Exemple #1
0
        private static int RunSonarGenericMetrics(SonarGenericMetricsCommandLineArgs a)
        {
            var fileSystem   = new FileSystem();
            var jsonParser   = new JsonListParser <DailyCodeChurn>(new FileStreamFactory());
            var converters   = new MeasureConverterListBuilder(new EnvironmentImpl()).Build(a);
            var jsonExporter = new JsonExporter(new FileStreamFactory());

            var processor = new SonarGenericMetricsProcessor(fileSystem, jsonParser, converters, jsonExporter, new ConsoleLoggerWithTimestamp());

            processor.Process(a);

            return(0);
        }
Exemple #2
0
        private static int RunDailyCodeChurn(DailyCodeChurnCommandLineArgs a)
        {
            var fileSystem          = new FileSystem();
            var jsonParser          = new JsonListParser <DailyCodeChurn>(new FileStreamFactory());
            var logger              = new ConsoleLoggerWithTimestamp();
            var exclusionsProcessor = new ExclusionsProcessor(a.Exclusions);
            var inclusionsProcessor = new InclusionsProcessor(a.Inclusions);
            var jsonExporter        = new JsonExporter(new FileStreamFactory());

            var processor = new DailyCodeChurnProcessor(fileSystem, jsonParser, logger, exclusionsProcessor, inclusionsProcessor, jsonExporter);

            processor.Process(a);

            return(0);
        }
Exemple #3
0
        private static int RunGitCodeChurnProcessor(GitExtractCommandLineArgs a)
        {
            var processWrapper       = new ProcessWrapper();
            var commandLineParser    = new CommandLineParser();
            var gitLogParser         = new GitLogParser();
            var logger               = new ConsoleLoggerWithTimestamp();
            var outputProcessor      = new JsonOutputProcessor(new DataConverter(), new FileStreamFactory(), logger);
            var bugDatabaseFactory   = new BugDatabaseFactory();
            var bugDatabaseDllLoader = new BugDatabaseDllLoader(logger, bugDatabaseFactory);
            var webRequest           = new WebRequest(new HttpClientWrapperFactory(bugDatabaseFactory));
            var fileSystem           = new FileSystem();
            var jsonParser           = new JsonListParser <WorkItem>(new FileStreamFactory());
            var bugDatabaseProcessor = new BugDatabaseProcessor(bugDatabaseDllLoader, webRequest, fileSystem, jsonParser, logger, a.BugDatabaseOutputFile);
            var processor            = new GitCodeChurnProcessor(commandLineParser, processWrapper, gitLogParser, outputProcessor, bugDatabaseProcessor, logger, a);

            processor.QueryBugDatabase();
            return(processor.Extract());
        }
Exemple #4
0
        private static int RunPerforceCodeChurnProcessor(P4ExtractCommandLineArgs a)
        {
            var processWrapper       = new ProcessWrapper();
            var changesParser        = new ChangesParser();
            var describeParser       = new DescribeParser();
            var commandLineParser    = new CommandLineParser();
            var logger               = new ConsoleLoggerWithTimestamp();
            var stopWatch            = new StopWatchWrapper();
            var outputProcessor      = new JsonOutputProcessor(new DataConverter(), new FileStreamFactory(), logger);
            var bugDatabaseFactory   = new BugDatabaseFactory();
            var bugDatabaseDllLoader = new BugDatabaseDllLoader(logger, bugDatabaseFactory);
            var webRequest           = new WebRequest(new HttpClientWrapperFactory(bugDatabaseFactory));
            var fileSystem           = new FileSystem();
            var jsonParser           = new JsonListParser <WorkItem>(new FileStreamFactory());
            var bugDatabaseProcessor = new BugDatabaseProcessor(bugDatabaseDllLoader, webRequest, fileSystem, jsonParser, logger, a.BugDatabaseOutputFile);
            var processor            = new PerforceCodeChurnProcessor(processWrapper, changesParser, describeParser, commandLineParser, bugDatabaseProcessor, logger, stopWatch, outputProcessor, a);

            processor.QueryBugDatabase();
            return(processor.Extract());
        }
Exemple #5
0
        private static int RunSonarGenericMetricsFromCosmosDb(SonarGenericMetricsCosmosDbCommandLineArgs a)
        {
            var logger       = new ConsoleLoggerWithTimestamp();
            var jsonParser   = new JsonListParser <DailyCodeChurn>(new FileStreamFactory());
            var jsonExporter = new JsonExporter(new FileStreamFactory());

            var cosmosConnection       = new CosmosConnection(new DatabaseFactory(a, JsonSerializerSettingsFactory.CreateDefaultSerializerSettingsForCosmosDB()), a.DatabaseId, Properties.Settings.Default.CosmosBulkBatchSize);
            var dataDocumentRepository = new DataDocumentRepository(cosmosConnection, a.CodeChurnCosmosContainer);
            var cosmosOutputProcessor  = new CosmosDbOutputProcessor(logger, dataDocumentRepository, new DataConverter(), a.CosmosProjectName, Properties.Settings.Default.CosmosBulkBatchSize);
            var environment            = new EnvironmentImpl();

            var converters = new MeasureConverterListBuilder(environment).Build(a);

            Dictionary <DateTime, Dictionary <string, DailyCodeChurn> > data;

            if (a.StartDate == null && a.EndDate == null)
            {
                data = cosmosOutputProcessor.GetAllDocumentsByProjectNameAndDocumentType <DailyCodeChurn>();
            }
            else
            {
                if (a.StartDate == null)
                {
                    throw new ArgumentNullException(nameof(a.StartDate));
                }
                if (a.EndDate == null)
                {
                    a.EndDate = environment.GetCurrentDateTime();
                }
                data = cosmosOutputProcessor.GetDocumentsInDateRange <DailyCodeChurn>(a.StartDate.Value, a.EndDate.Value);
            }

            var processor = new SonarGenericMetricsProcessor(jsonParser, converters, jsonExporter,
                                                             new ConsoleLoggerWithTimestamp(), new DataConverter());

            processor.Process(a, data);
            return(0);
        }
