djudman/evernote-telegram-bot

View on GitHub

Showing 12 of 12 total issues

Function _check_query has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def _check_query(self, document: dict, query: dict) -> bool:
        matched = True
        for k, query_value in query.items():
            key_value = document
            for name in k.split('.'):
Severity: Minor
Found in evernotebot/storage/providers/sqlite.py - 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

Function format_html has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def format_html(message: dict) -> str:
    entities = message.get('entities', [])
    if not entities:
        return get_message_text(message)
    pointer = 0
Severity: Minor
Found in evernotebot/bot/mixins/message.py - 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

Function make_request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def make_request(url, method='GET', params=None, body=None, headers=None):
    parse_result = urlparse(url)
    protocol = parse_result.scheme
    hostname = parse_result.netloc
    port = None
Severity: Minor
Found in evernotebot/util/http.py - 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

Function load_config has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def load_config():
    bot_name = os.getenv('TELEGRAM_BOT_NAME') or 'evernoterobot'
    host = os.getenv('EVERNOTEBOT_HOSTNAME') or '127.0.0.1'
    port = os.getenv('EVERNOTEBOT_EXPOSE_PORT') or 8000
    bot_api_token = os.getenv('TELEGRAM_API_TOKEN') or 'bot_api_token'
Severity: Minor
Found in evernotebot/config.py - 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

Function get_oauth_data has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def get_oauth_data(
Severity: Minor
Found in evernotebot/util/evernote/client.py - About 45 mins to fix

    Function make_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def make_request(url, method='GET', params=None, body=None, headers=None):
    Severity: Minor
    Found in evernotebot/util/http.py - About 35 mins to fix

      Function get_oauth_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_oauth_data(
              user_id: int,
              app_key: str,
              app_secret: str,
              callback_url: str,
      Severity: Minor
      Found in evernotebot/util/evernote/client.py - 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

      Function get_all has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_all(self, query: Optional[Dict] = None) -> typing.Generator:
              if query is None:
                  query = {}
              table = self._table_name
              args = tuple()
      Severity: Minor
      Found in evernotebot/storage/providers/sqlite.py - 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

      Function dict_merge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def dict_merge(d1: dict, d2: dict):
          for k, v in d2.items():
              if k in d1 and isinstance(d1[k], dict) and isinstance(d2[k], dict):
                  dict_merge(d1[k], d2[k])
              else:
      Severity: Minor
      Found in evernotebot/bot/mixins/user.py - 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

      Function create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def create(self, data: dict, auto_generate_id: bool = False) -> int:
              table = self._table_name
              if auto_generate_id:
                  if 'id' in data:
                      del data['id']
      Severity: Minor
      Found in evernotebot/storage/providers/sqlite.py - 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

      Function validate_headers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_headers(self, headers: list[tuple[str, bytes]], body: bytes):
              headers = headers or []
              content_length = None
              content_type = None
              for name, value in headers:
      Severity: Minor
      Found in evernotebot/util/asgi.py - 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

      Function save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def save(self, data: dict):
              object_id = data.get("id")
              if object_id:
                  data["_id"] = object_id
                  del data["id"]
      Severity: Minor
      Found in evernotebot/storage/providers/mongo.py - 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

      Severity
      Category
      Status
      Source
      Language