Showing 69 of 79 total issues
Method GrantResponse.LoadFromJSON
has 6 return statements (exceeds 4 allowed). Open
Open
func (r *GrantResponse) LoadFromJSON(responseBody []byte, mapping ...map[GrantResponseKey]string) error {
responseFieldMap := DefaultGrantResponseMapping
if len(mapping) > 0 {
responseFieldMap = mapping[0]
}
Function GetRemote
has 6 return statements (exceeds 4 allowed). Open
Open
func GetRemote(fromGitRepositoryAt string, remoteNameMatcher ...string) (*Remote, error) {
// validation checks
gitPath := path.Join(fromGitRepositoryAt, "/.git")
fileInfo, err := os.Lstat(gitPath)
if err != nil {
Method Repository.GetWebsiteURL
has 6 return statements (exceeds 4 allowed). Open
Open
func (r Repository) GetWebsiteURL() (string, error) {
switch true {
case validator.IsGitHTTPUrl(r.URL):
link, err := str.GetHttpLinkFromHttpCloneUrl(r.URL)
if err != nil {
Function ToSelect
has 6 return statements (exceeds 4 allowed). Open
Open
func ToSelect(options InputOptions) (int, error) {
helper := InputHelper(options)
fmt.Printf("\n")
helper.PrintBeforeMessage()
fmt.Printf("\n")
Function ResolvePath
has 6 return statements (exceeds 4 allowed). Open
Open
func ResolvePath(relativePathFragments ...string) (string, error) {
fullPath := path.Join(relativePathFragments...)
if len(fullPath) == 0 {
fullPath = "."
}
Function WatchNotifications
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
accessToken string,
fromProjects Projects,
databaseConnection *sql.DB,
updateInterval time.Duration,
stop chan struct{},
Function WatchNotifications
has 5 return statements (exceeds 4 allowed). Open
Open
func WatchNotifications(
accessToken string,
fromProjects Projects,
databaseConnection *sql.DB,
updateInterval time.Duration,
Function GetAccount
has 5 return statements (exceeds 4 allowed). Open
Open
func GetAccount(client request.Doer, hostname, accessToken string) (*APIv4UserResponse, error) {
requestObject, createRequestError := request.Create(request.CreateOptions{
URL: fmt.Sprintf("https://%s/api/v4/user", hostname),
Headers: map[string][]string{
"Content-Type": {"application/json"},
Function run
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func run(command *cobra.Command, args []string) {
if config.Global.Repositories == nil {
log.Error("no repositories have been defined")
os.Exit(1)
return
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function GetTodos
has 5 return statements (exceeds 4 allowed). Open
Open
func GetTodos(client request.Doer, hostname, accessToken string, since ...time.Time) (*APIv4TodoResponse, error) {
requestObject, createRequestError := request.Create(request.CreateOptions{
URL: fmt.Sprintf("https://%s/api/v4/todos", hostname),
Headers: map[string][]string{
"Content-Type": {"application/json"},
Method GrantRequest.Do
has 5 return statements (exceeds 4 allowed). Open
Open
func (r GrantRequest) Do(mapping ...map[GrantRequestKey]string) (*GrantResponse, error) {
client := http.Client{Timeout: time.Second * 5}
request, getRequestError := r.GetRequest(mapping...)
if getRequestError != nil {
return nil, fmt.Errorf("failed to create request: %s", getRequestError)
Method TodoSerializer.GetMessage
has 5 return statements (exceeds 4 allowed). Open
Open
func (ts TodoSerializer) GetMessage() string {
targetType := ts.getTargetType()
createdAt := humanize.Time(ts.CreatedAt)
switch ts.ActionName {
case "assigned":
Function GetAccount
has 5 return statements (exceeds 4 allowed). Open
Open
func GetAccount(client request.Doer, accessToken string) (*APIv3UserResponse, error) {
requestObject, requestError := request.Create(request.CreateOptions{
URL: "https://api.github.com/user",
Headers: map[string][]string{
"Accept": {"application/vnd.github.v3+json"}, // as requested at https://developer.github.com/v3/#current-version
Function ApplyMigrations
has 5 return statements (exceeds 4 allowed). Open
Open
func ApplyMigrations(tableName string, migrations []string, databasePath string) error {
connection, newConnectionError := NewConnection(databasePath)
defer connection.Close()
if newConnectionError != nil {
return newConnectionError
Function NewFromFile
has 5 return statements (exceeds 4 allowed). Open
Open
func NewFromFile(filePath string) (*Config, error) {
var configuration Config
absoluteFilePath, resolvePathError := utils.ResolvePath(filePath)
if resolvePathError != nil {
Function GetNotifications
has 5 return statements (exceeds 4 allowed). Open
Open
func GetNotifications(client request.Doer, accessToken string, since ...time.Time) (*APIv3Notifications, error) {
dateSinceFilter := time.Now().Add(-time.Hour * 24 * 365)
if len(since) > 0 {
dateSinceFilter = since[0]
}
Function GetStories
has 5 return statements (exceeds 4 allowed). Open
Open
func GetStories(accessToken string, inProjectID string, since ...time.Time) (*APIv5StoriesResponse, error) {
accountInfo, accountInfoError := GetAccount(accessToken)
if accountInfoError != nil {
return nil, accountInfoError
}
Function GetCommand
has 5 return statements (exceeds 4 allowed). Open
Open
func GetCommand() *cobra.Command {
cmd := cobra.Command{
Use: constants.MergeRequestNoun,
Short: "opens the browser to a merge/pull request at this repository's url",
Aliases: constants.MergeRequestAliases,
Function GetFiles
has 5 return statements (exceeds 4 allowed). Open
Open
func GetFiles(opt ...GetFilesOptions) ([]string, error) {
configurationFiles := []string{}
// local configurations
contextualConfigPath, getWdError := os.Getwd()
Method Repositories.Less
has 5 return statements (exceeds 4 allowed). Open
Open
func (r Repositories) Less(i, j int) bool {
if len(r[i].Name) > 0 && len(r[j].Name) > 0 {
comparison := strings.Compare(r[i].Name, r[j].Name)
if comparison != 0 {
return comparison <= 0