public override void Init(IRepositoryResolver repositories, IEnumerable<string> releases)
        {
            base.Init(repositories, releases);

            regression = new LogisticRegression();

            string previousRevision = null;
            foreach (var revision in TrainReleases)
            {
                foreach (var file in GetFilesInRevision(revision))
                {
                    context
                        .SetCommits(previousRevision, revision)
                        .SetFiles(e => e.IdIs(file.ID));

                    regression.AddTrainingData(
                        GetPredictorValuesFor(context),
                        FileHasDefects(file.ID, revision, previousRevision)
                    );
                }
                previousRevision = revision;
            }

            regression.Train();

            context.SetCommits(TrainReleases.Last(), PredictionRelease);
        }
コード例 #2
0
 public RelateEntityDispatcher(
     IRepositoryResolver repositoryResolver,
     IAuthService authService)
 {
     _repositoryResolver = repositoryResolver;
     _authService        = authService;
 }
コード例 #3
0
 public RepositoryEventService(
     ISetupResolver <ICollectionSetup> collectionResolver,
     IRepositoryResolver repositoryResolver)
 {
     _collectionResolver = collectionResolver;
     _repositoryResolver = repositoryResolver;
 }
        public override void Init(IRepositoryResolver repositories, IEnumerable<string> releases)
        {
            base.Init(repositories, releases);

            double dd = repositories.SelectionDSL()
                .Commits().TillRevision(PredictionRelease)
                .Modifications().InCommits()
                .CodeBlocks().InModifications().CalculateDefectDensity(PredictionRelease);

            context.SetCommits(null, PredictionRelease);

            regression = new LinearRegression();
            foreach (var file in GetFilesInRevision(PredictionRelease))
            {
                double ddForFile = repositories.SelectionDSL()
                    .Commits().TillRevision(PredictionRelease)
                    .Files().IdIs(file.ID)
                    .Modifications().InCommits().InFiles()
                    .CodeBlocks().InModifications().CalculateDefectDensity(PredictionRelease);

                if (ddForFile >= dd)
                {
                    context.SetFiles(e => e.IdIs(file.ID));

                    regression.AddTrainingData(
                        GetPredictorValuesFor(context)[0],
                        NumberOfFixedDefectsForFile(file.ID)
                    );
                }
            }

            regression.Train();
        }
コード例 #5
0
 public RepositoryResolverTests(EshopApiConfigurationFixture fixture)
 {
     _sut = new RepositoryResolver(
         new ServiceCollection()
         .AddEShop(fixture.Configuration)
         .BuildServiceProvider());
 }
コード例 #6
0
        protected override double[] DistributionData(IRepositoryResolver repositories)
        {
            var commits = repositories.Repository<Commit>()
                .Select(c => new
                {
                    Revision = c.Revision,
                    Message = c.Message
                }).ToArray();

            List<double> deletedToAdded = new List<double>();
            double added, deleted;

            foreach (var c in commits)
            {
                var code = repositories.SelectionDSL()
                    .Commits()
                        .RevisionIs(c.Revision)
                    .Modifications()
                        .InCommits()
                    .CodeBlocks()
                        .InModifications().Fixed();

                added = code.Added().CalculateLOC();
                if (added > 0)
                {
                    deleted = -code.Deleted().CalculateLOC();
                    deletedToAdded.Add(deleted / added);
                }
            }

            return deletedToAdded.ToArray();
        }
コード例 #7
0
        public void SetUp()
        {
            parent = new Parent
            {
                Id = 10,
                Name = "Parent from repository",
                Child = new Child
                {
                    Id = 3,
                    Name = "Child of Parent from repository"
                }
            };

            parentRepository = new FakeRepository(id => parent);
            childRepository = new FakeRepository(id => parent.Child);

            repositoryResolver = MockRepository.GenerateStub<IRepositoryResolver>();
            repositoryResolver.Stub(r => r.GetRepository(typeof (Parent))).Return(parentRepository);
            repositoryResolver.Stub(r => r.GetRepository(typeof (Child))).Return(childRepository);

            entityModelBinder = new EntityModelBinder(repositoryResolver);
            controllerContext = new ControllerContext
            {
                HttpContext = MockRepository.GenerateStub<HttpContextBase>()
            };
            request = MockRepository.GenerateStub<HttpRequestBase>();
            controllerContext.HttpContext.Stub(x => x.Request).Return(request);

            entityModelBinder.SetModelBinderDictionary(new ModelBinderDictionary { DefaultBinder = entityModelBinder });
        }
コード例 #8
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="connectionFactory">连接工厂实例</param>
 /// <param name="resolver">仓储接口</param>
 public DapperUnitOfWork(
     IConnectionFactory connectionFactory,
     IRepositoryResolver resolver)
 {
     _resolver          = resolver;
     _connectionFactory = connectionFactory;
 }