Exemple #6
0
        private static int RunGitToCosmosDbCodeChurnProcessor(GitExtractToCosmosDbCommandLineArgs a)
        {
            var processWrapper         = new ProcessWrapper();
            var commandLineParser      = new CommandLineParser();
            var gitLogParser           = new GitLogParser();
            var logger                 = new ConsoleLoggerWithTimestamp();
            var cosmosConnection       = new CosmosConnection(new DatabaseFactory(a, JsonSerializerSettingsFactory.CreateDefaultSerializerSettingsForCosmosDB()), a.DatabaseId, Properties.Settings.Default.CosmosBulkBatchSize);
            var dataDocumentRepository = new DataDocumentRepository(cosmosConnection, a.CodeChurnCosmosContainer);
            var cosmosOutputProcessor  = new CosmosDbOutputProcessor(logger, dataDocumentRepository, new DataConverter(), a.CosmosProjectName, Properties.Settings.Default.CosmosBulkBatchSize);
            var bugDatabaseFactory     = new BugDatabaseFactory();
            var bugDatabaseDllLoader   = new BugDatabaseDllLoader(logger, bugDatabaseFactory);
            var webRequest             = new WebRequest(new HttpClientWrapperFactory(bugDatabaseFactory));
            var fileSystem             = new FileSystem();
            var jsonParser             = new JsonListParser <WorkItem>(new FileStreamFactory());
            var bugDatabaseProcessor   = new BugDatabaseProcessor(bugDatabaseDllLoader, webRequest, fileSystem, jsonParser, logger, string.Empty);
            //, a.BugDatabaseOutputFile

            var processor = new GitCodeChurnProcessor(commandLineParser, processWrapper, gitLogParser, cosmosOutputProcessor, bugDatabaseProcessor, logger, a);

            processor.QueryBugDatabase();

            return(processor.Extract());
        }
 public GivenAJsonWorkItemParser()
 {
     streamFactory           = new Mock <IStreamFactory>();
     this.jsonWorkItemParser = new JsonListParser <WorkItem>(streamFactory.Object);
 }
Exemple #8
0
 public GivenAJsonDailyCodeChurnParser()
 {
     streamFactory = new Mock <IStreamFactory>();
     this.jsonDailyCodeChurnParser = new JsonListParser <DailyCodeChurn>(streamFactory.Object);
 }
    /// <summary>
    /// Loads the track list by retrieving the content json from the API.
    /// </summary>
    /// <param name="contentURL">The id of the content that will be sent as requet to the API.</param>
    public void LoadTrackList(string contentURL)
    {
        if (contentURL == null || contentURL.Length == 0)
        {
            return;
        }
        contentURL = "https://api.deezer.com/" + contentURL;
        Debug.Log(contentURL);
        string jsonContent = ApplicationMainScript.GetContentJson(contentURL);

        Debug.Log(jsonContent);
        if (contentURL.Contains("album"))
        {
            AlbumInfo albumInfo = JsonUtility.FromJson <AlbumInfo> (jsonContent);
            contentURL += "/tracks";
            jsonContent = ApplicationMainScript.GetContentJson(contentURL);
            jsonContent = jsonContent.Substring(jsonContent.IndexOf('['));
            jsonContent = jsonContent.Substring(0, jsonContent.LastIndexOf(']') + 1);
            jsonContent = "{\"Items\":" + jsonContent + "}";
            TrackInfo[] tracks = JsonListParser.FromJson <TrackInfo> (jsonContent);
            if (tracks.Length == 0)
            {
                return;
            }
            Debug.Log(tracks.Length);
            for (int i = 0; i < tracks.Length; i++)
            {
                tracks [i].album = albumInfo;
                AddTrackToList(tracks [i]);
            }
            TrackSelectPanelScript firstChild = transform.GetChild(0).gameObject.GetComponent <TrackSelectPanelScript> ();
            PlayingTrack.UpdateInfo(firstChild.trackName.text, firstChild.artistName.text, tracks [0].album.cover_small);
        }
        else if (contentURL.Contains("track"))
        {
            TrackInfo trackInfo = JsonUtility.FromJson <TrackInfo> (jsonContent);
            AddTrackToList(trackInfo);
            TrackSelectPanelScript firstChild = transform.GetChild(0).gameObject.GetComponent <TrackSelectPanelScript> ();
            PlayingTrack.UpdateInfo(firstChild.trackName.text, firstChild.artistName.text, trackInfo.album.cover_small);
        }
        else if (contentURL.Contains("playlist") || contentURL.Contains("radio"))
        {
            contentURL += "/tracks";
            jsonContent = ApplicationMainScript.GetContentJson(contentURL);
            jsonContent = jsonContent.Substring(jsonContent.IndexOf('['));
            jsonContent = jsonContent.Substring(0, jsonContent.LastIndexOf(']') + 1);
            jsonContent = "{\"Items\":" + jsonContent + "}";
            TrackInfo[] tracks = JsonListParser.FromJson <TrackInfo> (jsonContent);
            if (tracks.Length == 0)
            {
                return;
            }
            for (int i = 0; i < tracks.Length; i++)
            {
                AddTrackToList(tracks [i]);
            }
        }
        else
        {
            return;
        }
        Tracks [0].SetSelected();
    }