/// <summary>
        /// The convert violations to local.
        /// </summary>
        /// <param name="issueList">
        /// The issue list.
        /// </param>
        /// <param name="diffReport">
        /// The diff report.
        /// </param>
        /// <param name="currentResource">
        /// The current Resource.
        /// </param>
        /// <returns>
        /// The <see>
        ///         <cref>ObservableCollection</cref>
        ///     </see>
        ///     .
        /// </returns>
        public static List<Issue> ConvertOpenIssuesToLocalSource(List<Issue> issueList, ArrayList diffReport, Resource currentResource)
        {
            var local = new List<Issue>();

            if (issueList != null && issueList.Count > 0)
            {
                foreach (var issue in issueList)
                {
                    if (!issue.Component.EndsWith(currentResource.Lname))
                    {
                        continue;
                    }

                    if (issue.Status != IssueStatus.OPEN && issue.Status != IssueStatus.REOPENED && issue.Status != IssueStatus.UNDEFINED)
                    {
                        continue;
                    }

                    var copyOfViolation = issue.DeepCopy();
                    var convertedKey = EstimateWhereSonarLineIsUsingSourceDifference(issue.Line, diffReport);

                    if (convertedKey < 0)
                    {
                        continue;
                    }

                    copyOfViolation.Line = convertedKey;
                    local.Add(copyOfViolation);
                }
            }

            return new List<Issue>(local.OrderBy(i => i.Line));
        }
        private void SaveAssociationToDisk(Resource project)
        {
            try
            {
                this.configurationHelper.WriteSetting(
                    new SonarQubeProperties
                    {
                        Owner = Path.Combine(this.OpenSolutionPath, this.OpenSolutionName),
                        Key = "PROJECTKEY",
                        Value = project.Key,
                        Context = Context.GlobalPropsId
                    });

                this.configurationHelper.WriteSetting(
                    new SonarQubeProperties
                    {
                        Owner = Path.Combine(this.OpenSolutionPath, this.OpenSolutionName),
                        Key = "PROJECTNAME",
                        Value = this.OpenSolutionName,
                        Context = Context.GlobalPropsId
                    });

                this.configurationHelper.WriteSetting(
                    new SonarQubeProperties
                    {
                        Owner = Path.Combine(this.OpenSolutionPath, this.OpenSolutionName),
                        Key = "PROJECTLOCATION",
                        Value = this.OpenSolutionPath,
                        Context = Context.GlobalPropsId
                    });
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
コード例 #3
0
        /// <summary>
        /// Gathers the notes form test track.
        /// </summary>
        /// <param name="issues">The issues.</param>
        /// <returns></returns>
        private string GatherNotesFormTestTrackInPlainText(IList<Issue> issues, Resource project)
        {
            this.NumberOfBlockers = 0;
            this.NumberOfCriticals = 0;
            this.NumberOfMajors = 0;
            this.TechnicalDebt = 0;

            StringBuilder notes = new StringBuilder();
            notes.AppendLine("Issues are pending resolution:");
            notes.AppendLine("");

            if (project != null)
            {
                notes.AppendLine("Project : " + project.SolutionName + " : Key : " + project.Key);
            }

            HashSet<string> plans = new HashSet<string>();

            foreach (var issue in issues)
            {
                var compElelms = issue.Component.Split(':');
                var data = "    [" + issue.Assignee + "] " + issue.Message + " : " + compElelms[compElelms.Length - 1] + " : " + issue.Line + " : ";
                notes.AppendLine("    " + data + " => " + this.userConf.Hostname.TrimEnd('/') + "/issues/search#issues=" + issue.Key);
                this.PopulateStatistics(issue);
            }

            if (plans.Count != 0)
            {
                notes.AppendLine("");
                notes.AppendLine("The above issues are contained in the following action plans:");
                int i = 1;
                foreach (var plan in plans)
                {
                    var url = this.userConf.Hostname.TrimEnd('/') + "/issues/search#actionPlans=" + plan;
                    notes.AppendLine("    " + i.ToString() + " : " + url);
                    i++;
                }
            }

            notes.AppendLine("");
            var summary = "Issues: " + issues.Count + " Blockers: " + this.NumberOfBlockers + " Critical: " + this.NumberOfCriticals + " Majors: " + this.NumberOfMajors + " Debt: " + this.TechnicalDebt + " mn";
            notes.AppendLine(summary);
            return notes.ToString();
        }
コード例 #4
0
 /// <summary>
 /// Gets the plugin control options.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="configuration">The configuration.</param>
 /// <returns></returns>
 public IPluginControlOption GetPluginControlOptions(Resource project, ISonarConfiguration configuration)
 {
     return null;
 }
コード例 #5
0
 /// <summary>
 /// Associates the project.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="configuration">The configuration.</param>
 public void AssociateProject(Resource project, ISonarConfiguration configuration, Dictionary<string, Profile> profiles, string vsVersion)
 {
     this.associatedProject = project;
     this.userConf = configuration;
     this.testTrackIntegration = new TestTrackConnector(configuration.Username, configuration.Password, true, new TtConnection());
 }
コード例 #6
0
        /// <summary>The vs file item.</summary>
        /// <param name="filename">The filename.</param>
        /// <param name="associatedProject">The associated project.</param>
        /// <param name="fileResource">The file resource.</param>
        /// <returns>The <see cref="VsFileItem"/>.</returns>
        public VsFileItem VsFileItem(string filename, Resource associatedProject, Resource fileResource)
        {
            try
            {
                if (string.IsNullOrEmpty(filename))
                {
                    return null;
                }

                string driveLetter = filename.Substring(0, 1);
                ProjectItem item = this.environment.Solution.FindProjectItem(filename);

                if (item == null)
                {
                    return null;
                }

                string documentName = Path.GetFileName(filename);
                string documentPath = driveLetter + this.GetProperFilePathCapitalization(filename).Substring(1);
                string projectName = item.ContainingProject.Name;
                string projectPath = driveLetter + this.GetProperFilePathCapitalization(item.ContainingProject.FullName).Substring(1);
                string solutionName = this.ActiveSolutionName();
                string solutionPath = driveLetter + this.ActiveSolutionPath().Substring(1);
                var itemToReturn = new VsFileItem
                {
                    FileName = documentName,
                    FilePath = documentPath,
                    SonarResource = fileResource,
                    Project =
                        new VsProjectItem
                        {
                            ProjectName = projectName,
                            ProjectFilePath = projectPath,
                            Solution =
                                new VsSolutionItem
                                {
                                    SolutionName = solutionName,
                                    SolutionPath = solutionPath,
                                    SonarProject = associatedProject
                                }
                        }
                };

                return itemToReturn;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return null;
            }
        }
コード例 #7
0
        /// <summary>
        /// The get coverage DataCache for resource.
        /// </summary>
        /// <param name="resource">
        /// The resource.
        /// </param>
        /// <param name="currentSource">
        /// The current source.
        /// </param>
        /// <returns>
        /// The <see>
        ///         <cref>Dictionary</cref>
        ///     </see>
        ///     .
        /// </returns>
        public Dictionary<int, CoverageElement> GetCoverageDataForResource(Resource resource, string currentSource)
        {
            var coverageLine = new Dictionary<int, CoverageElement>();

            if (!DataCache.ContainsKey(resource.Key))
            {
                return coverageLine;
            }

            EditorData element = DataCache[resource.Key];

            ArrayList diffReport = VsSonarUtils.GetSourceDiffFromStrings(element.ServerSource, currentSource, DiffEngineLevel.FastImperfect);

            foreach (var linecov in element.CoverageData)
            {
                int line = VsSonarUtils.EstimateWhereSonarLineIsUsingSourceDifference(linecov.Key, diffReport);

                if (line > 0 && !coverageLine.ContainsKey(line))
                {
                    coverageLine.Add(line, linecov.Value);
                }
            }

            return coverageLine;
        }
コード例 #8
0
 /// <summary>
 /// The get source for resource.
 /// </summary>
 /// <param name="resource">
 /// The resource.
 /// </param>
 /// <returns>
 /// The <see cref="string"/>.
 /// </returns>
 internal string GetSourceForResource(Resource resource)
 {
     return DataCache.ContainsKey(resource.Key) ? DataCache[resource.Key].ServerSource : string.Empty;
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EditorData"/> class.
 /// </summary>
 /// <param name="resource">
 /// The resource.
 /// </param>
 public EditorData(Resource resource)
 {
     this.CoverageData = new Dictionary<int, CoverageElement>();
     this.Issues = new List<Issue>();
     this.Resource = resource;
 }
 public VsProjectItem VsProjectItem(string projectFileName, Resource associatedProject)
 {
     throw new NotImplementedException();
 }
 public VsFileItem VsFileItem(string fullPath, string projectFullPath, Resource associatedProject, Resource fileResource)
 {
     throw new NotImplementedException();
 }
 /// <summary>The vs project item.</summary>
 /// <param name="filename">The filename.</param>
 /// <param name="associatedProject"></param>
 /// <param name="projectResource"></param>
 /// <returns>The <see cref="VsFileItem"/>.</returns>
 /// <exception cref="NotImplementedException"></exception>
 public VsFileItem VsFileItem(string filename, Resource associatedProject, Resource projectResource)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="provider">The provider.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(
     Resource project,
     string workingDir,
     ISourceControlProvider provider,
     Dictionary<string, Profile> profile,
     string visualStudioVersion)
 {
     // not needed
 }
コード例 #14
0
ファイル: GitPlugin.cs プロジェクト: jmecsoftware/SQGitPlugin
 /// <summary>
 /// Associates the project.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="configuration">The configuration.</param>
 public void AssociateProject(Resource project, ISonarConfiguration configuration, Dictionary<string, Profile> profile, string vsversion)
 {
     // not needed
 }
        private Resource SearchSolutionResourceInSonarProjects(Resource solResource, string branchName)
        {
            Resource associatedProjectInSonar = null;
            foreach (Resource availableProject in this.model.AvailableProjects)
            {
                if (availableProject.IsBranch && solResource.IsBranch)
                {
                    associatedProjectInSonar = GetProjectInBranchResources(availableProject, solResource, branchName);
                }
                else
                {
                    if (availableProject.Key.Equals(solResource.Key))
                    {
                        associatedProjectInSonar = availableProject;
                    }
                }

                if (associatedProjectInSonar != null)
                {
                    return associatedProjectInSonar;
                }
            }

            return null;
        }
コード例 #16
0
        /// <summary>
        /// The is DataCache updated.
        /// </summary>
        /// <param name="resource">
        /// The resource.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool IsDataUpdated(Resource resource)
        {
            if (!DataCache.ContainsKey(resource.Key) || resource.Date > DataCache[resource.Key].Resource.Date)
            {
                return false;
            }

            return true;
        }
コード例 #17
0
        /// <summary>
        /// The update coverage DataCache.
        /// </summary>
        /// <param name="resource">
        /// The resource.
        /// </param>
        /// <param name="coverageData">
        /// The coverage DataCache.
        /// </param>
        /// <param name="issues">
        /// The issues.
        /// </param>
        /// <param name="serverSource">
        /// The server source.
        /// </param>
        public void UpdateResourceData(Resource resource, SourceCoverage coverageData, List<Issue> issues, string serverSource)
        {
            if (!DataCache.ContainsKey(resource.Key))
            {
                DataCache.Add(resource.Key, new EditorData(resource));
            }

            EditorData elem = DataCache[resource.Key];
            elem.ServerSource = serverSource;
            this.UpdateCoverageData(elem, coverageData);
            this.UpdateIssuesData(elem, issues);
        }
        /// <summary>
        /// Reports the translation exception.
        /// </summary>
        /// <param name="issue">The issue.</param>
        /// <param name="translatedPath">The translated path.</param>
        /// <param name="ex">The ex.</param>
        public static void ReportTranslationException(Issue issue, string translatedPath, INotificationManager manager, ISonarRestService service, Resource associatedProject, Exception ex = null)
        {
            if (ex != null)
            {
                manager.ReportMessage(new Message() { Id = "OnInEditor", Data = ex.Message + " : " + issue.Component });
                manager.ReportException(ex);
            }

            manager.ReportMessage(new Message() { Id = "OnInEditor ", Data = "Was Not Able To Translate Path For Resource:  " + issue.Component });
            manager.ReportMessage(new Message() { Id = "OnInEditor ", Data = "Solution = " + associatedProject.SolutionRoot });
            manager.ReportMessage(new Message() { Id = "OnInEditor", Data = "Translated Path = " + translatedPath });

            try
            {
                service.GetResourcesData(AuthtenticationHelper.AuthToken, issue.Component);
            }
            catch (Exception exConnection)
            {
                manager.ReportMessage(new Message() { Id = "OnInEditor : Failed to get Data For Resource", Data = exConnection.Message + " : " + issue.Component });
                manager.ReportException(exConnection);
            }
        }
コード例 #19
0
        /// <summary>
        /// The update issues.
        /// </summary>
        /// <param name="issues">
        /// The issues.
        /// </param>
        internal void UpdateIssues(List<Issue> issues)
        {
            this.ClearData();

            if (issues == null)
            {
                return;
            }

            foreach (Issue issue in issues)
            {
                if (!DataCache.ContainsKey(issue.Component))
                {
                    var resource = new Resource();
                    resource.Key = issue.Component;
                    DataCache.Add(issue.Component, new EditorData(new Resource()));
                }

                EditorData elem = DataCache[issue.Component];
                elem.Issues.Add(issue);
            }
        }
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="providerIn">The provider in.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(
     Resource project,
     string workingDir,
     ISourceControlProvider providerIn,
     Dictionary<string, Profile> profile,
     string visualStudioVersion)
 {
     this.sourceWorkDir = workingDir;
     this.associatedProject = project;
 }
コード例 #21
0
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="provider">The provider.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(ISonarConfiguration config, Resource project, string workingDir, ISourceControlProvider provider, IIssueTrackerPlugin sourcePlugin)
 {
     // not needed
 }
 /// <summary>
 /// The end data association.
 /// </summary>
 public void OnSolutionClosed()
 {
     this.sourceWorkDir = string.Empty;
     this.associatedProject = null;
 }
コード例 #23
0
        /// <summary>The vs project item.</summary>
        /// <param name="filename">The filename.</param>
        /// <param name="associatedProject">The associated project.</param>
        /// <returns>The <see cref="VsProjectItem"/>.</returns>
        public VsProjectItem VsProjectItem(string filename, Resource associatedProject)
        {
            if (string.IsNullOrEmpty(filename))
            {
                return null;
            }

            string driveLetter = filename.Substring(0, 1);
            string projectName = Path.GetFileNameWithoutExtension(filename);
            string projectPath = driveLetter + this.GetProperFilePathCapitalization(filename).Substring(1);
            string solutionName = this.ActiveSolutionName();
            string solutionPath = driveLetter + this.ActiveSolutionPath().Substring(1);
            var itemToReturn =
                new VsProjectItem
                {
                    ProjectName = projectName,
                    ProjectFilePath = projectPath,
                    Solution =
                        new VsSolutionItem
                        {
                            SolutionName = solutionName,
                            SolutionPath = solutionPath,
                            SonarProject = associatedProject
                        }
                };

            return itemToReturn;
        }
コード例 #24
0
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="providerIn">The provider in.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(ISonarConfiguration config, Resource project, string workingDir, ISourceControlProvider providerIn, IIssueTrackerPlugin sourcePlugin)
 {
     this.sourceWorkDir = workingDir;
     this.sonarConfiguration = config;
     this.associatedProject = project;
 }
コード例 #25
0
 /// <summary>
 /// Associates the project.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="connector">The connector.</param>
 public void AssociateProject(Resource project, ISonarConfiguration configuration, IIssueManagementConnection connector, string vsVersion)
 {
     this.associatedProject = project;
     this.userConf = configuration;
     this.testTrackIntegration = new TestTrackConnector(configuration.Username, configuration.Password, true, connector);
 }
コード例 #26
0
 /// <summary>
 /// The end data association.
 /// </summary>
 public void EndDataAssociation()
 {
     this.sourceWorkDir = string.Empty;
     this.sonarConfiguration = null;
     this.associatedProject = null;
 }
コード例 #27
0
        /// <summary>
        /// Gathers the notes form test track.
        /// </summary>
        /// <param name="issues">The issues.</param>
        /// <returns></returns>
        private string GatherNotesFormTestTrack(IList<Issue> issues, Resource project, out string summaryOut)
        {
            this.NumberOfBlockers = 0;
            this.NumberOfCriticals = 0;
            this.NumberOfMajors = 0;
            this.TechnicalDebt = 0;

            StringBuilder notes = new StringBuilder();
            notes.AppendLine("<p align=\"left\"><span style=\" font-size:12pt; color:#3366ff;\">Issues are pending resolution</span></p>");
            notes.AppendLine("<hr />");
            if (project != null)
            {
                notes.AppendLine("<p> Project : " + project.SolutionName + " : Key : " + project.Key);
            }
            else
            {
                notes.AppendLine("<p> Project : Multiple Projects" );
            }

            notes.AppendLine("<hr />");

            HashSet<string> plans = new HashSet<string>();

            foreach (var issue in issues)
            {
                var compElelms = issue.Component.Split(':');
                var url = "    [" + issue.Assignee + "] " + issue.Message + " : " + compElelms[compElelms.Length - 1] + " : " + issue.Line + " : ";
                notes.AppendLine("<p>    " + url + "<a href=\"" + this.userConf.Hostname.TrimEnd('/') + "/issues/search#issues=" + issue.Key + "\">See in SonarQube</a></p>");
                this.PopulateStatistics(issue);
            }

            notes.AppendLine("<hr />");
            summaryOut = "Issues: " + issues.Count + " => Blockers: " + this.NumberOfBlockers + " Critical: " + this.NumberOfCriticals + " Majors: " + this.NumberOfMajors + " Debt: " + this.TechnicalDebt + " mn";
            var summary = "<p>Issues: " + issues.Count + " => Blockers: " + this.NumberOfBlockers + " Critical: " + this.NumberOfCriticals + " Majors: " + this.NumberOfMajors + " Debt: " + this.TechnicalDebt + " mn</p>";
            notes.AppendLine(summary);

            notes.AppendLine("<p><br /> </p>");

            return notes.ToString();
        }
コード例 #28
0
        /// <summary>
        /// The get issues for resource.
        /// </summary>
        /// <param name="resource">
        /// The resource.
        /// </param>
        /// <param name="currentSource">
        /// The current source.
        /// </param>
        /// <returns>
        /// The
        ///     <see>
        ///         <cref>List</cref>
        ///     </see>
        ///     .
        /// </returns>
        public List<Issue> GetIssuesForResource(Resource resource, string currentSource)
        {
            var issues = new List<Issue>();

            if (!DataCache.ContainsKey(resource.Key))
            {
                return issues;
            }

            EditorData element = DataCache[resource.Key];

            if (element.ServerSource == null)
            {
                return element.Issues;
            }

            try
            {
                ArrayList diffReport = VsSonarUtils.GetSourceDiffFromStrings(element.ServerSource, currentSource, DiffEngineLevel.FastImperfect);

                foreach (Issue issue in element.Issues)
                {
                    int line = VsSonarUtils.EstimateWhereSonarLineIsUsingSourceDifference(issue.Line, diffReport);

                    if (line >= 0)
                    {
                        issues.Add(issue);
                    }
                }

                return issues;
            }
            catch (Exception)
            {
                return element.Issues;
            }
        }
 public BlameLine GetBlameByLine(Resource resource, int line)
 {
     return this.service.GetBlameLine(AuthtenticationHelper.AuthToken, resource.Key, line);
 }
コード例 #30
0
        /// <summary>
        /// The get issues for resource.
        /// </summary>
        /// <param name="resource">
        /// The resource.
        /// </param>
        /// <returns>
        /// The <see>
        ///         <cref>List</cref>
        ///     </see>
        ///     .
        /// </returns>
        public List<Issue> GetIssuesForResource(Resource resource)
        {
            var issues = new List<Issue>();

            if (resource == null)
            {
                return issues;
            }

            if (DataCache.ContainsKey(resource.Key) || DataCache.ContainsKey(resource.NonSafeKey))
            {
                EditorData element = null;

                if (DataCache.ContainsKey(resource.Key))
                {
                    element = DataCache[resource.Key];
                }
                else
                {
                    element = DataCache[resource.NonSafeKey];
                }

                foreach (Issue issue in element.Issues)
                {
                    issues.Add(issue);
                }
            }

            return issues;
        }