ActivityWatch/aw-webui

View on GitHub

Showing 23 of 33 total issues

File activity.ts has 436 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import moment from 'moment';
import { unitOfTime } from 'moment';
import * as _ from 'lodash';
import { map, filter, values, groupBy, sortBy, flow, reverse } from 'lodash/fp';

Severity: Minor
Found in src/store/modules/activity.ts - About 6 hrs to fix

    Function update has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function update(svg_elem, usage_arr, onPeriodClicked) {
      const dateformat = 'YYYY-MM-DD';
    
      // No apps, sets status to "No data"
      if (usage_arr.length <= 0) {
    Severity: Major
    Found in src/visualizations/periodusage.js - About 2 hrs to fix

      Function update has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function update(container, events, showAFK, chunkfunc, eventfunc) {
        const timeline = d3.select(container.querySelector('.apptimeline')).html(null);
        const titleinfo_list = d3.select(container.querySelector('.titleinfo-list')).html(null);
        d3.select(container.querySelector('.titleinfo-container')).html(null);
      
      
      Severity: Major
      Found in src/visualizations/timeline.js - About 2 hrs to fix

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

        function update(el, json) {
          // Basic setup of page elements.
          initializeBreadcrumbTrail();
        
          el.querySelector('#container').innerHTML = '';
        Severity: Major
        Found in src/visualizations/sunburst-clock.js - About 2 hrs to fix

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

          function update(svg_el, events, event_type) {
            const timeline = d3.select(svg_el);
            timeline.selectAll('*').remove();
          
            if (events.length <= 0) {
          Severity: Major
          Found in src/visualizations/timeline-simple.js - About 2 hrs to fix

            Function load_demo has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async load_demo({ commit }) {
                // A function to load some demo data (for screenshots and stuff)
                commit('start_loading', {});
            
                function groupSumEventsBy(events, key, f) {
            Severity: Major
            Found in src/store/modules/activity.ts - About 2 hrs to fix

              Function update has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function update(container, apps) {
                // No apps, sets status to "No data"
                if (apps.length <= 0) {
                  set_status(container, 'No data');
                  return container;
              Severity: Major
              Found in src/visualizations/summary.js - About 2 hrs to fix

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

                  async ensure_loaded({ commit, state, dispatch }, query_options: QueryOptions) {
                    console.info('Query options: ', query_options);
                    if (!state.loaded || state.query_options !== query_options || query_options.force) {
                      commit('start_loading', query_options);
                      if (!query_options.timeperiod) {
                Severity: Minor
                Found in src/store/modules/activity.ts - 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 fullDesktopQuery has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function fullDesktopQuery(
                  browserbuckets: string[],
                  windowbucket: string,
                  afkbucket: string,
                  filterAFK = true,
                Severity: Minor
                Found in src/queries.ts - About 1 hr to fix

                  Function ensure_loaded has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async ensure_loaded({ commit, state, dispatch }, query_options: QueryOptions) {
                      console.info('Query options: ', query_options);
                      if (!state.loaded || state.query_options !== query_options || query_options.force) {
                        commit('start_loading', query_options);
                        if (!query_options.timeperiod) {
                  Severity: Minor
                  Found in src/store/modules/activity.ts - About 1 hr to fix

                    Function drawLegend has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function drawLegend() {
                      // Dimensions of legend item: width, height, spacing, radius of rounded rect.
                      const li = {
                        w: 75,
                        h: 30,
                    Severity: Minor
                    Found in src/visualizations/sunburst-clock.js - About 1 hr to fix

                      Function buildTooltip has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function buildTooltip(bucket, e) {
                        // WARNING: XSS risk, make sure to sanitize properly
                        // FIXME: Not actually tested against XSS attacks, implementation needs to be verified in tests.
                        let inner = 'Unknown bucket type';
                        if (bucket.type == 'currentwindow') {
                      Severity: Minor
                      Found in src/util/tooltip.js - About 1 hr to fix

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

                        export function canonicalEvents(params: DesktopQueryParams | AndroidQueryParams): string {
                          // Needs escaping for regex patterns like '\w' to work (JSON.stringify adds extra unecessary escaping)
                          const classes_str = JSON.stringify(params.classes).replace(/\\\\/g, '\\');
                          const cat_filter_str = JSON.stringify(params.filter_classes);
                        
                        
                        Severity: Minor
                        Found in src/queries.ts - 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 split_by_hour_into_data has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function split_by_hour_into_data(events) {
                          if (events === undefined || events === null || events.length == 0) return [];
                          const d = moment(events[0].timestamp).startOf('day');
                          const hoursOffset = get_hour_offset();
                          return _.range(0, 24).map(h => {
                        Severity: Minor
                        Found in src/util/transforms.js - About 1 hr to fix

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

                            beforeCreate: function () {
                              const that = this;
                              const methods = this.$options.methods || {};
                              for (const key in methods) {
                                const original = methods[key];
                          Severity: Minor
                          Found in src/mixins/asyncErrorCaptured.js - 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 fullDesktopQuery has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            browserbuckets: string[],
                            windowbucket: string,
                            afkbucket: string,
                            filterAFK = true,
                            classes,
                          Severity: Major
                          Found in src/queries.ts - About 50 mins to fix

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

                            export function getTitleAttr(bucket: Bucket, e: Event) {
                              if (bucket.type == 'currentwindow') {
                                return e.data.app;
                              } else if (bucket.type == 'web.tab.current') {
                                try {
                            Severity: Minor
                            Found in src/util/color.ts - 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 update has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            function update(container, events, showAFK, chunkfunc, eventfunc) {
                            Severity: Minor
                            Found in src/visualizations/timeline.js - About 35 mins to fix

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

                              function updateSummedEvents(container, summedEvents, titleKeyFunc, hoverKeyFunc, colorKeyFunc) {
                              Severity: Minor
                              Found in src/visualizations/summary.js - About 35 mins to fix

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

                                function handleError(error, vm, info) {
                                  let cur = vm;
                                  while ((cur = cur.$parent)) {
                                    const hooks = cur.$options.errorCaptured || [];
                                    for (const hook of hooks) if (hook.call(cur, error, vm, info) === false) break;
                                Severity: Minor
                                Found in src/mixins/asyncErrorCaptured.js - 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

                                Severity
                                Category
                                Status
                                Source
                                Language