holderdeord/hdo-transcript-search

View on GitHub

Showing 56 of 95 total issues

Method parse_section has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_section(node)
        @current_node = node

        section = case node.name.downcase
                  when 'innlegg', 'hovedinnlegg', 'replikk'
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 renderPartyStats has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    renderPartyStats() {
        this.state.parties.sort((a, b) => a[this.props.unit] - b[this.props.unit]);
        let topParty = this.state.topParties[this.props.unit];

        if (!topParty) {
Severity: Minor
Found in webapp/src/frontend/components/ResultStats.js - About 1 hr to fix

    Method significant_terms_timeline has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def significant_terms_timeline(query = nil, algorithm = :mutual_information, size = 10)
        response = client.search(
          index: 'hdo-transcripts',
          type: 'speech',
          body: {
    Severity: Minor
    Found in scripts/significant_terms.rb - About 1 hr to fix

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

          render() {
              let services = this.props.services;
      
              if (!services.length) {
                  return null;
      Severity: Minor
      Found in webapp/src/frontend/components/RelatedServices.js - About 1 hr to fix

        Method build_slug_cache has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_slug_cache
                return unless @slug_cache.empty? || @id_to_person.empty?
        
                @logger.info "building name -> slug cache, id -> person cache"
        
        
        Severity: Minor
        Found in indexer/lib/hdo-transcript-indexer.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 _buildResponse has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _buildResponse(aggResponse) {
                let personMap = this._buildPersonMap(
                    aggResponse.aggregations.filteredPeople.people
                );
        
        
        Severity: Minor
        Found in webapp/src/backend/search-api.js - About 1 hr to fix

          Method build_slug_cache has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def build_slug_cache
                  return unless @slug_cache.empty? || @id_to_person.empty?
          
                  @logger.info "building name -> slug cache, id -> person cache"
          
          
          Severity: Minor
          Found in indexer/lib/hdo-transcript-indexer.rb - About 1 hr to fix

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

            function topSearches(params) {
                return getAnalytics()
                    .then(an => {
                        return an.data.ga.getAsync({
                            ids: GA_ID,
            Severity: Minor
            Found in webapp/src/backend/analytics.js - About 1 hr to fix

              Function analytics has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function analytics(state = null, action) {
                  switch (action.type) {
                      case SUMMARY:
                          ga(
                              'send',
              Severity: Minor
              Found in webapp/src/frontend/reducers/analytics.js - About 1 hr to fix

                Method initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def initialize(options)
                        @data_dir     = data_dir_from(options)
                        @sessions     = options.fetch(:sessions)
                        @faraday      = Faraday.new('http://data.stortinget.no')
                        @logger       = Logger.new(STDOUT)
                Severity: Minor
                Found in indexer/lib/hdo-transcript-indexer.rb - About 1 hr to fix

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

                      render() {
                          if (!this.props.visible) {
                              return null;
                          }
                  
                  
                  Severity: Minor
                  Found in webapp/src/frontend/components/DevPanel.js - About 1 hr to fix

                    Method timeline_for has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def timeline_for(word)
                        response = client.search(
                          index: 'hdo-transcripts',
                          type: 'speech',
                          body: {
                    Severity: Minor
                    Found in scripts/significant_terms.rb - About 1 hr to fix

                      Method parse_speech has 32 lines of code (exceeds 25 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

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

                            render() {
                                return (
                                    <form className="row" id="search-form" onSubmit={::this.handleSearch}>
                                        <div className="col-md-6 col-md-offset-3">
                                            <div
                        Severity: Minor
                        Found in webapp/src/frontend/components/SearchForm.js - About 1 hr to fix

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

                              render() {
                                  let focusedIndex = +this.props.params.focused;
                                  let unit = this.props.params.unit || 'pct';
                          
                                  return (
                          Severity: Minor
                          Found in webapp/src/frontend/components/Search.js - About 1 hr to fix

                            Method extract_entities has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                  def extract_entities(section)
                                    r, w = IO.pipe
                            
                                    process = ChildProcess.build("python", NER_SCRIPT)
                                    process.duplex = true
                            Severity: Minor
                            Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 1 hr to fix

                              Function renderPeopleStats has a Cognitive Complexity of 10 (exceeds 5 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: Minor
                              Found in webapp/src/frontend/components/ResultStats.js - 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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  render() {
                                      let unit = this.props.unit;
                                      let counts = this.props.counts;
                              
                                      if (this.props.sort) {
                              Severity: Minor
                              Found in webapp/src/frontend/components/TopListChart.js - 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 matchMedia has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              window.matchMedia || (window.matchMedia = function() {
                                  "use strict";
                              
                                  // For browsers that support matchMedium api such as IE 9 and webkit
                                  var styleMedia = (window.styleMedia || window.media);
                              Severity: Minor
                              Found in webapp/public/matchMedia.js - About 1 hr to fix

                                Method index_file has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      def index_file(file)
                                        transcript_id = file.basename.to_s.sub(file.extname, '')
                                        data          = JSON.parse(file.read)
                                        presidents    = data['presidents'].map { |e| {name: e, external_id: @slug_cache[e]} }
                                        session       = data['session']
                                Severity: Minor
                                Found in indexer/lib/hdo-transcript-indexer.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language