コード例 #9
0
ファイル: Distribution.cs プロジェクト: BMichael998/msr-tools
        public override void Calc(IRepositoryResolver repositories)
        {
            var data = DistributionData(repositories);

            if (ShowProbabilityDistribution)
            {
                x = new double[data.Length];
                y = new double[data.Length];

                for (int i = 0; i < data.Length; i++)
                {
                    x[i] = data[i];
                    y[i] = (double)data.Where(d => d <= data[i]).Count() / data.Count();
                }
            }

            if (ShowProbabilityDensity)
            {
                densityX = new double[Intervals];
                densityY = new double[Intervals];

                double delta = data.Max() / Intervals;

                for (int i = 0; i < Intervals; i++)
                {
                    densityX[i] = i * delta + delta / 2;
                    densityY[i] = (double)data.Where(d => d >= i*delta && d < (i+1)*delta).Count() / data.Count();
                }
            }

            Legend = string.Format(
                "Mean = {0:0.00} Standard deviation = {1:0.00}",
                Accord.Statistics.Tools.Mean(x), Accord.Statistics.Tools.StandardDeviation(x)
            );
        }
コード例 #10
0
        public void SetUp()
        {
            parent = new Parent
            {
                Id    = 10,
                Name  = "Parent from repository",
                Child = new Child
                {
                    Id   = 3,
                    Name = "Child of Parent from repository"
                }
            };

            parentRepository = new FakeRepository(id => parent);
            childRepository  = new FakeRepository(id => parent.Child);

            repositoryResolver = MockRepository.GenerateStub <IRepositoryResolver>();
            repositoryResolver.Stub(r => r.GetRepository(typeof(Parent))).Return(parentRepository);
            repositoryResolver.Stub(r => r.GetRepository(typeof(Child))).Return(childRepository);

            entityModelBinder = new EntityModelBinder(repositoryResolver);
            controllerContext = new ControllerContext
            {
                HttpContext = MockRepository.GenerateStub <HttpContextBase>()
            };
            request = MockRepository.GenerateStub <HttpRequestBase>();
            controllerContext.HttpContext.Stub(x => x.Request).Return(request);

            entityModelBinder.SetModelBinderDictionary(new ModelBinderDictionary {
                DefaultBinder = entityModelBinder
            });
        }
コード例 #11
0
        public override void Calc(IRepositoryResolver repositories)
        {
            var fileIDs = repositories.SelectionDSL()
                .Files().InDirectory(TargetDir).Exist()
                .Select(f => f.ID).ToList();

            List<double> xlist = new List<double>(fileIDs.Count);
            List<double> ylist = new List<double>(fileIDs.Count);

            foreach (var fileID in fileIDs)
            {
                var code = repositories.SelectionDSL()
                    .Files().IdIs(fileID)
                    .Modifications().InFiles()
                    .CodeBlocks().InModifications()
                    .Fixed();

                var dd = code.CalculateTraditionalDefectDensity();
                if (dd > 0)
                {
                    xlist.Add(code.CalculateLOC());
                    ylist.Add(dd);
                }
            }

            x = xlist.ToArray();
            y = ylist.ToArray();
        }
コード例 #12
0
        public override void Calc(IRepositoryResolver repositories)
        {
            base.Calc(repositories);

            x = new double[dates.Count()];
            y = new double[dates.Count()];

            double codeSize = 0;
            for (int i = 0; i < dates.Length; i++)
            {
                x[i] = (dates[i] - dates[0]).TotalDays;
                codeSize += repositories.SelectionDSL()
                    .Commits()
                        .Reselect(e => i > 0 ? e.DateIsGreaterThan(dates[i-1]) : e)
                        .DateIsLesserOrEquelThan(dates[i])
                    .Files()
                        .InDirectory(TargetDir)
                    .Modifications()
                        .InCommits()
                        .InFiles()
                    .CodeBlocks()
                        .InModifications()
                        .CalculateLOC();
                y[i] = codeSize;
            }
        }
コード例 #13
0
        public override void Calc(IRepositoryResolver repositories)
        {
            base.Calc(repositories);

            x = new double[dates.Count()-1];
            yByAuthor = new Dictionary<string,double[]>();
            for (int i = 0; i < Authors.Length; i++)
            {
                yByAuthor.Add(Authors[i], new double[dates.Count()-1]);
            }

            for (int i = 0; i < Authors.Length; i++)
            {
                y = yByAuthor[Authors[i]];
                DateTime prev = dates[0];
                int counter = 0;

                for (int j = 1; j < dates.Length; j++)
                {
                    if (i == 0)
                    {
                        x[counter] = (dates[j] - dates[0]).TotalDays;
                    }
                    y[counter] = repositories.SelectionDSL().Commits()
                        .DateIsGreaterOrEquelThan(prev)
                        .DateIsLesserThan(dates[j])
                        .AuthorIs(Authors[i])
                        .Count();

                    prev = dates[j];
                    counter++;
                }
            }
        }
