social-snippet/social-snippet

View on GitHub

Showing 21 of 21 total issues

File test_storage.rb has 385 lines of code (exceeds 250 allowed). Consider refactoring.
Open

RSpec.configure do

  shared_context :TestStorage do

    describe "test storage class" do
Severity: Minor
Found in lib/social_snippet/rspec/test_storage.rb - About 5 hrs to fix

    Class YAMLDocument has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class YAMLDocument
    
        @@path = nil
    
        require_relative "yaml_document/query"
    Severity: Minor
    Found in lib/social_snippet/document_backend/yaml_document.rb - About 4 hrs to fix

      Class Tag has 31 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class SocialSnippet::Tag
      
        attr_reader :path
        attr_reader :repo
        attr_reader :ref
      Severity: Minor
      Found in lib/social_snippet/tag.rb - About 3 hrs to fix

        Class RepositoryManager has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class RepositoryManager
        
            attr_reader :core
        
            # Constructor
        Severity: Minor
        Found in lib/social_snippet/repository/repository_manager.rb - About 2 hrs to fix

          Class Config has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class SocialSnippet::Config
          
            attr_reader :core
            attr_reader :home
            attr_reader :fields
          Severity: Minor
          Found in lib/social_snippet/config.rb - About 2 hrs to fix

            Class Command has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class SocialSnippet::CommandLine::Command
            
              attr_reader :args
              attr_reader :tokens
              attr_reader :options
            Severity: Minor
            Found in lib/social_snippet/command_line/command.rb - About 2 hrs to fix

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

                        context "glob /path/to/**/*.rb" do
                          subject { storage.glob "/path/to/**/*.rb" }
                          it { expect(subject.length).to eq 2 } 
                          it { should_not include "/path/to/" }
                          it { should_not include "/path/to/dir2" }
              Severity: Major
              Found in lib/social_snippet/rspec/test_storage.rb and 1 other location - About 1 hr to fix
              lib/social_snippet/rspec/test_storage.rb on lines 219..232

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

              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

                        context "glob /path/to/dir2/**/*.rb" do
                          subject { storage.glob "/path/to/dir2/**/*.rb" }
                          it { expect(subject.length).to eq 2 } 
                          it { should_not include "/path/to/" }
                          it { should_not include "/path/to/dir2" }
              Severity: Major
              Found in lib/social_snippet/rspec/test_storage.rb and 1 other location - About 1 hr to fix
              lib/social_snippet/rspec/test_storage.rb on lines 203..216

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

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

                        context "glob /path/to/dir2/**/*.c" do
                          subject { storage.glob "/path/to/dir2/**/*.c" }
                          it { expect(subject.length).to eq 2 } 
                          it { should_not include "/path/to/" }
                          it { should_not include "/path/to/dir2" }
              Severity: Major
              Found in lib/social_snippet/rspec/test_storage.rb and 3 other locations - About 1 hr to fix
              lib/social_snippet/rspec/test_storage.rb on lines 147..158
              lib/social_snippet/rspec/test_storage.rb on lines 161..172
              lib/social_snippet/rspec/test_storage.rb on lines 189..200

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

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

                        context "glob /path/to/**/*.c" do
                          subject { storage.glob "/path/to/**/*.c" }
                          it { expect(subject.length).to eq 5 } 
                          it { should_not include "/path/to/" }
                          it { should_not include "/path/to/dir2" }
              Severity: Major
              Found in lib/social_snippet/rspec/test_storage.rb and 3 other locations - About 1 hr to fix
              lib/social_snippet/rspec/test_storage.rb on lines 147..158
              lib/social_snippet/rspec/test_storage.rb on lines 175..186
              lib/social_snippet/rspec/test_storage.rb on lines 189..200

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

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

                        context "glob /path/to/*.c" do
                          subject { storage.glob "/path/to/*.c" }
                          it { expect(subject.length).to eq 1 } 
                          it { should_not include "/path/to/" }
                          it { should_not include "/path/to/dir2" }
              Severity: Major
              Found in lib/social_snippet/rspec/test_storage.rb and 3 other locations - About 1 hr to fix
              lib/social_snippet/rspec/test_storage.rb on lines 161..172
              lib/social_snippet/rspec/test_storage.rb on lines 175..186
              lib/social_snippet/rspec/test_storage.rb on lines 189..200

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

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

                        context "glob /path/to/**/*.cpp" do
                          subject { storage.glob "/path/to/**/*.cpp" }
                          it { expect(subject.length).to eq 1 } 
                          it { should_not include "/path/to/" }
                          it { should_not include "/path/to/dir2" }
              Severity: Major
              Found in lib/social_snippet/rspec/test_storage.rb and 3 other locations - About 1 hr to fix
              lib/social_snippet/rspec/test_storage.rb on lines 147..158
              lib/social_snippet/rspec/test_storage.rb on lines 161..172
              lib/social_snippet/rspec/test_storage.rb on lines 175..186

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

              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 resolve_tag_repo_ref! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def resolve_tag_repo_ref!(tag)
                    return unless tag.has_repo?
                    repo = core.repo_manager.find_repository(tag.repo)
                    # set latest version
                    if tag.has_ref? === false
              Severity: Minor
              Found in lib/social_snippet/resolvers/base_resolver.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

              Method insert_func has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def insert_func(snippet, context_from, base_tag = nil)
                    raise "must be passed snippet" unless snippet.is_a?(Snippet)
              
                    inserter = Inserter.new(snippet.lines)
                    context = context_from.clone
              Severity: Minor
              Found in lib/social_snippet/resolvers/insert_resolver.rb - About 35 mins 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

              Method each_child_snippet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def each_child_snippet(snippet, context, base_tag)
                    raise "must be passed snippet" unless snippet.is_a?(Snippet)
              
                    snippet.snip_tags.each do |tag_info|
                      t = tag_info[:tag].set_by_tag(base_tag)
              Severity: Minor
              Found in lib/social_snippet/resolvers/base_resolver.rb - About 35 mins 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

              Method insert_depended_snippets! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def insert_depended_snippets!(inserter, snippet, context, tag)
                    raise "must be passed snippet" unless snippet.is_a?(Snippet)
              
                    dep_tags = deps_resolver.find(snippet, context, tag)
                    dep_tags = sort_dep_tags_by_dep(dep_tags)
              Severity: Minor
              Found in lib/social_snippet/resolvers/insert_resolver.rb - About 35 mins 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

              Method field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def field(sym, options = {})
                      @field_keys ||= ::Set.new
                      @default_field ||= ::Hash.new
                      @field_type ||= ::Hash.new
              
              
              Severity: Minor
              Found in lib/social_snippet/document_backend/yaml_document.rb - About 25 mins 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

              Method move_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def move_path(new_path)
                  source = dirname.split("/")
                  dest = new_path.split("/")
                  destname = dest.pop
              
              
              Severity: Minor
              Found in lib/social_snippet/context.rb - About 25 mins 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

              Method find_func has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def find_func(snippet, context_from, tag_from)
                    raise "must be passed snippet" unless snippet.is_a?(Snippet)
              
                    found_tags = []
                    context = context_from.clone
              Severity: Minor
              Found in lib/social_snippet/resolvers/dep_resolver.rb - About 25 mins 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

              Method run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run
                    if has_next_token?
                      s = next_token
                      if has_next_token?
                        key = s
              Severity: Minor
              Found in lib/social_snippet/command_line/sspm/sub_commands/config_command.rb - About 25 mins 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