ActivityWatch/aw-webui

View on GitHub

Showing 37 of 37 total issues

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

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

import { window_events } from '~/util/fakedata';
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 ensure_loaded has a Cognitive Complexity of 18 (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 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

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

            for (let i = 0; i < count; i++) {
              const start = moment(timeperiod.start)
                .add(i * _length[0], _length[1] as moment.unitOfTime.DurationConstructor)
                .format();
              periods.push({ start, length: _length });
          Severity: Major
          Found in src/util/timeperiod.ts and 1 other location - About 2 hrs to fix
          src/util/timeperiod.ts on lines 69..74

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

          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

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

            for (let i = 0; i < 24; i++) {
              const start = moment(timeperiod.start)
                .add(i * _length[0], _length[1] as moment.unitOfTime.DurationConstructor)
                .format();
              periods.push({ start, length: _length });
          Severity: Major
          Found in src/util/timeperiod.ts and 1 other location - About 2 hrs to fix
          src/util/timeperiod.ts on lines 90..95

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

          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 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 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 42 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

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

                      timeline
                        .append('text')
                        .attr('x', '0')
                        .attr('y', '3')
                        .text(text)
                    Severity: Major
                    Found in src/visualizations/timeline-simple.js and 2 other locations - About 1 hr to fix
                    src/visualizations/summary.js on lines 28..35
                    src/visualizations/timeline.js on lines 61..68

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

                    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

                      timeline
                        .append('text')
                        .attr('x', '0')
                        .attr('y', '3')
                        .text(text)
                    Severity: Major
                    Found in src/visualizations/timeline.js and 2 other locations - About 1 hr to fix
                    src/visualizations/summary.js on lines 28..35
                    src/visualizations/timeline-simple.js on lines 24..31

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

                    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

                      svg
                        .append('text')
                        .attr('x', '0px')
                        .attr('y', '25px')
                        .text(msg)
                    Severity: Major
                    Found in src/visualizations/summary.js and 2 other locations - About 1 hr to fix
                    src/visualizations/timeline-simple.js on lines 24..31
                    src/visualizations/timeline.js on lines 61..68

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

                    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 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 buildBarchartDataset has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function buildBarchartDataset(
                          $store: any,
                          data_by_hour: HourlyData[],
                          classes: Category[]
                        ): Dataset[] {
                        Severity: Minor
                        Found in src/util/datasets.ts - 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 buildBarchartDataset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export function buildBarchartDataset(
                            $store: any,
                            data_by_hour: HourlyData[],
                            classes: Category[]
                          ): Dataset[] {
                          Severity: Minor
                          Found in src/util/datasets.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

                          Severity
                          Category
                          Status
                          Source
                          Language