notyim/notyim

View on GitHub

Showing 20 of 20 total issues

Function exports has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(api) {
  var validEnv = ['development', 'test', 'production']
  var currentEnv = api.env()
  var isDevelopmentEnv = api.env('development')
  var isProductionEnv = api.env('production')
Severity: Major
Found in babel.config.js - About 2 hrs to fix

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

    func _Gaia_SaveCheckMetrics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
        in := new(SaveCheckMetricsRequest)
        if err := dec(in); err != nil {
            return nil, err
        }
    Severity: Major
    Found in extras/go/gaia/agent/agent.pb.go and 2 other locations - About 2 hrs to fix
    extras/go/gaia/agent/agent.pb.go on lines 425..441
    extras/go/gaia/agent/agent.pb.go on lines 443..459

    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 221.

    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 3 locations. Consider refactoring.
    Open

    func _Gaia_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
        in := new(RegistrationRequest)
        if err := dec(in); err != nil {
            return nil, err
        }
    Severity: Major
    Found in extras/go/gaia/agent/agent.pb.go and 2 other locations - About 2 hrs to fix
    extras/go/gaia/agent/agent.pb.go on lines 443..459
    extras/go/gaia/agent/agent.pb.go on lines 461..477

    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 221.

    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 3 locations. Consider refactoring.
    Open

    func _Gaia_SyncCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
        in := new(SyncCheckRequest)
        if err := dec(in); err != nil {
            return nil, err
        }
    Severity: Major
    Found in extras/go/gaia/agent/agent.pb.go and 2 other locations - About 2 hrs to fix
    extras/go/gaia/agent/agent.pb.go on lines 425..441
    extras/go/gaia/agent/agent.pb.go on lines 461..477

    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 221.

    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

    Function withClientTrace has 67 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func withClientTrace(ctx context.Context, r *Result) context.Context {
        trace := &httptrace.ClientTrace{
            DNSStart: func(i httptrace.DNSStartInfo) {
                r.dnsStart = time.Now()
            },
    Severity: Minor
    Found in extras/gaia/scanner/httpscanner/scanner.go - About 1 hr to fix

      Method GenericEvent.UnmarshalJSON has 63 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (e *GenericEvent) UnmarshalJSON(data []byte) error {
          var temp EventWrapper
      
          if err := json.Unmarshal(data, &temp); err != nil {
              return fmt.Errorf("Unmarshal event error: %w", err)
      Severity: Minor
      Found in extras/gaia/eventbus.go - About 1 hr to fix

        Function Check has 57 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func Check(req *http.Request) *CheckResponse {
            req.Header.Set("User-Agent", "noty/2.0 (https://noty.im)")
            var result Result
        
            ctx := WithHTTPStat(req.Context(), &result)
        Severity: Minor
        Found in extras/gaia/scanner/httpscanner/scanner.go - About 1 hr to fix

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

          package cmd
          
          import (
              "github.com/notyim/gaia/agent"
              "github.com/notyim/gaia/config"
          Severity: Major
          Found in extras/go/gaia/cmd/client.go and 1 other location - About 1 hr to fix
          extras/go/gaia/cmd/server.go on lines 1..23

          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 132.

          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

          package cmd
          
          import (
              "github.com/notyim/gaia/agent"
              "github.com/notyim/gaia/config"
          Severity: Major
          Found in extras/go/gaia/cmd/server.go and 1 other location - About 1 hr to fix
          extras/go/gaia/cmd/client.go on lines 1..23

          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 132.

          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 GenericEvent.UnmarshalJSON has 10 return statements (exceeds 4 allowed).
          Open

          func (e *GenericEvent) UnmarshalJSON(data []byte) error {
              var temp EventWrapper
          
              if err := json.Unmarshal(data, &temp); err != nil {
                  return fmt.Errorf("Unmarshal event error: %w", err)
          Severity: Major
          Found in extras/gaia/eventbus.go - About 1 hr to fix

            Method verify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def verify
                if VerificationService.check_to_verify(@verification, params[:code])
                  case @verification.verifiable
                  when Receiver
                    redirect_to receivers_url, flash: { notice: 'You have succesflly confirm the contact' }
            Severity: Minor
            Found in app/controllers/verification_controller.rb - About 45 mins 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 Server.SetupRoute has 6 return statements (exceeds 4 allowed).
            Open

            func (s *Server) SetupRoute() {
                secureMiddleware := secure.New(secure.Options{
                    AllowedHosts:         []string{"noty.ax", "gaia.noty.im", "laputa.noty.im", ".*.noty.im"},
                    AllowedHostsAreRegex: true,
                    HostsProxyHeaders:    []string{"X-Forwarded-Host"},
            Severity: Major
            Found in extras/gaia/server.go - About 40 mins to fix

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

              func (c *gaiaClient) SaveCheckMetrics(ctx context.Context, in *SaveCheckMetricsRequest, opts ...grpc.CallOption) (*SaveCheckMetricsResponse, error) {
                  out := new(SaveCheckMetricsResponse)
                  err := c.cc.Invoke(ctx, "/Gaia/SaveCheckMetrics", in, out, opts...)
                  if err != nil {
                      return nil, err
              Severity: Minor
              Found in extras/go/gaia/agent/agent.pb.go and 2 other locations - About 35 mins to fix
              extras/go/gaia/agent/agent.pb.go on lines 387..394
              extras/go/gaia/agent/agent.pb.go on lines 396..403

              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 107.

              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 3 locations. Consider refactoring.
              Open

              func (c *gaiaClient) Register(ctx context.Context, in *RegistrationRequest, opts ...grpc.CallOption) (*RegistrationResponse, error) {
                  out := new(RegistrationResponse)
                  err := c.cc.Invoke(ctx, "/Gaia/Register", in, out, opts...)
                  if err != nil {
                      return nil, err
              Severity: Minor
              Found in extras/go/gaia/agent/agent.pb.go and 2 other locations - About 35 mins to fix
              extras/go/gaia/agent/agent.pb.go on lines 396..403
              extras/go/gaia/agent/agent.pb.go on lines 405..412

              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 107.

              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 3 locations. Consider refactoring.
              Open

              func (c *gaiaClient) SyncCheck(ctx context.Context, in *SyncCheckRequest, opts ...grpc.CallOption) (*SyncCheckResponse, error) {
                  out := new(SyncCheckResponse)
                  err := c.cc.Invoke(ctx, "/Gaia/SyncCheck", in, out, opts...)
                  if err != nil {
                      return nil, err
              Severity: Minor
              Found in extras/go/gaia/agent/agent.pb.go and 2 other locations - About 35 mins to fix
              extras/go/gaia/agent/agent.pb.go on lines 387..394
              extras/go/gaia/agent/agent.pb.go on lines 405..412

              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 107.

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

                def auto_prefix
                  case @check.type
                  when Check::TYPE_HTTP
                    @check.uri = "http://#{@check.uri}" unless @check.uri.start_with?('http')
                  when Check::TYPE_TCP
              Severity: Minor
              Found in app/controllers/checks_controller.rb - About 35 mins 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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.save(receiver)
                  raise 'UserCannotManageTeam' unless can_view?(receiver)
              
                  VerificationService.generate(receiver) if receiver.save! && receiver.require_verify?
              
              
              Severity: Minor
              Found in app/services/receiver_service.rb - About 25 mins 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 Agent.SyncState has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func (a *Agent) SyncState() {
                  defer a.conn.Close()
                  done := make(chan struct{})
              
                  go func() {
              Severity: Minor
              Found in extras/gaia/client/client.go - About 25 mins 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

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

                def acknowledge(receiver)
                  @receiver = Receiver.find(receiver)
                  @verification = @receiver.last_verification
                  @url = [verify_verification_url(@verification), '?code=', @verification.code].join('')
                  mail(to: @receiver.handler, subject: 'Your email alert contact is confirm')
              Severity: Minor
              Found in app/mailers/verification_mailer.rb and 1 other location - About 15 mins to fix
              app/mailers/verification_mailer.rb on lines 6..10

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

              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

                def confirm_contact(receiver)
                  @receiver = Receiver.find(receiver)
                  @verification = @receiver.last_verification
                  @url = [verify_verification_url(@verification), '?code=', @verification.code].join('')
                  mail(to: @receiver.handler, subject: 'Please confirm your email alert contact')
              Severity: Minor
              Found in app/mailers/verification_mailer.rb and 1 other location - About 15 mins to fix
              app/mailers/verification_mailer.rb on lines 13..17

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

              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

              Severity
              Category
              Status
              Source
              Language