TooAngel/democratic-collaboration

View on GitHub

Showing 14 of 109 total issues

Function render has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    if (!this.state.pullRequest) {
      return <div>Here you can enable world driven for each of your repositories. When
      enabled, pull requests are watched and automatically merged based on the
      reviews.</div>;
Severity: Major
Found in src/public/js/pullrequestView.js - About 2 hrs to fix

    Function getPullRequestData has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function getPullRequestData(user, owner, repo, number) {
      const pull = await getPullRequest(user, owner, repo, number);
      const contributors = await getContributors(user, pull.head.repo.contributors_url);
      const reviews = await getReviews(user, pull);
      for (const review of reviews) {
    Severity: Major
    Found in src/helpers/pullRequest.js - About 2 hrs to fix

      Function put has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def put(self, org, repo):
              checked = request.json['checked']
              full_name = '{}/{}'.format(org, repo)
              github_client = github.Github(g.user.github_access_token)
              repository = github_client.get_repo('{}/{}'.format(org, repo))
      Severity: Minor
      Found in src/apiendpoint.py - 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

      Function render has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render() {
          if (!this.state.fetched) {
            return <div className="loader"></div>;
          }
      
      
      Severity: Minor
      Found in src/public/js/dashboard.js - About 1 hr to fix

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

            def handle_pull_request_review(self, data):
                # print(data)
                if data['action'] == 'submitted':
                    if 'state' not in data['review']:
                        # print('No state')
        Severity: Minor
        Found in src/routes/githubWebHook.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 getDates has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function getDates(user, pull) {
          const createdAt = new Date(pull.created_at).getTime();
          const commits = await getCommits(user, pull);
          const commit = commits.reduce((total, current) => {
            return Math.max(new Date(total), new Date(current.commit.author.date));
        Severity: Minor
        Found in src/helpers/pullRequest.js - About 1 hr to fix

          Function getContributors has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function getContributors(user, url) {
            const options = {
              headers: {
                Accept: 'application/vnd.github.v3+json',
                Authorization: `token ${user.githubAccessToken}`,
          Severity: Minor
          Found in src/helpers/pullRequest.js - About 1 hr to fix

            Function ws_admin_logs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def ws_admin_logs(ws):
                logging.info('websocket connection started')
                url = 'https://api.heroku.com/apps/worlddriven/log-sessions'
                headers = {
                    'accept': 'application/vnd.heroku+json; version=3',
            Severity: Minor
            Found in src/server.py - About 55 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 update_contributors_with_reviews has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def update_contributors_with_reviews(self):
                    data = fetch_reviews(self.repository.full_name, self.pull_request.number, self.token)
                    reviews_decided = [review for review in data if review['state'] != 'COMMENTED']
                    for review in reviews_decided:
                        value = 0
            Severity: Minor
            Found in src/PullRequest.py - 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

            Function getPullRequestData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export async function getPullRequestData(user, owner, repo, number) {
              const pull = await getPullRequest(user, owner, repo, number);
              const contributors = await getContributors(user, pull.head.repo.contributors_url);
              const reviews = await getReviews(user, pull);
              for (const review of reviews) {
            Severity: Minor
            Found in src/helpers/pullRequest.js - 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

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

            export async function createIssueComment(user, owner, repo, number, comment) {
            Severity: Minor
            Found in src/helpers/github.js - About 35 mins to fix

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

              def repositories():
                  if not g.user:
                      return 401
              
                  github_client = github.Github(g.user.github_access_token)
              Severity: Minor
              Found in src/server.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 check_for_merge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check_for_merge(self):
                      self.set_status()
              
                      if self.coefficient >= 0 and self.max_date + self.merge_duration < datetime.utcnow():
                          logging.info('Would merge now')
              Severity: Minor
              Found in src/PullRequest.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 check_pull_requests has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def check_pull_requests():
                  logging.info('Check pull requests: {}'.format(datetime.utcnow()))
                  app = Flask(__name__)
                  app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('JAWSDB_MARIA_URL', 'mysql://worlddriven:password@127.0.0.1/worlddriven')
                  db.init_app(app)
              Severity: Minor
              Found in src/PullRequest.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