コード例 #14
0
        public override void Calc(IRepositoryResolver repositories)
        {
            base.Calc(repositories);

            x = new double[dates.Count()];
            tdd = new double[dates.Count()];
            dd = new double[dates.Count()];
            string revision = null;

            for (int i = 0; i < dates.Length; i++)
            {
                x[i] = (dates[i] - dates[0]).TotalDays;
                var code = repositories.SelectionDSL()
                    .Commits()
                        .DateIsLesserOrEquelThan(dates[i])
                        .Do(c =>
                            revision = repositories.Repository<Commit>().Single(cc =>
                                cc.OrderedNumber == c.Max(ccc => ccc.OrderedNumber)
                            ).Revision
                        )
                    .Files()
                        .InDirectory(TargetDir)
                    .Modifications()
                        .InCommits()
                        .InFiles()
                    .CodeBlocks()
                        .InModifications();

                tdd[i] = code.CalculateTraditionalDefectDensity(revision);
                dd[i] = code.CalculateDefectDensity(revision);
            }
        }
コード例 #15
0
		public ProductBinder(IValidatingBinder validatingBinder, IRepositoryResolver resolver, IRepository<Product> repository, IHttpFileService httpFileService, IOrderableService<ProductImage> orderableService, ISizeService sizeService)
			: base(validatingBinder, resolver)
		{
			this.repository = repository;
			this.httpFileService = httpFileService;
			this.orderableService = orderableService;
			this.sizeService = sizeService;
		}
コード例 #16
0
 public ProxyableService(DaoRepository repository, AppConf appConf, IRepositoryResolver repositoryResolver = null)
 {
     AppConf            = appConf;
     DaoRepository      = repository;
     Repository         = repository;
     Logger             = appConf?.Logger ?? Log.Default;
     RepositoryResolver = repositoryResolver ?? new DefaultRepositoryResolver(repository);
     DiagnosticName     = GetType().Name;
 }
コード例 #17
0
 public DeleteEntityDispatcher(
     IAuthService authService,
     IRepositoryResolver repositoryResolver,
     IParentService parentService)
 {
     _authService        = authService;
     _repositoryResolver = repositoryResolver;
     _parentService      = parentService;
 }
コード例 #18
0
 public ReorderEntityDispatcher(
     IRepositoryResolver repositoryResolver,
     IParentService parentService,
     IAuthService authService)
 {
     _repositoryResolver = repositoryResolver;
     _parentService      = parentService;
     _authService        = authService;
 }
コード例 #19
0
 public HomeController(
     ISettingsProvider settingsProvider,
     IRepositoryResolver repoResolver
     )
 {
     _repoResolver = repoResolver;
     _configurationProvider = settingsProvider;
     _settings = _configurationProvider.Load();
 }
コード例 #20
0
 public RepositoryController(
     ISettingsProvider settingsProvider,
     IRepositoryResolver repoResolver,
     IHighlightingService hightlightingService)
 {
     _hightlightingService = hightlightingService;
     _repoResolver = repoResolver;
     _configurationProvider = settingsProvider;
     _settings = _configurationProvider.Load();
 }
コード例 #21
0
 public GetEntityDispatcher(
     ISetupResolver <IEntityVariantSetup> entityVariantResolver,
     IRepositoryResolver repositoryResolver,
     IParentService parentService,
     IAuthService authService)
 {
     _entityVariantResolver = entityVariantResolver;
     _repositoryResolver    = repositoryResolver;
     _parentService         = parentService;
     _authService           = authService;
 }
コード例 #22
0
 public GetEntitiesDispatcher(
     IRepositoryResolver repositoryResolver,
     IDataViewResolver dataViewResolver,
     IParentService parentService,
     IAuthService authService)
 {
     _repositoryResolver = repositoryResolver;
     _dataViewResolver   = dataViewResolver;
     _parentService      = parentService;
     _authService        = authService;
 }
コード例 #23
0
 public PersistEntityDispatcher(
     IAuthService authService,
     IRepositoryResolver repositoryResolver,
     IParentService parentService,
     IEditContextFactory editContextFactory)
 {
     _authService        = authService;
     _repositoryResolver = repositoryResolver;
     _parentService      = parentService;
     _editContextFactory = editContextFactory;
 }
コード例 #24
0
 public DataProviderResolver(
     ISetupResolver <ICollectionSetup> collectionSetupResolver,
     IRepositoryResolver repositoryResolver,
     IMediator mediator,
     IServiceProvider serviceProvider)
 {
     _collectionSetupResolver = collectionSetupResolver;
     _repositoryResolver      = repositoryResolver;
     _mediator        = mediator;
     _serviceProvider = serviceProvider;
 }
コード例 #25
0
 public DataProviderResolver(
     ISetupResolver <ICollectionSetup> collectionSetupResolver,
     IRepositoryResolver repositoryResolver,
     IMemoryCache memoryCache,
     IServiceProvider serviceProvider)
 {
     _collectionSetupResolver = collectionSetupResolver;
     _repositoryResolver      = repositoryResolver;
     _memoryCache             = memoryCache;
     _serviceProvider         = serviceProvider;
 }
