import issues from './list'

/**
 * Help Url
 *
 * Construct a link to a helpful neurostars query, based on the
 * issue key
 */
const constructHelpUrl = issue => {
  const neurostarsPrefix = 'https://neurostars.org/'
  const searchQuery = issue && issue.key ? 'search?q=' + issue.key : ''
  const helpUrl = neurostarsPrefix + searchQuery
  return helpUrl
}

/**
 * Issue
 *
 * A constructor for BIDS issues.
 */
export default function(options) {
  const code = options.hasOwnProperty('code') ? options.code : null
  const issue = issues[code]

  this.key = issue.key
  this.code = code
  this.file = options.hasOwnProperty('file') ? options.file : null
  this.evidence = options.hasOwnProperty('evidence') ? options.evidence : null
  this.line = options.hasOwnProperty('line') ? options.line : null
  this.character = options.hasOwnProperty('character')
    ? options.character
    : null
  this.severity = options.hasOwnProperty('severity')
    ? options.severity
    : issue.severity
  this.reason = options.hasOwnProperty('reason') ? options.reason : issue.reason
  this.helpUrl = constructHelpUrl(issue)
}

@@ -408,33 +408,749 @@
 .%0A *
-/%0Aexport default 
+%0A * @param %7BObject%7D options%0A * @param %7Bstring%7D options.key The descriptive string matching the issue code%0A * @param %7Bnumber%7D options.code Issue code - see 'list.js' for definitions%0A * @param %7Bstring%7D %5Boptions.file%5D The relative path of the affected file%0A * @param %7Bstring%7D %5Boptions.evidence%5D The value throwing this issue%0A * @param %7Bnumber%7D %5Boptions.line%5D The line of the affected file (if within a file)%0A * @param %7Bnumber%7D %5Boptions.character%5D The character offset in the affected line%0A * @param %7Bstring%7D %5Boptions.severity%5D Is this an error or warning?%0A * @param %7Bstring%7D %5Boptions.reason%5D A descriptive%0A * @param %7Bstring%7D %5Boptions.helpUrl%5D A URL providing documentation to help solve this error%0A * @returns %7BObject%7D Issue object%0A */%0A
 function
 (opt
@@ -1145,16 +1145,22 @@
 function
+ Issue
 (options
@@ -1825,10 +1825,32 @@
 (issue)%0A
-
 %7D%0A
+%0Aexport default Issue%0A

Document the Issue object constructor with types and field usage.