findbugs

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: 12 Imported by: 0

Documentation

Overview

Package findbugs is the Findbugs static analysis tool's implementation of an Imendulo tool. See http://findbugs.sourceforge.net/ for more information.

Index

Constants

View Source
const (
	NAME = "Findbugs"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BugCategory

type BugCategory struct {
	Name        string `xml:"category,attr"`
	Description string `xml:"Description"`
}

BugCategory describes a category in which bugs may fall.

type BugInstance

type BugInstance struct {
	Id           bson.ObjectId
	Type         string         `xml:"type,attr"`
	Priority     int            `xml:"priority,attr"`
	Abbreviation string         `xml:"abbrev,attr"`
	Category     string         `xml:"category,attr"`
	Rank         int            `xml:"rank,attr"`
	ShortMessage string         `xml:"ShortMessage"`
	LongMessage  string         `xml:"LongMessage"`
	Class        *Class         `xml:"Class"`
	Method       *Method        `xml:"Method"`
	Field        *Field         `xml:"Field"`
	Var          *LocalVariable `xml:"LocalVariable"`
	Line         *SourceLine    `xml:"SourceLine"`
	Properties   []*Property    `xml:"Property"`
}

BugInstance describes a particular bug detected by Findbugs. It contains information describing its location and state as well as its category, severity and type.

type BugPattern

type BugPattern struct {
	Type         string        `xml:"type,attr"`
	Abbreviation string        `xml:"abbrev,attr"`
	Category     string        `xml:"category,attr"`
	Description  string        `xml:"ShortDescription"`
	Details      template.HTML `xml:"Details"`
}

BugPattern describes a pattern associated with a BugCategory.

type Class

type Class struct {
	Name      string      `xml:"classname,attr"`
	IsPrimary bool        `xml:"primary,attr"`
	Line      *SourceLine `xml:"SourceLine"`
	Message   string      `xml:"Message"`
}

Class describes a Java Class in which a bug was found.

type ClassStats

type ClassStats struct {
	Name        string `xml:"class,attr"`
	Source      string `xml:"sourceFile,attr"`
	IsInterface bool   `xml:"interface,attr"`
	BugCount    int    `xml:"bugs,attr"`
	Size        int    `xml:"size,attr"`
	Priority1   int    `xml:"priority_1,attr"`
	Priority2   int    `xml:"priority_2,attr"`
	Priority3   int    `xml:"priority_3,attr"`
}

ClassStats provides Findbugs statistics about a specific class within a package.

type DummyReport

type DummyReport struct {
	Time    int      `xml:"analysisTimestamp,attr"`
	Summary *Summary `xml:"FindBugsSummary"`
	//Instances is all the bugs found by Findbugs
	Instances []*BugInstance `xml:"BugInstance"`
	//Categories is the bug categories found by Findbugs.
	Categories []*BugCategory `xml:"BugCategory"`
	//Patterns is the bug patterns found by Findbugs.
	Patterns []*BugPattern `xml:"BugPattern"`
}

type Field

type Field struct {
	Name      string      `xml:"name,attr"`
	Class     string      `xml:"classname,attr"`
	Signature string      `xml:"signature,attr"`
	IsStatic  bool        `xml:"isStatic,attr"`
	IsPrimary bool        `xml:"primary,attr"`
	Role      string      `xml:"role,attr"`
	Line      *SourceLine `xml:"SourceLine"`
	Message   string      `xml:"Message"`
}

Field describes a global variable within a Java Class.

type FileStats

type FileStats struct {
	Path     string `xml:"path,attr"`
	BugCount int    `xml:"bugCount,attr"`
	Size     int    `xml:"size,attr"`
}

FileStats provides Findbugs statistics about a specific source file.

type LocalVariable

type LocalVariable struct {
	Name     string `xml:"name,attr"`
	Register int    `xml:"register,attr"`
	PC       string `xml:"pc,attr"`
	Role     string `xml:"role,attr"`
	Message  string `xml:"Message"`
}

LocalVariable describes a local variable within a Java Class.

type Method

type Method struct {
	Name      string      `xml:"name,attr"`
	Class     string      `xml:"classname,attr"`
	Signature string      `xml:"signature,attr"`
	IsStatic  bool        `xml:"isStatic,attr"`
	IsPrimary bool        `xml:"primary,attr"`
	Line      *SourceLine `xml:"SourceLine"`
	Message   string      `xml:"Message"`
}

Method describes a method within a Java Class.

type PackageStats

type PackageStats struct {
	Name       string        `xml:"package,attr"`
	ClassCount int           `xml:"total_types,attr"`
	BugCount   int           `xml:"total_bugs,attr"`
	Size       int           `xml:"total_size,attr"`
	Priority1  int           `xml:"priority_1,attr"`
	Priority2  int           `xml:"priority_2,attr"`
	Priority3  int           `xml:"priority_3,attr"`
	Classes    []*ClassStats `xml:"ClassStats"`
}

PackageStats provides Findbugs statistics about a specific package as well as the classes found within it.

type Property

type Property struct {
	Name  string `xml:"name,attr"`
	Value string `xml:"value,attr"`
}

Property decribes some attribute associated with a bug.

type Report

type Report struct {
	Id      bson.ObjectId
	Time    int
	Summary *Summary
	//Instances is all the bugs found by Findbugs
	Instances []*BugInstance
	//CategoryMap and PatternMap make it easier to use the bug categories and patterns.
	CategoryMap map[string]*BugCategory
	PatternMap  map[string]*BugPattern
}

Report stores the results of running Findbugs. It is populated from XML output produced by findbugs.

func NewReport

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

NewReport

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 returns true if Findbugs found no bugs and false otherwise.

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

func (*Result) ChartVals

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

ChartVals

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) String