コード例 #26
0
 public EntityInteractionDispatcher(
     ICollectionResolver collectionResolver,
     IRepositoryResolver repositoryResolver,
     IConcurrencyService concurrencyService,
     IButtonInteraction buttonInteraction)
 {
     _collectionResolver = collectionResolver;
     _repositoryResolver = repositoryResolver;
     _concurrencyService = concurrencyService;
     _buttonInteraction  = buttonInteraction;
 }
コード例 #27
0
 public EntitiesInteractionDispatcher(
     ISetupResolver <ICollectionSetup> collectionResolver,
     IRepositoryResolver repositoryResolver,
     IConcurrencyService concurrencyService,
     IButtonInteraction buttonInteraction,
     IEditContextFactory editContextFactory)
 {
     _collectionResolver = collectionResolver;
     _repositoryResolver = repositoryResolver;
     _concurrencyService = concurrencyService;
     _buttonInteraction  = buttonInteraction;
     _editContextFactory = editContextFactory;
 }
コード例 #28
0
ファイル: TreeService.cs プロジェクト: mg02l/RapidCMS
 public TreeService(
     ICollectionResolver collectionResolver,
     ICms cms,
     IRepositoryResolver repositoryResolver,
     IAuthService authService,
     IParentService parentService)
 {
     _collectionResolver = collectionResolver;
     _cms = cms;
     _repositoryResolver = repositoryResolver;
     _authService        = authService;
     _parentService      = parentService;
 }
コード例 #29
0
ファイル: Prediction.cs プロジェクト: BMichael998/msr-tools
 public virtual void Init(IRepositoryResolver repositories, IEnumerable<string> releases)
 {
     this.repositories = repositories;
     PredictionRelease = releases.Last();
     if (releases.Count() > 1)
     {
         TrainReleases = releases.Take(releases.Count() - 1);
     }
     else
     {
         TrainReleases = releases;
     }
     context = new PredictorContext(repositories);
 }
コード例 #30
0
 public GetPageDispatcher(
     ISetupResolver <CollectionSetup> collectionResolver,
     IRepositoryResolver repositoryResolver,
     IAuthService authService,
     ILogin loginRegistration,
     ISetupResolver <PageSetup> pageResolver,
     INavigationStateProvider navigationStateProvider)
 {
     _collectionResolver      = collectionResolver;
     _repositoryResolver      = repositoryResolver;
     _authService             = authService;
     _loginRegistration       = loginRegistration;
     _pageResolver            = pageResolver;
     _navigationStateProvider = navigationStateProvider;
 }
コード例 #31
0
 public GetEntityDispatcher(
     ISetupResolver <ICollectionSetup> collectionResolver,
     IRepositoryResolver repositoryResolver,
     IParentService parentService,
     IConcurrencyService concurrencyService,
     IAuthService authService,
     IServiceProvider serviceProvider)
 {
     _collectionResolver = collectionResolver;
     _repositoryResolver = repositoryResolver;
     _parentService      = parentService;
     _concurrencyService = concurrencyService;
     _authService        = authService;
     _serviceProvider    = serviceProvider;
 }
コード例 #32
0
 public EntitiesInteractionDispatcher(
     INavigationStateProvider navigationStateProvider,
     ISetupResolver <CollectionSetup> collectionResolver,
     IRepositoryResolver repositoryResolver,
     IConcurrencyService concurrencyService,
     IButtonInteraction buttonInteraction,
     IEditContextFactory editContextFactory,
     IMediator mediator)
 {
     _navigationStateProvider = navigationStateProvider;
     _collectionResolver      = collectionResolver;
     _repositoryResolver      = repositoryResolver;
     _concurrencyService      = concurrencyService;
     _buttonInteraction       = buttonInteraction;
     _editContextFactory      = editContextFactory;
     _mediator = mediator;
 }
コード例 #33
0
ファイル: TreeService.cs プロジェクト: michaelcoxon/RapidCMS
 public TreeService(
     ISetupResolver <ICollectionSetup> collectionResolver,
     ISetupResolver <IPageSetup> pageResolver,
     ISetupResolver <IEnumerable <ITreeElementSetup> > treeElementResolver,
     ICms cms,
     IRepositoryResolver repositoryResolver,
     IAuthService authService,
     IParentService parentService)
 {
     _collectionResolver  = collectionResolver;
     _pageResolver        = pageResolver;
     _treeElementResolver = treeElementResolver;
     _cms = cms;
     _repositoryResolver = repositoryResolver;
     _authService        = authService;
     _parentService      = parentService;
 }
コード例 #34
0
 public GetEntitiesDispatcher(
     ICollectionResolver collectionResolver,
     IRepositoryResolver repositoryResolver,
     IDataViewResolver dataViewResolver,
     IParentService parentService,
     IConcurrencyService concurrencyService,
     IAuthService authService,
     IServiceProvider serviceProvider)
 {
     _collectionResolver = collectionResolver;
     _repositoryResolver = repositoryResolver;
     _dataViewResolver   = dataViewResolver;
     _parentService      = parentService;
     _concurrencyService = concurrencyService;
     _authService        = authService;
     _serviceProvider    = serviceProvider;
 }
