holderdeord/hdo-transcript-search

View on GitHub

Showing 95 of 95 total issues

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

app.get('/api/stats/lix', (req, res) => {
    api.getLixStats()
        .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 221..226
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

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

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

                                                timeline: {
                                                    date_histogram: {
                                                        field: 'time',
                                                        interval: 'year',
                                                        time_zone: 'Europe/Oslo',
                Severity: Major
                Found in webapp/src/backend/search-api.js and 1 other location - About 1 hr to fix
                webapp/src/backend/search-api.js on lines 277..293

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

                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

                                        timeline: {
                                            date_histogram: {
                                                field: 'time',
                                                interval: 'year',
                                                time_zone: 'Europe/Oslo',
                Severity: Major
                Found in webapp/src/backend/search-api.js and 1 other location - About 1 hr to fix
                webapp/src/backend/search-api.js on lines 203..219

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

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

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

                                            <div>
                                                Referater fra{' '}
                                                <a href="http://data.stortinget.no">
                                                    data.stortinget.no
                                                </a>{' '}
                    Severity: Major
                    Found in webapp/src/frontend/components/Footer.js and 1 other location - About 1 hr to fix
                    webapp/src/frontend/components/Footer.js on lines 23..32

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

                    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

                                            <div>
                                                Kildekode på{' '}
                                                <a href="https://github.com/holderdeord/hdo-transcript-search">
                                                    GitHub
                                                </a>{' '}
                    Severity: Major
                    Found in webapp/src/frontend/components/Footer.js and 1 other location - About 1 hr to fix
                    webapp/src/frontend/components/Footer.js on lines 15..22

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

                    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

                    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

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

                              case HITS:
                                  ga(
                                      'send',
                                      'event',
                                      'hits',
                      Severity: Major
                      Found in webapp/src/frontend/reducers/analytics.js and 1 other location - About 1 hr to fix
                      webapp/src/frontend/reducers/analytics.js on lines 7..18

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

                      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

                                      <div className="row navigation-links">
                                          <div className="col-xs-6 col-md-6">{prevLink}</div>
                                          <div className="col-xs-6 col-md-6 text-right">{nextLink}</div>
                                      </div>
                      Severity: Major
                      Found in webapp/src/frontend/components/SpeechInContext.js and 1 other location - About 1 hr to fix
                      webapp/src/frontend/components/SpeechInContext.js on lines 68..71

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

                      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

                                      <div className="row navigation-links">
                                          <div className="col-xs-6 col-md-6">{prevLink}</div>
                                          <div className="col-xs-6 col-md-6 text-right">{nextLink}</div>
                                      </div>
                      Severity: Major
                      Found in webapp/src/frontend/components/SpeechInContext.js and 1 other location - About 1 hr to fix
                      webapp/src/frontend/components/SpeechInContext.js on lines 52..55

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

                      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

                              case SUMMARY:
                                  ga(
                                      'send',
                                      'event',
                                      'summary',
                      Severity: Major
                      Found in webapp/src/frontend/reducers/analytics.js and 1 other location - About 1 hr to fix
                      webapp/src/frontend/reducers/analytics.js on lines 19..30

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

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

                      Severity
                      Category
                      Status
                      Source
                      Language