<commit_before>require 'tester/reporter/status_code_report'
require 'tester/modules/module'
require 'tester/util/supported_verbs'

class Typo < Module
    def go(definition, report)
        super

        contract = allowances(definition)

        contract.each do |url, verbs|
            check_verbs definition, url, verbs

            check_typo_url definition, url
        end

        report.reports == []
    end

    def check_verbs definition, url, verbs
        missing_verbs = SupportedVerbs.all - verbs
        puts "Missing verbs: #{missing_verbs}"
        missing_verbs.each do |verb|
            response = call url, verb
            request = Request.new

            test = TypoClass.new response, request.payload, definition.not_allowed_response, url, verb
            reports = test.check
            puts "Verb check found #{reports.size}"
            puts reports
            puts "****"
            self.report.reports.concat reports
        end
    end

    def check_typo_url definition, url
        bad_url = "#{url}gibberishadsfasdf"
        request = Request.new
        response = call bad_url, SupportedVerbs::GET

        test = TypoClass.new response, request.payload, definition.not_found_response, bad_url, SupportedVerbs::GET
            reports = test.check
            puts "Mistype url check found #{reports.size}"
            puts reports
            puts "****"
        self.report.reports.concat reports
    end

    def allowances(definition)
        allowances = {}
        definition.methods.each do |method|
            url = method.url
            if allowances[url]
                allowances[url] << method.verb
            else
                allowances[url] = [method.verb]
            end
        end
        allowances
    end

    def call(url, verb)
        begin
            RestClient::Request.execute(method: verb, url: url,
                                timeout: 10)
        rescue RestClient::ExceptionWithResponse => e<commit_msg>Removing output so all in reporting<commit_after>require 'tester/reporter/status_code_report'
require 'tester/modules/module'
require 'tester/util/supported_verbs'

class Typo < Module
    def go(definition, report)
        super

        contract = allowances(definition)

        contract.each do |url, verbs|
            check_verbs definition, url, verbs

            check_typo_url definition, url
        end

        report.reports == []
    end

    def check_verbs definition, url, verbs
        missing_verbs = SupportedVerbs.all - verbs
        puts "Missing verbs: #{missing_verbs}"
        missing_verbs.each do |verb|
            response = call url, verb
            request = Request.new

            test = TypoClass.new response, request.payload, definition.not_allowed_response, url, verb
            reports = test.check
            self.report.reports.concat reports
        end
    end

    def check_typo_url definition, url
        bad_url = "#{url}gibberishadsfasdf"
        request = Request.new
        response = call bad_url, SupportedVerbs::GET

        test = TypoClass.new response, request.payload, definition.not_found_response, bad_url, SupportedVerbs::GET
            reports = test.check
        self.report.reports.concat reports
    end

    def allowances(definition)
        allowances = {}
        definition.methods.each do |method|
            url = method.url
            if allowances[url]
                allowances[url] << method.verb
            else
                allowances[url] = [method.verb]
            end
        end
        allowances
    end

    def call(url, verb)
        begin
            RestClient::Request.execute(method: verb, url: url,
                                timeout: 10)
        rescue RestClient::ExceptionWithResponse => e
{'fraction_non_alphanumeric': 0.0769433465085639, 'fraction_numerical': 0.001054018445322793, 'mean_word_length': 1.9267540478026215, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5255808', 'n_tokens_mistral': 1039, 'n_tokens_neox': 1000, 'n_words': 259}