コード例 #35
0
        protected override double[] DistributionData(IRepositoryResolver repositories)
        {
            var commits = repositories.SelectionDSL()
                .Commits()
                .Select(x => x.Revision).ToArray();

            List<double> data = new List<double>(commits.Count());

            foreach (var commit in commits)
            {
                data.Add(repositories.SelectionDSL()
                    .Commits().RevisionIs(commit)
                    .Modifications().InCommits()
                    .CodeBlocks().InModifications().Added().CalculateLOC()
                );
            }

            return data.ToArray();
        }
コード例 #36
0
 public TreeService(
     ISetupResolver <CollectionSetup> collectionResolver,
     ISetupResolver <PageSetup> pageResolver,
     ISetupResolver <IEnumerable <TreeElementSetup> > treeElementResolver,
     ICms cms,
     IRepositoryResolver repositoryResolver,
     IAuthService authService,
     IParentService parentService,
     IConcurrencyService concurrencyService,
     IHttpContextAccessor httpContextAccessor)
 {
     _collectionResolver  = collectionResolver;
     _pageResolver        = pageResolver;
     _treeElementResolver = treeElementResolver;
     _cms = cms;
     _repositoryResolver  = repositoryResolver;
     _authService         = authService;
     _parentService       = parentService;
     _concurrencyService  = concurrencyService;
     _httpContextAccessor = httpContextAccessor;
 }
コード例 #37
0
        protected override double[] DistributionData(IRepositoryResolver repositories)
        {
            var fileIDs = repositories.SelectionDSL()
                .Files()
                    .InDirectory(TargetDir)
                    .Exist()
                .Select(x => x.ID).ToArray();

            List<double> data = new List<double>(fileIDs.Count());

            foreach (var fileID in fileIDs)
            {
                data.Add(repositories.SelectionDSL()
                    .Files().IdIs(fileID)
                    .Modifications().InFiles()
                    .CodeBlocks().InModifications().CalculateDefectDensity()
                );
            }

            return data.ToArray();
        }
コード例 #38
0
        public override void Calc(IRepositoryResolver repositories)
        {
            var revisions = repositories.SelectionDSL()
                .Commits()
                .Select(c => c.Revision)
                .ToList();

            List<double> xlist = new List<double>(revisions.Count);
            List<double> ylist = new List<double>(revisions.Count);

            foreach (var revision in revisions)
            {
                var code = repositories.SelectionDSL()
                    .Commits().RevisionIs(revision)
                    .Files().InDirectory(TargetDir)
                    .Modifications().InCommits().InFiles()
                    .CodeBlocks().InModifications()
                    .Fixed();

                var addedLoc = code.Added().CalculateLOC();
                if (addedLoc == 0)
                {
                    continue;
                }
                var dd = code.CalculateTraditionalDefectDensity();
                if (dd == 0)
                {
                    continue;
                }
                xlist.Add(addedLoc);
                ylist.Add(dd);
            }

            x = xlist.ToArray();
            y = ylist.ToArray();
        }
 public abstract void Init(IRepositoryResolver repositories);
コード例 #40
0
ファイル: UserController.cs プロジェクト: catalin209/MAGI
 public UserController(IRepositoryResolver resolver)
 {
     _repoResolver = resolver;
 }
コード例 #41
0
        protected DateTime[] GetDates(IRepositoryResolver repositories)
        {
            List<DateTime> dates = new List<DateTime>();

            DateTime min = repositories.Repository<Commit>().Min(c => c.Date);
            DateTime max = repositories.Repository<Commit>().Max(c => c.Date);

            DateTime date = min;
            switch (DatePeriod)
            {
                case DatePeriod.DAY: date = date.StartOfDay(); break;
                case DatePeriod.WEEK: date = date.StartOfWeek(); break;
                case DatePeriod.MONTH: date = date.StartOfMonth(); break;
                case DatePeriod.QUARTER: date = date.StartOfQuarter(); break;
                case DatePeriod.YEAR: date = date.StartOfYear(); break;
                default: break;
            }

            DateTime prevDate = date;
            while (prevDate < max)
            {
                dates.Add(date);
                prevDate = date;
                switch (DatePeriod)
                {
                    case DatePeriod.DAY: date = date.AddDays(1); break;
                    case DatePeriod.WEEK: date = date.AddWeeks(1); break;
                    case DatePeriod.MONTH: date = date.AddMonths(1); break;
                    case DatePeriod.QUARTER: date = date.AddQuarters(1); break;
                    case DatePeriod.YEAR: date = date.AddYears(1); break;
                    default: break;
                }
            }

            if (dates.Count > 0 && dates.First() < min)
            {
                dates[0] = min;
            }
            if (dates.Count > 1 && dates.Last() > max)
            {
                dates[dates.Count-1] = max;
            }

            return dates.ToArray();
        }
 public override void Init(IRepositoryResolver repositories)
 {
 }
