gmantaos/Goirate

View on GitHub

Showing 25 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    setOrDefaultUint := func(val *uint16, env string, defaultVal uint16) {
                        if os.Getenv(env) != "" {
                            num, err := strconv.ParseUint(os.Getenv(env), 10, 16)
                            if err != nil {
                                log.Fatal(err)
            Severity: Minor
            Found in src/config.go and 1 other location - About 55 mins to fix
            src/config.go on lines 112..122

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 124.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    setOrDefaultInt := func(val *int, env string, defaultVal int) {
                        if os.Getenv(env) != "" {
                            num, err := strconv.ParseInt(os.Getenv(env), 10, 32)
                            if err != nil {
                                log.Fatal(err)
            Severity: Minor
            Found in src/config.go and 1 other location - About 55 mins to fix
            src/config.go on lines 123..133

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 124.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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
                              Severity
                              Category
                              Status
                              Source
                              Language