pmd

package
v0.0.0-...-d4285bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2014 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package pmd is the PMD static analysis tool's implementation of an Impendulo tool. For more information see http://pmd.sourceforge.net/.

Index

Constants

View Source
const (
	NAME = "PMD"
)

Variables

This section is empty.

Functions

func RuleSet

func RuleSet() (map[string]*Rule, error)

RuleSet loads the available rules from a json file which can be set via the config file.

Types

type File

type File struct {
	Name       string     `xml:"name,attr"`
	Violations Violations `xml:"violation"`
}

File defines a source file analysed by PMD and all of the errors found in it.

func (*File) CompressViolations

func (f *File) CompressViolations()

CompressViolations packs all Violations of the same type into a single Violation by storing their location seperately.

func (*File) String

func (f *File) String() string

String

type Report

type Report struct {
	Id      bson.ObjectId
	Version string  `xml:"version,attr"`
	Files   []*File `xml:"file"`
	Errors  int
}

Report is the result of running PMD on a Java source file.

func NewReport

func NewReport(id bson.ObjectId, data []byte) (*Report, error)

NewReport generates a new Report from XML generated by PMD.

func (*Report) File

func (r *Report) File(name string) *File

File retrieves a File whose name ends with the provided name.

func (*Report) Lines

func (r *Report) Lines() []*result.Line

func (*Report) String

func (r *Report) String() string

String

func (*Report) Success

func (r *Report) Success() bool

Success is true if no errors were found.

type Result

type Result struct {
	Id     bson.ObjectId `bson:"_id"`
	FileId bson.ObjectId `bson:"fileid"`
	Name   string        `bson:"name"`
	Report *Report       `bson:"report"`
	GridFS bool          `bson:"gridfs"`
	Type   string        `bson:"type"`
}

func NewResult

func NewResult(fileId bson.ObjectId, data []byte) (*Result, error)

NewResult creates a new PMD Result. Any error returned will be as a result of creating a PMD Report from the XML in data.

func (*Result) ChartVals

func (r *Result) ChartVals() []*result.ChartVal

ChartVals gets the number of errors found by PMD.

func (*Result) GetFileId

func (r *Result) GetFileId() bson.ObjectId

GetFileId

func (*Result) GetId

func (r *Result) GetId() bson.ObjectId

GetId

func (*Result) GetName

func (r *Result) GetName() string

GetName

func (*Result) GetTestId

func (this *Result) GetTestId() bson.ObjectId

func (*Result) GetType

func (r *Result) GetType() string

func (*Result) Lines

func (r *Result) Lines() []*result.Line

func (*Result) OnGridFS

func (r *Result) OnGridFS() bool

OnGridFS

func (*Result) Reporter

func (r *Result) Reporter() result.Reporter

func (*Result) SetReport

func (r *Result) SetReport(report result.Reporter)

SetReport is used to change this result's report. This comes in handy when putting data into/getting data out of GridFS

func (*Result) Success

func (r *Result) Success() bool

Success

func (*Result) Template

func (r *Result) Template() string

type Rule

type Rule struct {
	Id          string
	Name        string
	Description string
	Default     bool
}

Rule is the descriptive representation of a PMD rule. It is used when a PMD configuration is chosen.

type Rules

type Rules struct {
	Id        bson.ObjectId   `bson:"_id"`
	ProjectId bson.ObjectId   `bson:"projectid"`
	Rules     map[string]bool `bson:"rules"`
}

Rules specifies the PMD rules configured for a specific project. It only stores each rule's identifier.

func DefaultRules

func DefaultRules(projectId bson.ObjectId) (*Rules, error)

DefaultRules creates a default Rules struct from the available rules.

func NewRules

func NewRules(projectId bson.ObjectId, rules map[string]bool) (*Rules, error)

NewRules creates a bew Rules struct from a set of rules for a given project. Each rule in the set is checked against the available rules.

func (*Rules) RuleArray

func (r *Rules) RuleArray() []string

RuleArray extracts an array of pmd rule identifiers from a Rules struct.

func (*Rules) String

func (r *Rules) String() string

String

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool is an implementation of tool.T which allows us to run PMD on Java classes.

func New

func New(rules *Rules) (*Tool, error)

New creates a new instance of a PMD Tool. Errors returned will be due to loading either the default PMD rules or the PMD execution script.

func (*Tool) Lang

func (t *Tool) Lang() tool.Language

Lang is Java

func (*Tool) Name

func (t *Tool) Name() string

Name is PMD

func (*Tool) Run

func (t *Tool) Run(fileId bson.ObjectId, target *tool.Target) (result.Tooler, error)

Run runs PMD on a provided Java source file. PMD writes its output to an XML file which we then read and use to create a PMD Result.

type Violation

type Violation struct {
	Id          bson.ObjectId
	Begin       int          `xml:"beginline,attr"`
	End         int          `xml:"endline,attr"`
	Rule        string       `xml:"rule,attr"`
	RuleSet     string       `xml:"ruleset,attr"`
	Url         template.URL `xml:"externalInfoUrl,attr"`
	Priority    int          `xml:"priority,attr"`
	Description string       `xml:",innerxml"`
	//The locations where the error was detected.
	Starts, Ends []int
}

Violation describes an error detected by PMD.

type Violations

type Violations []*Violation

Violations

func (Violations) Len

func (v Violations) Len() int

func (Violations) Less

func (v Violations) Less(i, j int) bool

func (Violations) Swap

func (v Violations) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL