holderdeord/hdo-transcript-search

View on GitHub

Showing 95 of 95 total issues

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

app.get('/api/analytics/browsers/:days?', (req, res) => {
    analytics
        .browsers({ days: req.params.days || 30 })
        .then(d => res.json(d))
        .catch(errorHandler.bind(res));
Severity: Major
Found in webapp/src/backend/app.js and 1 other location - About 2 hrs to fix
webapp/src/backend/app.js on lines 228..233

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

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 2 locations. Consider refactoring.
Open

app.get('/api/analytics/sources/:days?', (req, res) => {
    analytics
        .sources({ days: req.params.days || 30 })
        .then(d => res.json(d))
        .catch(errorHandler.bind(res));
Severity: Major
Found in webapp/src/backend/app.js and 1 other location - About 2 hrs to fix
webapp/src/backend/app.js on lines 242..247

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

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

                    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

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

                            app.get('/api/analytics/image-errors', (req, res) => {
                                analytics
                                    .imageErrors()
                                    .then(d => res.json(d))
                                    .catch(errorHandler.bind(res));
                            Severity: Major
                            Found in webapp/src/backend/app.js and 2 other locations - About 1 hr to fix
                            webapp/src/backend/app.js on lines 201..205
                            webapp/src/backend/app.js on lines 235..240

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

                            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

                            app.get('/api/analytics/active', (req, res) => {
                                analytics
                                    .active()
                                    .then(d => res.json(d))
                                    .catch(errorHandler.bind(res));
                            Severity: Major
                            Found in webapp/src/backend/app.js and 2 other locations - About 1 hr to fix
                            webapp/src/backend/app.js on lines 201..205
                            webapp/src/backend/app.js on lines 221..226

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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language