<commit_before>fs = require 'fs'
logger = require 'winston'
path = require 'path'



class Report

  constructor: (@options) ->

    reporter = @options.reporter

    ext = @options.output.split('.').pop() if @options.output

    if ext is 'xml' and reporter is 'json' or
       ext is 'json' and reporter is 'xml'

      logger.warn "output file extention '#{@options.output}'
                  does not match reporter '#{reporter}'"


    switch reporter
      when 'xml' then reporter = './reporters/xml-pmd'
      when 'json' then reporter = './reporters/json'
      else reporter = path.join(process.cwd(), reporter)

    @reporter = require reporter
    @stdReporter = require './reporters/_std-log'

  generate: (@map) ->

    [raw, dump, log] = @reporter()
    log = @stdReporter() unless log

    logger.info log
    if @options.output
      fs.writeFileSync(@options.output, dump or raw)
    else<commit_msg>removing double line<commit_after>fs = require 'fs'
logger = require 'winston'
path = require 'path'



class Report

  constructor: (@options) ->

    reporter = @options.reporter

    ext = @options.output.split('.').pop() if @options.output

    if ext is 'xml' and reporter is 'json' or
       ext is 'json' and reporter is 'xml'

      logger.warn "output file extention '#{@options.output}'
                  does not match reporter '#{reporter}'"

    switch reporter
      when 'xml' then reporter = './reporters/xml-pmd'
      when 'json' then reporter = './reporters/json'
      else reporter = path.join(process.cwd(), reporter)

    @reporter = require reporter
    @stdReporter = require './reporters/_std-log'

  generate: (@map) ->

    [raw, dump, log] = @reporter()
    log = @stdReporter() unless log

    logger.info log
    if @options.output
      fs.writeFileSync(@options.output, dump or raw)
    else
{'fraction_non_alphanumeric': 0.13029315960912052, 'fraction_numerical': 0.0, 'mean_word_length': 2.776639344262295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6371732', 'n_tokens_mistral': 577, 'n_tokens_neox': 543, 'n_words': 173}