func (r *Result) String() string

String

func (*Result) Template

func (r *Result) Template() string

type SourceLine

type SourceLine struct {
	Class   string `xml:"classname,attr"`
	Start   int    `xml:"start,attr"`
	End     int    `xml:"end,attr"`
	StartBC int    `xml:"startBytecode,attr"`
	EndBC   int    `xml:"endBytecode,attr"`
	File    string `xml:"sourcefile,attr"`
	Path    string `xml:"sourcepath,attr"`
	Message string `xml:"Message"`
}

Sourceline describes a line inside a Java Class.

type Summary

type Summary struct {
	ClassCount     int             `xml:"total_classes,attr"`
	ReferenceCount int             `xml:"referenced_classes,attr"`
	BugCount       int             `xml:"total_bugs,attr"`
	Size           int             `xml:"total_size,attr"`
	PackageCount   int             `xml:"num_packages,attr"`
	SecondsCPU     int             `xml:"cpu_seconds,attr"`
	SecondsClock   int             `xml:"clock_seconds,attr"`
	SecondsGC      int             `xml:"gc_seconds,attr"`
	PeakMB         int             `xml:"peak_mbytes,attr"`
	AllocMB        int             `xml:"alloc_mbytes,attr"`
	Priority1      int             `xml:"priority_1,attr"`
	Priority2      int             `xml:"priority_2,attr"`
	Priority3      int             `xml:"priority_3,attr"`
	Files          []*FileStats    `xml:"FileStats"`
	Packages       []*PackageStats `xml:"PackageStats"`
}

Summary provides statistics about Findbugs's execution on a package and file level. Furthermore it gives performance information such as memory usage and where time was spent.

func (*Summary) String

func (s *Summary) String() string

String

type Tool

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

Findbugs is a tool.T used to run Findbugs on Java classes.

func New

func New() (*Tool, error)

New creates a new instance of the Findbugs tool. If an error is returned, it will be due Findbugs not being configured correctly.

func (*Tool) Lang

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

Lang is Java.

func (*Tool) Name

func (t *Tool) Name() string

Name is Findbugs.

func (*Tool) Run

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

Run executes Findbugs on the provided source file. Findbugs is run with the following flags: -effort:max, -experimental, -relaxed. The result is written to an XML file which is then read and used to create a Findbugs Result.

Jump to

Keyboard shortcuts

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