コード例 #43
0
 public ProductController(IRepositoryResolver resolver)
 {
     _repoResolver = resolver;
 }
コード例 #44
0
 public abstract void Calc(IRepositoryResolver repositories);
コード例 #45
0
 public InMemorySession(IRepositoryResolver repositories)
 {
     this.repositories = repositories;
 }
コード例 #46
0
 public CountryController(IRepositoryResolver resolver)
 {
     _repoResolver = resolver;
 }
        protected override BugFixSelectionExpression BugFixes(IRepositoryResolver repositories)
        {
            double stabilizationPeriod = repositories.SelectionDSL()
                .Commits().TillRevision(model.PredictionRelease)
                .BugFixes().InCommits().CalculateStabilizationPeriod(0.9);

            var stableCommits = repositories.SelectionDSL()
                .Commits().DateIsLesserOrEquelThan(model.ReleaseDate.AddDays(-stabilizationPeriod));

            return stableCommits.BugFixes().InCommits();
        }
コード例 #48
0
        public override IDictionary<string, object> BuildData(IRepositoryResolver repositories)
        {
            Dictionary<string,object> result = new Dictionary<string,object>();

            int commits = repositories.Repository<Commit>().Count();
            var authors = repositories.Repository<Commit>()
                .Select(x => x.Author)
                .Distinct().ToList();
            double totalLoc = repositories.SelectionDSL()
                .Files().InDirectory(TargetDir)
                .Modifications().InFiles()
                .CodeBlocks().InModifications().CalculateLOC();
            int totalFiles = repositories.SelectionDSL()
                .Files().InDirectory(TargetDir).Exist()
                .Count();

            var codeByAuthor = (from author in authors select new
            {
                Name = author,
                AddedCode = repositories.SelectionDSL()
                    .Commits().AuthorIs(author)
                    .Files().InDirectory(TargetDir)
                    .Modifications().InFiles()
                    .CodeBlocks().InModifications().AddedInitiallyInCommits()
                    .Fixed(),
                RemovedCode = repositories.SelectionDSL()
                    .Commits().AuthorIs(author)
                    .Files().InDirectory(TargetDir)
                    .Modifications().InCommits().InFiles()
                    .CodeBlocks().InModifications().Deleted()
                    .Fixed(),
                TouchedFiles = repositories.SelectionDSL()
                    .Commits().AuthorIs(author)
                    .Files().InDirectory(TargetDir).Exist().TouchedInCommits()
            }).ToList();

            var statByAuthor =
                from a in codeByAuthor
                let authorCommits = a.AddedCode.Commits().Again().Count()
                let authorFixes = a.AddedCode.Commits().Again().AreBugFixes().Count()
                let authorRefactorings = a.AddedCode.Commits().Again().AreRefactorings().Count()
                let authorAddedLoc = a.AddedCode.CalculateLOC()
                let authorCurrentLoc = authorAddedLoc + a.AddedCode.ModifiedBy().CalculateLOC()
                let authorTouchedFiles = a.TouchedFiles.Count()
                let authorFilesTouchedByOtherAuthors = a.TouchedFiles
                    .Commits().AuthorIsNot(a.Name)
                    .Files().Again().TouchedInCommits().Count()
                select new
                {
                    name = a.Name,
                    commits = string.Format("{0} ({1}%)", authorCommits, (((double)authorCommits / commits) * 100).ToString("F02")),
                    fixes = string.Format("{0} ({1}%)", authorFixes, (((double)authorFixes / authorCommits) * 100).ToString("F02")),
                    refactorings = string.Format("{0} ({1}%)", authorRefactorings, (((double)authorRefactorings / authorCommits) * 100).ToString("F02")),
                    dd = a.AddedCode.CalculateDefectDensity().ToString("F03"),
                    added_loc = a.AddedCode.CalculateLOC(),
                    removed_loc = - a.RemovedCode.CalculateLOC(),
                    remain_loc = authorCurrentLoc,
                    contribution = ((authorCurrentLoc / totalLoc) * 100).ToString("F02") + "%",
                    specialization = ((double)authorTouchedFiles / totalFiles * 100).ToString("F02") + "%",
                    unique_specialization = (authorTouchedFiles > 0 ?
                        ((double)(authorTouchedFiles - authorFilesTouchedByOtherAuthors) / totalFiles * 100)
                        :
                        0).ToString("F02") + "%",
                    demand_for_code = (authorAddedLoc > 0 ?
                        ((authorCurrentLoc / authorAddedLoc) * 100)
                        :
                        0).ToString("F02") + "%"
                };

            result.Add("authors", statByAuthor.OrderBy(x => x.name).ToArray());

            return result;
        }
 public override void Init(IRepositoryResolver repositories)
 {
     this.repositories = repositories;
 }
