/// <summary>
        /// The get projects with matching duplications.
        /// </summary>
        /// <param name="project">
        /// The project.
        /// </param>
        /// <returns>
        /// The <see cref="List"/>.
        /// </returns>
        private List<SonarProject> GetProjectsWithMatchingDuplications(SonarProject project)
        {
            var crossProjectData = new List<SonarProject>();

            foreach (var dup in this.DuplicatedData)
            {
                foreach (var group in dup.DuplicatedGroups)
                {
                    foreach (var block in group.DuplicatedBlocks)
                    {
                        if (project.IsFileFoundInFiles(block.Resource.Key) == null)
                        {
                            foreach (var projectResource in this.ProjectResources)
                            {
                                if (projectResource.IsFileFoundInFiles(block.Resource.Key) != null)
                                {
                                    bool found = false;
                                    foreach (var crossproject in crossProjectData)
                                    {
                                        if (crossproject.Project.Key.Equals(projectResource.Project.Key))
                                        {
                                            found = true;
                                        }
                                    }

                                    if (!found)
                                    {
                                        crossProjectData.Add(projectResource);
                                    }
                                }
                            }
                        }

                    }
                }
            }

            return crossProjectData;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The get duplicated blocks.
        /// </summary>
        /// <param name="secondProject">
        /// The second project.
        /// </param>
        /// <returns>
        /// The <see cref="List"/>.
        /// </returns>
        public List<DuplicationData> GetDuplicatedBlocks(SonarProject secondProject)
        {
            var newData = new List<DuplicationData>();

            foreach (var otherData in this.GetDuplicatedData())
            {
                var isFound = false;

                foreach (var group in otherData.DuplicatedGroups)
                {
                    foreach (var block in group.DuplicatedBlocks)
                    {
                        if (this.IsFileFoundInFiles(block.Resource.Key) != null)
                        {
                            continue;
                        }

                        if (secondProject.IsFileFoundInFiles(block.Resource.Key) != null)
                        {
                            isFound = true;
                        }
                    }
                }

                if (isFound)
                {
                    newData.Add(otherData);
                }
            }

            return newData;
        }