Updated

db/migrate / 20160210195916_import_initial_locations.rb

D
253 lines of codes
2 methods
119.0 complexity/method
2 churn
238.0 complexity
0 duplications
class ImportInitialLocations < ActiveRecord::Migration
  1. ImportInitialLocations has no descriptive comment
class Location < ActiveRecord::Base; end
  1. ImportInitialLocations::Location has no descriptive comment
def up
  1. ImportInitialLocations#up has a flog score of 237
  2. ImportInitialLocations#up has approx 237 statements
  3. ImportInitialLocations#up doesn't depend on instance state (maybe move it to another class?)
# These are territories that aren't officially recognised # as countries by the FCO but do appear in ISO 3166-1 alpha-2. # The names are taken from https://www.gov.uk/api/world-locations Location.create!(code: "AS", name: "American Samoa") Location.create!(code: "AI", name: "Anguilla") Location.create!(code: "AW", name: "Aruba") Location.create!(code: "BM", name: "Bermuda") Location.create!(code: "BAT", name: "British Antarctic Territory") Location.create!(code: "IO", name: "British Indian Ocean Territory") Location.create!(code: "VG", name: "British Virgin Islands") Location.create!(code: "KY", name: "Cayman Islands") Location.create!(code: "XC", name: "Channel Islands", end_date: "2016-02-11") Location.create!(code: "FK", name: "Falkland Islands") Location.create!(code: "GF", name: "French Guiana") Location.create!(code: "PF", name: "French Polynesia") Location.create!(code: "GI", name: "Gibraltar") Location.create!(code: "GP", name: "Guadeloupe") Location.create!(code: "HK", name: "Hong Kong") Location.create!(code: "IM", name: "Isle of Man") Location.create!(code: "MO", name: "Macao") Location.create!(code: "MQ", name: "Martinique") Location.create!(code: "YT", name: "Mayotte") Location.create!(code: "MS", name: "Montserrat") Location.create!(code: "NC", name: "New Caledonia") Location.create!(code: "PS", name: "The Occupied Palestinian Territories") Location.create!(code: "PN", name: "Pitcairn Island") Location.create!(code: "RE", name: "Réunion") Location.create!(code: "GS", name: "South Georgia and the South Sandwich Islands") Location.create!(code: "PM", name: "St Pierre & Miquelon") Location.create!(code: "TW", name: "Taiwan") Location.create!(code: "TC", name: "Turks and Caicos Islands") Location.create!(code: "WF", name: "Wallis and Futuna") Location.create!(code: "EH", name: "Western Sahara") Location.create!(code: "SH", name: "St Helena, Ascension and Tristan da Cunha") Location.create!(code: "BQ", name: "Bonaire/St Eustatius/Saba") Location.create!(code: "CW", name: "Curaçao") Location.create!(code: "GG", name: "Guernsey") Location.create!(code: "JE", name: "Jersey") Location.create!(code: "BL", name: "Saint-Barthélemy") Location.create!(code: "SX", name: "St Maarten") Location.create!(code: "MF", name: "St Martin") # These are countries offically recognised by the FCO # Data is taken from https://country.register.gov.uk/records Location.create!(code: "GM", name: "Gambia,The") Location.create!(code: "ZW", name: "Zimbabwe", start_date: "1980-04-18") Location.create!(code: "ZM", name: "Zambia") Location.create!(code: "YE", name: "Yemen", start_date: "1990-05-22") Location.create!(code: "VN", name: "Vietnam") Location.create!(code: "VE", name: "Venezuela") Location.create!(code: "VA", name: "Vatican City") Location.create!(code: "VU", name: "Vanuatu", start_date: "1980-07-30") Location.create!(code: "UZ", name: "Uzbekistan", start_date: "1991-09-01") Location.create!(code: "UY", name: "Uruguay") Location.create!(code: "US", name: "United States") Location.create!(code: "AE", name: "United Arab Emirates") Location.create!(code: "UA", name: "Ukraine", start_date: "1991-08-24") Location.create!(code: "UG", name: "Uganda") Location.create!(code: "TV", name: "Tuvalu", start_date: "1978-10-01") Location.create!(code: "TM", name: "Turkmenistan", start_date: "1991-10-27") Location.create!(code: "TR", name: "Turkey") Location.create!(code: "TN", name: "Tunisia") Location.create!(code: "TT", name: "Trinidad and Tobago") Location.create!(code: "TO", name: "Tonga") Location.create!(code: "TG", name: "Togo") Location.create!(code: "TH", name: "Thailand") Location.create!(code: "TZ", name: "Tanzania") Location.create!(code: "TJ", name: "Tajikistan", start_date: "1991-09-09") Location.create!(code: "SY", name: "Syria") Location.create!(code: "CH", name: "Switzerland") Location.create!(code: "SE", name: "Sweden") Location.create!(code: "SZ", name: "Swaziland") Location.create!(code: "SR", name: "Suriname", start_date: "1975-11-25") Location.create!(code: "SD", name: "Sudan") Location.create!(code: "LK", name: "Sri Lanka") Location.create!(code: "ES", name: "Spain") Location.create!(code: "SS", name: "South Sudan", start_date: "2011-07-09") Location.create!(code: "ZA", name: "South Africa") Location.create!(code: "SO", name: "Somalia") Location.create!(code: "SB", name: "Solomon Islands", start_date: "1978-07-07") Location.create!(code: "SI", name: "Slovenia", start_date: "1991-06-25") Location.create!(code: "SK", name: "Slovakia", start_date: "1993-01-01") Location.create!(code: "SG", name: "Singapore") Location.create!(code: "SL", name: "Sierra Leone") Location.create!(code: "SC", name: "Seychelles", start_date: "1976-06-29") Location.create!(code: "RS", name: "Serbia") Location.create!(code: "SN", name: "Senegal") Location.create!(code: "SA", name: "Saudi Arabia") Location.create!(code: "ST", name: "Sao Tome and Principe", start_date: "1975-07-12") Location.create!(code: "SM", name: "San Marino") Location.create!(code: "WS", name: "Samoa") Location.create!(code: "VC", name: "St Vincent", start_date: "1979-10-27") Location.create!(code: "LC", name: "St Lucia", start_date: "1979-02-22") Location.create!(code: "KN", name: "St Kitts and Nevis", start_date: "1983-09-19") Location.create!(code: "RW", name: "Rwanda") Location.create!(code: "RU", name: "Russia", start_date: "1991-12-25") Location.create!(code: "RO", name: "Romania") Location.create!(code: "QA", name: "Qatar") Location.create!(code: "PT", name: "Portugal") Location.create!(code: "PL", name: "Poland") Location.create!(code: "PH", name: "Philippines") Location.create!(code: "PE", name: "Peru") Location.create!(code: "PY", name: "Paraguay") Location.create!(code: "PG", name: "Papua New Guinea", start_date: "1975-09-16") Location.create!(code: "PA", name: "Panama") Location.create!(code: "PW", name: "Palau", start_date: "1994-10-01") Location.create!(code: "PK", name: "Pakistan") Location.create!(code: "OM", name: "Oman") Location.create!(code: "NO", name: "Norway") Location.create!(code: "NG", name: "Nigeria") Location.create!(code: "NE", name: "Niger") Location.create!(code: "NI", name: "Nicaragua") Location.create!(code: "NZ", name: "New Zealand") Location.create!(code: "NL", name: "Netherlands") Location.create!(code: "NP", name: "Nepal") Location.create!(code: "NR", name: "Nauru") Location.create!(code: "NA", name: "Namibia", start_date: "1980-03-21") Location.create!(code: "MZ", name: "Mozambique", start_date: "1975-06-25") Location.create!(code: "MA", name: "Morocco") Location.create!(code: "ME", name: "Montenegro") Location.create!(code: "MN", name: "Mongolia") Location.create!(code: "MC", name: "Monaco") Location.create!(code: "MD", name: "Moldova", start_date: "1991-08-27") Location.create!(code: "FM", name: "Micronesia", start_date: "1986-11-03") Location.create!(code: "MX", name: "Mexico") Location.create!(code: "MU", name: "Mauritius") Location.create!(code: "MR", name: "Mauritania") Location.create!(code: "MH", name: "Marshall Islands", start_date: "1986-10-21") Location.create!(code: "MT", name: "Malta") Location.create!(code: "ML", name: "Mali") Location.create!(code: "MV", name: "Maldives") Location.create!(code: "MY", name: "Malaysia") Location.create!(code: "MW", name: "Malawi") Location.create!(code: "MG", name: "Madagascar") Location.create!(code: "MK", name: "Macedonia", start_date: "1991-09-08") Location.create!(code: "LU", name: "Luxembourg") Location.create!(code: "LT", name: "Lithuania", start_date: "1990-03-11") Location.create!(code: "LI", name: "Liechtenstein") Location.create!(code: "LY", name: "Libya") Location.create!(code: "LR", name: "Liberia") Location.create!(code: "LS", name: "Lesotho") Location.create!(code: "LB", name: "Lebanon") Location.create!(code: "LV", name: "Latvia", start_date: "1990-05-04") Location.create!(code: "LA", name: "Laos") Location.create!(code: "KG", name: "Kyrgyzstan", start_date: "1991-08-31") Location.create!(code: "KW", name: "Kuwait") Location.create!(code: "XK", name: "Kosovo") Location.create!(code: "KR", name: "South Korea") Location.create!(code: "KP", name: "North Korea") Location.create!(code: "KI", name: "Kiribati", start_date: "1979-07-12") Location.create!(code: "KE", name: "Kenya") Location.create!(code: "KZ", name: "Kazakhstan", start_date: "1991-12-16") Location.create!(code: "JO", name: "Jordan") Location.create!(code: "JP", name: "Japan") Location.create!(code: "JM", name: "Jamaica") Location.create!(code: "CI", name: "Ivory Coast") Location.create!(code: "IT", name: "Italy") Location.create!(code: "IL", name: "Israel") Location.create!(code: "IE", name: "Ireland") Location.create!(code: "IQ", name: "Iraq") Location.create!(code: "IR", name: "Iran") Location.create!(code: "ID", name: "Indonesia") Location.create!(code: "IN", name: "India") Location.create!(code: "IS", name: "Iceland") Location.create!(code: "HU", name: "Hungary") Location.create!(code: "HN", name: "Honduras") Location.create!(code: "HT", name: "Haiti") Location.create!(code: "GY", name: "Guyana") Location.create!(code: "GW", name: "Guinea-Bissau") Location.create!(code: "GN", name: "Guinea") Location.create!(code: "GT", name: "Guatemala") Location.create!(code: "GD", name: "Grenada", start_date: "1974-02-07") Location.create!(code: "GR", name: "Greece") Location.create!(code: "GH", name: "Ghana") Location.create!(code: "DE", name: "Germany", start_date: "1990-10-03") Location.create!(code: "GE", name: "Georgia", start_date: "1991-04-09") Location.create!(code: "GA", name: "Gabon") Location.create!(code: "FR", name: "France") Location.create!(code: "FI", name: "Finland") Location.create!(code: "FJ", name: "Fiji") Location.create!(code: "ET", name: "Ethiopia") Location.create!(code: "EE", name: "Estonia", start_date: "1991-08-20") Location.create!(code: "ER", name: "Eritrea", start_date: "1993-05-24") Location.create!(code: "GQ", name: "Equatorial Guinea") Location.create!(code: "SV", name: "El Salvador") Location.create!(code: "EG", name: "Egypt") Location.create!(code: "EC", name: "Ecuador") Location.create!(code: "TL", name: "East Timor") Location.create!(code: "DO", name: "Dominican Republic") Location.create!(code: "DM", name: "Dominica", start_date: "1978-11-03") Location.create!(code: "DJ", name: "Djibouti", start_date: "1977-06-27") Location.create!(code: "DK", name: "Denmark") Location.create!(code: "CZ", name: "Czech Republic", start_date: "1993-01-01") Location.create!(code: "CY", name: "Cyprus") Location.create!(code: "CU", name: "Cuba") Location.create!(code: "HR", name: "Croatia", start_date: "1991-06-25") Location.create!(code: "CR", name: "Costa Rica") Location.create!(code: "CD", name: "Congo (Democratic Republic)") Location.create!(code: "CG", name: "Congo") Location.create!(code: "KM", name: "Comoros", start_date: "1975-07-06") Location.create!(code: "CO", name: "Colombia") Location.create!(code: "CN", name: "China") Location.create!(code: "CL", name: "Chile") Location.create!(code: "TD", name: "Chad") Location.create!(code: "CF", name: "Central African Republic") Location.create!(code: "CV", name: "Cape Verde", start_date: "1975-07-05") Location.create!(code: "CA", name: "Canada") Location.create!(code: "CM", name: "Cameroon") Location.create!(code: "KH", name: "Cambodia") Location.create!(code: "BI", name: "Burundi") Location.create!(code: "MM", name: "Burma") Location.create!(code: "BF", name: "Burkina Faso") Location.create!(code: "BG", name: "Bulgaria") Location.create!(code: "BN", name: "Brunei", start_date: "1984-01-01") Location.create!(code: "BR", name: "Brazil") Location.create!(code: "BW", name: "Botswana") Location.create!(code: "BA", name: "Bosnia and Herzegovina", start_date: "1992-03-03") Location.create!(code: "BO", name: "Bolivia") Location.create!(code: "BT", name: "Bhutan") Location.create!(code: "BJ", name: "Benin") Location.create!(code: "BZ", name: "Belize", start_date: "1981-09-21") Location.create!(code: "BE", name: "Belgium") Location.create!(code: "BY", name: "Belarus", start_date: "1991-08-25") Location.create!(code: "BB", name: "Barbados") Location.create!(code: "BD", name: "Bangladesh") Location.create!(code: "BH", name: "Bahrain") Location.create!(code: "BS", name: "Bahamas,The") Location.create!(code: "AZ", name: "Azerbaijan", start_date: "1991-08-30") Location.create!(code: "AT", name: "Austria") Location.create!(code: "AU", name: "Australia") Location.create!(code: "AM", name: "Armenia", start_date: "1991-09-21") Location.create!(code: "AR", name: "Argentina") Location.create!(code: "AG", name: "Antigua and Barbuda", start_date: "1981-11-01") Location.create!(code: "AO", name: "Angola", start_date: "1975-11-11") Location.create!(code: "AD", name: "Andorra") Location.create!(code: "DZ", name: "Algeria") Location.create!(code: "AL", name: "Albania") Location.create!(code: "AF", name: "Afghanistan") Location.create!(code: "GB", name: "United Kingdom") Location.create!(code: "CS", name: "Czechoslovakia", end_date: "1992-12-31") Location.create!(code: "YU", name: "Yugoslavia", end_date: "1992-04-28") Location.create!(code: "DD", name: "East Germany", end_date: "1990-10-02") Location.create!(code: "SU", name: "USSR", end_date: "1991-12-25") end def down
  1. ImportInitialLocations#down doesn't depend on instance state (maybe move it to another class?)
Location.delete_all end end