コード例 #50
0
        public override IDictionary<string, object> BuildData(IRepositoryResolver repositories)
        {
            Dictionary<string,object> result = new Dictionary<string,object>();

            int commits_count = repositories.Repository<Commit>().Count();
            int commits_fix_count = repositories.SelectionDSL().Commits().AreBugFixes().Count();
            string commits_fix_percent = ((double)commits_fix_count / commits_count * 100).ToString("F02");
            int commits_refactoring_count = repositories.SelectionDSL().Commits().AreRefactorings().Count();
            string commits_refactoring_percent = ((double)commits_refactoring_count / commits_count * 100).ToString("F02");

            DateTime statfrom = repositories.Repository<Commit>().Min(x => x.Date);
            DateTime statto = repositories.Repository<Commit>().Max(x => x.Date);

            result.Add("stat_date", DateTime.Now.ToString());
            result.Add("stat_period_from", statfrom);
            result.Add("stat_period_to", statto);
            result.Add("stat_period_days", (statto - statfrom).Days);
            result.Add("stat_period_years", ((statto - statfrom).TotalDays / 365).ToString("F01"));
            result.Add("authors_count",
                repositories.Repository<Commit>().Select(x => x.Author).Distinct().Count()
            );
            result.Add("commits_count", commits_count);
            result.Add("commits_fix_count", commits_fix_count);
            result.Add("commits_fix_percent", commits_fix_percent);
            result.Add("commits_refactoring_count", commits_refactoring_count);
            result.Add("commits_refactoring_percent", commits_refactoring_percent);
            var files = repositories.SelectionDSL()
                .Files().InDirectory(TargetDir)
                .Fixed();
            result.Add("files_current",
                files.Exist().Count()
            );
            result.Add("files_added",
                files.Count()
            );
            result.Add("files_removed",
                files.Deleted().Count()
            );
            var code = repositories.SelectionDSL()
                .Files().InDirectory(TargetDir)
                .Modifications().InFiles()
                .CodeBlocks().InModifications()
                .Fixed();
            result.Add("loc_current",
                code.CalculateLOC()
            );
            result.Add("loc_added",
                code.Added().CalculateLOC()
            );
            result.Add("loc_removed",
                - code.Deleted().CalculateLOC()
            );
            result.Add("tdd",
                code.CalculateTraditionalDefectDensity().ToString("F03")
            );
            result.Add("dd",
                code.CalculateDefectDensity().ToString("F03")
            );

            return result;
        }
        public override void Init(IRepositoryResolver repositories)
        {
            authorByRevision = repositories.SelectionDSL()
                .Commits().TillRevision(model.PredictionRelease)
                .ToDictionary(x => x.Revision, x => x.Author);

            int releaseRevisionOrderedNumber = repositories.Repository<Commit>()
                .Single(x => x.Revision == model.PredictionRelease).OrderedNumber;
            var codeByAuthorAndFile =
                (
                    from cb in repositories.Repository<CodeBlock>()
                    join m in repositories.Repository<Modification>() on cb.ModificationID equals m.ID
                    join c in repositories.Repository<Commit>() on m.CommitID equals c.ID
                    join f in repositories.Repository<ProjectFile>() on m.FileID equals f.ID
                    where
                        cb.Size > 0
                        &&
                        c.OrderedNumber <= releaseRevisionOrderedNumber
                    group cb by new { Author = c.Author, FileID = f.ID } into g
                    select new
                    {
                        Author = g.Key.Author,
                        FileID = g.Key.FileID,
                        CodeSize = g.Sum(x => x.Size)
                    }
                ).ToArray();

            var allFiles = model.AllFiles.Select(x => x.ID).ToArray();
            var allAuthors = repositories.SelectionDSL()
                .Commits().TillRevision(model.PredictionRelease)
                .Select(x => x.Author).Distinct().ToArray();

            int numberOfFiles = allFiles.Count();
            int numberOfAuthors = allAuthors.Count();
            int numberOfEquations = numberOfFiles + numberOfAuthors + 1;
            double[,] equations = new double[numberOfEquations,numberOfEquations];
            double[] results = new double[numberOfEquations];

            int equation = 0;
            double locAdded = codeByAuthorAndFile.Sum(x => x.CodeSize);

            for (int i = 0; i < allFiles.Length; i++)
            {
                double locAddedInFile = codeByAuthorAndFile
                    .Where(x => x.FileID == allFiles[i])
                    .Sum(x => x.CodeSize);
                equations[numberOfEquations-1, i] = locAddedInFile / locAdded;
                equations[equation, i] = 1;

                if (locAddedInFile > 0)
                {
                    double dcd = repositories.SelectionDSL()
                        .Commits()
                            .TillRevision(model.PredictionRelease)
                        .Files()
                            .IdIs(allFiles[i])
                        .Modifications().InCommits().InFiles()
                        .CodeBlocks().InModifications().CalculateDefectCodeDensity(model.PredictionRelease);

                    for (int j = 0; j < allAuthors.Length; j++)
                    {
                        double locAddedInFileByAuthor = codeByAuthorAndFile
                            .Where(x => x.FileID == allFiles[i] && x.Author == allAuthors[j])
                            .Sum(x => x.CodeSize);
                        equations[equation, numberOfFiles + j] = (locAddedInFileByAuthor / locAddedInFile);
                    }
                    results[equation] = dcd;
                }
                equation++;
            }

            for (int i = 0; i < allAuthors.Length; i++)
            {
                double locAddedByAuthor = codeByAuthorAndFile
                    .Where(x => x.Author == allAuthors[i])
                    .Sum(x => x.CodeSize);
                equations[numberOfEquations-1, numberOfFiles + i] = locAddedByAuthor / locAdded;
                equations[equation, numberOfFiles + i] = 1;

                if (locAddedByAuthor > 0)
                {
                    double dcd = repositories.SelectionDSL()
                        .Commits()
                            .AuthorIs(allAuthors[i])
                            .TillRevision(model.PredictionRelease)
                        .Modifications().InCommits()
                        .CodeBlocks().InModifications().CalculateDefectCodeDensity(model.PredictionRelease);
                    for (int j = 0; j < allFiles.Length; j++)
                    {
                        double locAddedByAuthorInFile = codeByAuthorAndFile
                            .Where(x => x.Author == allAuthors[i] && x.FileID == allFiles[j])
                            .Sum(x => x.CodeSize);
                        equations[equation, j] = (locAddedByAuthorInFile / locAddedByAuthor);
                    }
                    results[equation] = dcd;
                }
                equation++;
            }

            results[numberOfEquations-1] = repositories.SelectionDSL()
                .Commits()
                    .TillRevision(model.PredictionRelease)
                .Modifications().InCommits()
                .CodeBlocks().InModifications().CalculateDefectCodeDensity(model.PredictionRelease);

            int varCount = equations.GetUpperBound(1)+1;
            double[,] normalEquations = new double[varCount, varCount];
            double[] normalResults = new double[varCount];
            Func<double[,],double[],int,int,double> nc = (e, r, n1, n2) =>
            {
                double sum = 0;
                for (int i = 0; i < numberOfEquations; i++)
                {
                    if (n2 < numberOfEquations)
                    {
                        sum += e[i,n1] * e[i,n2];
                    }
                    else
                    {
                        sum += e[i,n1] * r[i];
                    }
                }
                return sum;
            };

            for (int i = 0; i < varCount; i++)
            {
                for (int j = 0; j < varCount; j++)
                {
                    normalEquations[i,j] = nc(equations,results,i,j);
                }
                normalResults[i] = nc(equations,results,i,numberOfEquations);
            }
            var DCD = new Accord.Math.Decompositions.SingularValueDecomposition(normalEquations).Solve(normalResults);

            DCDF = new Dictionary<int,double>();
            DCDA = new Dictionary<string,double>();
            double DCD_min = 0.001;
            for (int i = 0; i < allFiles.Length; i++)
            {
                DCDF.Add(allFiles[i], DCD[i] > 0 ? DCD[i] : DCD_min);
            }
            for (int i = 0; i < allAuthors.Length; i++)
            {
                DCDA.Add(allAuthors[i], DCD[numberOfFiles + i] > 0 ? DCD[numberOfFiles + i] : DCD_min);
            }
        }
