Beispiel #1
0
        public Task <int> StartAsync(FixOptions options)
        {
            _options = options;
            _lua     = new LuaLint(_options.IndicoreRootPath, new List <string>());

            IEnumerable <string> files;

            if (File.Exists(options.Path))
            {
                var list = new List <string>();
                files = list;
                list.Add(options.Path);
            }
            else
            {
                files = Directory
                        .GetFiles(options.Path, "*.*", SearchOption.AllDirectories)
                        .Where(file => IsValidExtension(Path.GetExtension(file)))
                        .ToList();
            }
            foreach (var file in files)
            {
                FixFile(file);
            }
            return(Task.FromResult(1));
        }
Beispiel #2
0
        public Task <int> StartAsync(ListOptions options)
        {
            _options = options;
            _lua     = new LuaLint("", new List <string>());

            foreach (var check in _lua.Checks)
            {
                Console.WriteLine(check);
            }

            return(Task.FromResult(0));
        }
Beispiel #3
0
        public Task <int> StartAsync(ScannerOptions options)
        {
            _options = options;
            _lua     = new LuaLint(options.IndicoreRootPath, options.Excluded);

            IEnumerable <string> files;

            if (File.Exists(options.Path))
            {
                var list = new List <string>();
                files = list;
                list.Add(options.Path);
            }
            else
            {
                files = Directory
                        .GetFiles(options.Path, "*.*", SearchOption.AllDirectories)
                        .Where(file => IsValidExtension(Path.GetExtension(file)))
                        .ToList();
            }

            List <string> log = new List <string>();

            foreach (var file in files)
            {
                string[] warnings = GetWarnings(file);
                if (warnings.Length > 0)
                {
                    PrintWarnings(file, warnings);
                    log.Add("\n=== " + file + " ===");
                    log.AddRange(warnings);
                }
            }
            File.WriteAllLines(options.OutputFile, log.ToArray());
            return(Task.FromResult(0));
        }