コード例 #1
0
 public IEnumerable <IProjectValidationProblem> Validate(IExecutionContext context, IProject project)
 {
     foreach (var plugin in project.Operations().AllPlugins.Where(p => p.Version.IsDefined))
     {
         //		&& !_externalModules.Contains(p, true)))
         // TODO: inherit plugin version
         var validation = new ReferenceValidator(context);
         var result     = validation.ValidateReference(project, plugin, "plugin");
         if (result != null)
         {
             yield return(result);
         }
     }
 }
コード例 #2
0
        private IProjectValidationProblem ValidateDependency(IExecutionContext context, IProject project, IDependency dependency)
        {
            if (dependency.Version.IsDefined)             // REVIEW: inhereited too
            {
                var validation = new ReferenceValidator(context);
                return(validation.ValidateReference(project, dependency, "dependency"));
            }
            else
            {
                // REVIEW: apply inheritance and dependencyManagement
                //		error.Level = ErrorLevel.Warning;
                //		error.Details =  string.Format("Project {0} depends on {1}:{2} has no version specified.",
                //			projectNode.Project, dependencyReference.GroupId, dependencyReference.ArtifactId);
                //		error.AddFix(new ApplyVersionFix(projectNode.Project, dependencyReference, realDependencyVersion));
                //		AddError(error);
                //		continue;

                return(null);
            }
        }
コード例 #3
0
        // REVIEW need logical refactoring
        private IProjectValidationProblem ValidateInternal(IExecutionContext context, IProject project)
        {
            var parentReference = project.Parent;

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

            var extractor = new ProjectDataExtractor();

            IProject parentByPath;

            if (context.TryGetParentByPath(project, out parentByPath))
            {
                var resolved = extractor.Extract(parentByPath);
                if (project.Operations().HasProjectAsParent(resolved))
                {
                    return(null);
                }

                if (project.Operations().HasProjectAsParent(resolved, false))
                {
                    return(new ValidationProblem("actualparentversion")                     // TODO: fixable
                    {
                        ProjectReference = project,
                        Severity = ProblemSeverity.ProjectWarning,
                        Description = string.Format("parent reference version {0} is different from actual parent {1}.", project.Parent, resolved)
                    });
                }
            }

            var validation = new ReferenceValidator(context);
            var result     = validation.ValidateReference(project, parentReference, "parent");

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

            // previosly found exact match, but it includes including external modules, should be ignored
            if (string.IsNullOrEmpty(parentReference.RelativePath) && context.IsExternalModule(parentReference))
            {
                return(null);
            }

            // exact match found, but path is wrong
            return(new ValidationProblem("parentpath")             // TODO: fixable
            {
                ProjectReference = project,
                Severity = ProblemSeverity.ProjectWarning,
                Description = string.Format("incorrect relative path ({1}) to parent {0}", project.Parent, project.Parent.RelativePath)
            });

            //		var parentProject = _repository.SelectProjectNodes(parent, true).Single();
            //		string resolvedPathToParent = PathOperations.GetRelativePath(_projectNode.FullPath, parentProject.FullPath);
            //		resolvedPathToParent = PathOperations.Normalize(resolvedPathToParent);

            //		if (!string.Equals(_projectNode.RelativeParentPath, resolvedPathToParent, StringComparison.OrdinalIgnoreCase))
            //		{
            //			error.Details = string.Format("Parent path '{0}' does not point to {1}, should be {2}",
            //				_projectNode.RelativeParentPath, parentProject, resolvedPathToParent);

            //			error.AddFix(new RelativePathFix(project, resolvedPathToParent));
            //			_validationOutput.AddError(error);
        }