コード例 #52
0
ファイル: CatalogController.cs プロジェクト: catalin209/MAGI
 public CatalogController(IRepositoryResolver resolver)
 {
     _repoResolver = resolver;
 }
コード例 #53
0
 public EntityModelBinder(IRepositoryResolver repositoryResolver)
 {
     this.repositoryResolver = repositoryResolver;
 }
 public virtual void Init(IRepositoryResolver repositories)
 {
 }
コード例 #55
0
 public virtual void Init(IRepositoryResolver repositories)
 {
     Initialized = true;
 }
コード例 #56
0
 public override void Calc(IRepositoryResolver repositories)
 {
 }
コード例 #57
0
ファイル: UnitOfWork.cs プロジェクト: 5Gears0Chill/paladins
 public UnitOfWork(IRepositoryResolver repositoryResolver)
 {
     _repositoryResolver = repositoryResolver;
 }
コード例 #58
0
 public override void Calc(IRepositoryResolver repositories)
 {
     dates = GetDates(repositories);
 }
コード例 #59
0
 public BiscuitFacade(IRepositoryResolver repositoryResolver)
 {
     _repositoryResolver = repositoryResolver;
 }
        public override void Init(IRepositoryResolver repositories)
        {
            authorByRevision = repositories.SelectionDSL()
                .Commits().TillRevision(model.PredictionRelease)
                .ToDictionary(x => x.Revision, x => x.Author);

            defectLineProbabilityOfAuthor = new SmartDictionary<string,double>(a =>
                repositories.SelectionDSL()
                    .Commits().AuthorIs(a).BeforeRevision(model.PredictionRelease)
                    .Modifications().InCommits()
                    .CodeBlocks().InModifications().CalculateDefectCodeDensity(model.PredictionRelease)
            );
        }