holderdeord/hdo-transcript-search

View on GitHub

Showing 56 of 95 total issues

File search-api.js has 481 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable camelcase */

import Promise from 'bluebird';
import LRU from 'lru-cache';
import es from './es-client';
Severity: Minor
Found in webapp/src/backend/search-api.js - About 7 hrs to fix

    File converter.rb has 420 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'time'
    require 'set'
    require 'hashie/mash'
    require 'hdo/storting_importer'
    require 'childprocess'
    Severity: Minor
    Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 6 hrs to fix

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

          render() {
              const {
                  scoreStats,
                  parties,
                  timeline,
      Severity: Major
      Found in webapp/src/frontend/components/Lix.js - About 5 hrs to fix

        Function getLixStats has 119 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getLixStats() {
                return es
                    .search({
                        index: INDEX_NAME,
                        type: INDEX_TYPE,
        Severity: Major
        Found in webapp/src/backend/search-api.js - About 4 hrs to fix

          Method parse_name_string has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

                def parse_name_string(str, person)
                  result = Hashie::Mash.new
                  orig = str
                  str = clean_name_string(str)
          
          
          Severity: Minor
          Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 4 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 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              render() {
                  let speech = this.props.speech;
                  let timestamp = TimeUtils.timestampForHit(speech);
                  let title = speech.title;
          
          
          Severity: Major
          Found in webapp/src/frontend/components/Speech.js - About 3 hrs to fix

            Method parse_name_string has 88 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def parse_name_string(str, person)
                    result = Hashie::Mash.new
                    orig = str
                    str = clean_name_string(str)
            
            
            Severity: Major
            Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 3 hrs to fix

              Class Converter has 27 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class Converter
                    class << self
                      def parse(file, options = {})
                        case file
                        when /s(\d{2})(\d{2})(\d{2}).*\.xml$/i
              Severity: Minor
              Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 3 hrs to fix

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

                    render() {
                        let unit = this.props.unit;
                        let counts = this.props.counts;
                
                        if (this.props.sort) {
                Severity: Major
                Found in webapp/src/frontend/components/TopListChart.js - About 2 hrs to fix

                  Function _buildAggregationsQuery has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      _buildAggregationsQuery(opts) {
                          var query = this._queryFor(opts.query);
                  
                          var aggregations = {
                              timeline: {
                  Severity: Major
                  Found in webapp/src/backend/search-api.js - About 2 hrs to fix

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

                        render() {
                            if (this.state.queries.length) {
                                this.chartOptions.axisY.onlyInteger = this.props.unit === 'count';
                    
                                return (
                    Severity: Major
                    Found in webapp/src/frontend/components/Timeline.js - About 2 hrs to fix

                      File hdo-transcript-indexer.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require 'nokogiri'
                      require 'pathname'
                      require 'uri'
                      require 'logger'
                      require 'json'
                      Severity: Minor
                      Found in indexer/lib/hdo-transcript-indexer.rb - About 2 hrs to fix

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

                            render() {
                                let result = this.getFocusedHitSet();
                        
                                if (!result) {
                                    return null;
                        Severity: Major
                        Found in webapp/src/frontend/components/SearchResults.js - About 2 hrs to fix

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

                              renderPeopleStats() {
                                  let people = this.state.people[this.props.unit] || [];
                                  let isPct = this.props.unit === 'pct';
                          
                                  people = people.slice(0, 8);
                          Severity: Major
                          Found in webapp/src/frontend/components/ResultStats.js - About 2 hrs to fix

                            Function createFeed has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export default function createFeed(opts) {
                                let { baseUrl, imageUrl, absoluteUrl, results, query } = opts;
                                let links = {};
                            
                                let start = +(query.start || 0);
                            Severity: Major
                            Found in webapp/src/backend/createFeed.js - About 2 hrs to fix

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

                                  render() {
                                      let speeches = this.props.speeches;
                              
                                      if (!speeches.length) {
                                          return null;
                              Severity: Major
                              Found in webapp/src/frontend/components/SpeechInContext.js - About 2 hrs to fix

                                Function _setupAnimation has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    _setupAnimation() {
                                        //
                                        // http://gionkunz.github.io/chartist-js/examples.html#advanced-smil-animations
                                        //
                                
                                
                                Severity: Minor
                                Found in webapp/src/frontend/components/BaseChart.js - About 2 hrs to fix

                                  Method parse_speech has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                        def parse_speech(node)
                                          name_nodes = node.css('navn, Navn')
                                          name_str = name_nodes.text
                                          text     = clean_text(text_from(node))
                                  
                                  
                                  Severity: Minor
                                  Found in indexer/lib/hdo-transcript-indexer/converter.rb - 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 render has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      render() {
                                          return (
                                              <footer>
                                                  <a href="https://www.holderdeord.no/">
                                                      <img className="logo" src="/logo.png" />
                                  Severity: Minor
                                  Found in webapp/src/frontend/components/Footer.js - About 1 hr to fix

                                    Function getHitStream has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        getHitStream(opts) {
                                            let delimiter = opts.format === 'csv' ? ',' : '\t';
                                            let scrollId = null;
                                            let tsvHeaders = TSV_HEADERS;
                                            if (opts.extra_fields) {
                                    Severity: Minor
                                    Found in webapp/src/backend/search-api.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language