gmantaos/Goirate

View on GitHub

Showing 20 of 25 total issues

Method MovieCommand.Execute has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
Open

func (m *MovieCommand) Execute(args []string) error {

    movie, err := m.getMovie()

    if err != nil {
Severity: Minor
Found in src/movie.go - About 4 hrs to fix

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 ImportConfig has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
Open

func ImportConfig() {

    if _, err := os.Stat(configPath()); err == nil {

        /*
Severity: Minor
Found in src/config.go - About 4 hrs to fix

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 ImportConfig has 98 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func ImportConfig() {

    if _, err := os.Stat(configPath()); err == nil {

        /*
Severity: Major
Found in src/config.go - About 2 hrs to fix

    Method scanCommand.handleSeriesTorrents has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
    Open

    func (cmd *scanCommand) handleSeriesTorrents(seriesTorrentsList []seriesTorrents) error {
    
        for _, seriesTorrents := range seriesTorrentsList {
    
            /*
    Severity: Minor
    Found in src/series.go - About 2 hrs to fix

    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

    Method MovieCommand.Execute has 76 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (m *MovieCommand) Execute(args []string) error {
    
        movie, err := m.getMovie()
    
        if err != nil {
    Severity: Major
    Found in src/movie.go - About 2 hrs to fix

      Method pirateBayScaper.search has 73 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (s *pirateBayScaper) search(query string, timeout time.Duration) ([]Torrent, error) {
      
          torrentsChannel := make(chan []Torrent)
          errorChannel := make(chan error)
      
      
      Severity: Minor
      Found in src/torrents/piratebay.go - About 1 hr to fix

        Method pirateBayScaper.search has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
        Open

        func (s *pirateBayScaper) search(query string, timeout time.Duration) ([]Torrent, error) {
        
            torrentsChannel := make(chan []Torrent)
            errorChannel := make(chan error)
        
        
        Severity: Minor
        Found in src/torrents/piratebay.go - About 1 hr to fix

        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

        Method pirateBayScaper.ParseSearchPage has 55 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (s *pirateBayScaper) ParseSearchPage(doc *goquery.Document) []Torrent {
        
            var torrents []Torrent
        
            doc.Find("#searchResult > tbody > tr").Each(func(i int, row *goquery.Selection) {
        Severity: Minor
        Found in src/torrents/piratebay.go - About 1 hr to fix

          Method MirrorScraper.getTorrents has 51 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (m *MirrorScraper) getTorrents(mirrors []Mirror, query string, trustSource bool) (*Mirror, []Torrent, error) {
          
              type torrentResponse struct {
                  mirror   *Mirror
                  torrents []Torrent
          Severity: Minor
          Found in src/torrents/mirrors.go - About 1 hr to fix

            Method TVmazeToken.Search has 7 return statements (exceeds 4 allowed).
            Open

            func (tkn *TVmazeToken) Search(searchName string) ([]TVmazeSeries, error) {
            
                var searchResults []TVmazeSeries
            
                var searchResponse []struct {
            Severity: Major
            Found in src/series/tvmaze.go - About 45 mins to fix

              Method SearchFilters.IsOk has 7 return statements (exceeds 4 allowed).
              Open

              func (f SearchFilters) IsOk(torrent *Torrent) bool {
              
                  maxSize, _ := f.MaxSizeKB()
                  minSize, _ := f.MinSizeKB()
              
              
              Severity: Major
              Found in src/torrents/search.go - About 45 mins to fix

                Method addCommand.Execute has 7 return statements (exceeds 4 allowed).
                Open

                func (cmd *addCommand) Execute(args []string) error {
                
                    tvmazeToken, err := tvmazeLogin()
                
                    if err != nil {
                Severity: Major
                Found in src/series.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                      } else if t, exists := trnts[Default]; exists && ok(t) {
                  
                          torrent = t
                      }
                  Severity: Major
                  Found in src/torrents/search.go - About 45 mins to fix

                    Method MovieCommand.Execute has 7 return statements (exceeds 4 allowed).
                    Open

                    func (m *MovieCommand) Execute(args []string) error {
                    
                        movie, err := m.getMovie()
                    
                        if err != nil {
                    Severity: Major
                    Found in src/movie.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      if topTorrent == nil {
                                          log.Println("No torrent found")
                                      } else {
                      
                                          log.Println(topTorrent.Title)
                      Severity: Major
                      Found in src/movie.go - About 45 mins to fix

                        Method scanCommand.handleSeriesTorrents has 6 return statements (exceeds 4 allowed).
                        Open

                        func (cmd *scanCommand) handleSeriesTorrents(seriesTorrentsList []seriesTorrents) error {
                        
                            for _, seriesTorrents := range seriesTorrentsList {
                        
                                /*
                        Severity: Major
                        Found in src/series.go - About 40 mins to fix

                          Method UpdateCommand.Execute has 6 return statements (exceeds 4 allowed).
                          Open

                          func (cmd *UpdateCommand) Execute(args []string) error {
                          
                              currentVersion, valid := parseVersion(Version)
                          
                              if !valid && os.Getenv("GOIRATE_DEBUG") != "true" {
                          Severity: Major
                          Found in src/update.go - About 40 mins to fix

                            Function extractUploadTime has 6 return statements (exceeds 4 allowed).
                            Open

                            func extractUploadTime(description string) time.Time {
                            
                                /*
                                    First check the MM-DD HH:mm format
                                */
                            Severity: Major
                            Found in src/torrents/piratebay.go - About 40 mins to fix

                              Method pirateBayScaper.ParseSearchPage has 5 return statements (exceeds 4 allowed).
                              Open

                              func (s *pirateBayScaper) ParseSearchPage(doc *goquery.Document) []Torrent {
                              
                                  var torrents []Torrent
                              
                                  doc.Find("#searchResult > tbody > tr").Each(func(i int, row *goquery.Selection) {
                              Severity: Major
                              Found in src/torrents/piratebay.go - About 35 mins to fix

                                Method scanCommand.scanSeries has 5 return statements (exceeds 4 allowed).
                                Open

                                func (cmd *scanCommand) scanSeries(tvmazeToken *series.TVmazeToken, ser *series.Series, torrentList *[]seriesTorrents) (bool, error) {
                                
                                    filters := cmd.GetFilters()
                                
                                    if ser.MinQuality != "" {
                                Severity: Major
                                Found in src/series.go - About 35 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language