<commit_before>﻿using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace DidntHappenTest
{
    class Program
    {
        /// <summary>
        /// Entry point of application.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("                               If it's not documented it\n");
            sb.Append("██████╗ ██╗██████╗ ███╗   ██╗█╗████████╗    ██╗  ██╗ █████╗ ██████╗ ██████╗ ███████╗███╗   ██╗\n");
            sb.Append("██╔══██╗██║██╔══██╗████╗  ██║╚╝╚══██╔══╝    ██║  ██║██╔══██╗██╔══██╗██╔══██╗██╔════╝████╗  ██║\n");
            sb.Append("██║  ██║██║██║  ██║██╔██╗ ██║     ██║       ███████║███████║██████╔╝██████╔╝█████╗  ██╔██╗ ██║\n");
            sb.Append("██║  ██║██║██║  ██║██║╚██╗██║     ██║       ██╔══██║██╔══██║██╔═══╝ ██╔═══╝ ██╔══╝  ██║╚██╗██║\n");
            sb.Append("██████╔╝██║██████╔╝██║ ╚████║     ██║       ██║  ██║██║  ██║██║     ██║     ███████╗██║ ╚████║\n");
            sb.Append("╚═════╝ ╚═╝╚═════╝ ╚═╝  ╚═══╝     ╚═╝       ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝     ╚══════╝╚═╝  ╚═══╝\n");

            Console.WriteLine(sb.ToString());
            // Regular expressions
            string rgxMethod = @"(^\s*(private|public|static)+.*[)]$)";
            string rgxComment = @"^([ \t]*)([//]{2,})(.*)$";
            Regex r = new Regex(rgxMethod);
            Regex rr = new Regex(rgxComment);

            // Get the files
            string[] filePaths;

            try
            {
                filePaths = Directory.GetFiles(@"H:\GitHub\PathEditor\PathEditor\PathEditor", "*.cs", SearchOption.AllDirectories);
                //filePaths = Directory.GetFiles(@"H:\GitHub\", "*.cs", SearchOption.AllDirectories);
            }
            catch(Exception e)
            {
                Console.WriteLine("Unable to load the files.");
                return;
            }

            // Check if the file contains documentation
            foreach (var filePath in filePaths)
            {
                Console.WriteLine("Checking if {0} contains documentation...", filePath);

                using (StreamReader sr = new StreamReader(filePath))
                {
                    int lineNumber = 0;
                    
                    bool foundError = false;

                    string prevLine = String.Empty;
                    string curLine = String.Empty;
                    
                    while(true)
                    {
                        lineNumber++;
                        prevLine = curLine;
                        curLine = sr.ReadLine();
                        if(curLine == null)
                        {
                            break;
                        }

                        if (r.Match(curLine).Success && !(rr.IsMatch(prevLine)))
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("\tMissing documentation on line: {0}", lineNumber);
                            Console.WriteLine("\t\tprevLine: {0}\n\t\tcurLine: {1}", prevLine, curLine);
                            Console.ResetColor();
                            foundError = true;
                        }
                    }

                    string preText = String.Empty;
                    if (!foundError)
                    {
                        preText = "No errors";
                        Console.ForegroundColor = ConsoleColor.Green;
                    }
                    else
                    {
                        preText = "Errors ";
                        Console.BackgroundColor = ConsoleColor.Red;
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    Console.WriteLine("\t{0} found in:  {1}",preText, filePath);
                    Console.ResetColor();
                }
            }
            Console.ReadLine();
        }
    }
}<commit_msg>Added args<commit_after>﻿using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace DidntHappenTest
{
    class Program
    {
        /// <summary>
        /// Entry point of application.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("                               If it's not documented it\n");
            sb.Append("██████╗ ██╗██████╗ ███╗   ██╗█╗████████╗    ██╗  ██╗ █████╗ ██████╗ ██████╗ ███████╗███╗   ██╗\n");
            sb.Append("██╔══██╗██║██╔══██╗████╗  ██║╚╝╚══██╔══╝    ██║  ██║██╔══██╗██╔══██╗██╔══██╗██╔════╝████╗  ██║\n");
            sb.Append("██║  ██║██║██║  ██║██╔██╗ ██║     ██║       ███████║███████║██████╔╝██████╔╝█████╗  ██╔██╗ ██║\n");
            sb.Append("██║  ██║██║██║  ██║██║╚██╗██║     ██║       ██╔══██║██╔══██║██╔═══╝ ██╔═══╝ ██╔══╝  ██║╚██╗██║\n");
            sb.Append("██████╔╝██║██████╔╝██║ ╚████║     ██║       ██║  ██║██║  ██║██║     ██║     ███████╗██║ ╚████║\n");
            sb.Append("╚═════╝ ╚═╝╚═════╝ ╚═╝  ╚═══╝     ╚═╝       ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝     ╚══════╝╚═╝  ╚═══╝\n");
            Console.WriteLine(sb.ToString());


            // Test if input arguments were supplied:
            if (args.Length == 0)
            {
                Console.WriteLine("No path was passed in to check.\nClosing application.");
                return;
            }

            if (!Directory.Exists(args[0]))
            {
                Console.Write("The path specified does not exist;\n {0}\nClosing application.", args[0]);
                return;
            }

            // Get the files
            string[] filePaths;

            try
            {
                filePaths = Directory.GetFiles(args[0], "*.cs", SearchOption.AllDirectories);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to load the files.");
                return;
            }


            // Regular expressions
            const string rgxMethod = @"(^\s*(private|public|static)+.*[)]$)";
            const string rgxComment = @"^([ \t]*)([//]{2,})(.*)$";
            var r = new Regex(rgxMethod);
            var rr = new Regex(rgxComment);

            // Check if the file contains documentation
            foreach (var filePath in filePaths)
            {
                Console.WriteLine("Checking if {0} contains documentation...", filePath);

                using (StreamReader sr = new StreamReader(filePath))
                {
                    int lineNumber = 0;

                    bool foundError = false;

                    string prevLine = String.Empty;
                    string curLine = String.Empty;

                    while (true)
                    {
                        lineNumber++;
                        prevLine = curLine;
                        curLine = sr.ReadLine();
                        if (curLine == null)
                        {
                            break;
                        }

                        if (r.Match(curLine).Success && !(rr.IsMatch(prevLine)))
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("\tMissing documentation on line: {0}", lineNumber);
                            Console.WriteLine("\t\tPrevious Line:\t{0}\n\t\tCurrent Line:\t{1}", prevLine, curLine);
                            Console.ResetColor();
                            foundError = true;
                        }
                    }

                    string preText = String.Empty;
                    if (!foundError)
                    {
                        preText = "No errors";
                        Console.ForegroundColor = ConsoleColor.Green;
                    }
                    else
                    {
                        preText = "Errors";
                        Console.BackgroundColor = ConsoleColor.Red;
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    Console.WriteLine("\t{0} found in:  {1}", preText, filePath);
                    Console.ResetColor();
                }
            }
            Console.ReadLine();
        }
    }
}
{'fraction_non_alphanumeric': 0.19763593380614658, 'fraction_numerical': 0.0024822695035460994, 'mean_word_length': 1.1823574929068867, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2638333', 'n_tokens_mistral': 2669, 'n_tokens_neox': 2574, 'n_words': 455}