LearnPAd/learnpad

View on GitHub
lp-ontology-recommender/src/main/resources/gate/plugins/Ontology/src/gate/creole/ontology/impl/sesame/SesameManager.java

Summary

Maintainability
F
3 days
Test Coverage

File SesameManager.java has 640 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 *  SesameManager.java
 *
 *  Copyright (c) 1995-2012, The University of Sheffield. See the file
 *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt

    SesameManager has 38 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class SesameManager {
      private RepositoryConnection mRepositoryConnection;
      private Repository           mRepository;
      private RepositoryManager    mRepositoryManager;
      private String               mRepositoryLocation;

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

        public void createUnmanagedRepository(File repositoryDirFile, String configstring) {
          isManagedRepository = false;
          logger.debug("SesameManager: creating unmanaged repo, dir is "+repositoryDirFile.getAbsolutePath());
          ValueFactory vf = new MemValueFactory();
          Graph graph = parseRdf(configstring, vf, RDFFormat.TURTLE);

        Method createRepository has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public void createRepository(String config) {
            logger.debug("createRepository called");
            if(mRepositoryManager == null) {
              throw new SesameManagerException("No connect prior to createRepository");
            }

          Method openRepository has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            public void openRepository(String name) {
              logger.debug("Called openRespository with ID "+name);
              if(mRepositoryManager != null) {
                try {
                  mRepository = mRepositoryManager.getRepository(name);

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

            public gate.creole.ontology.Literal convertSesameLiteral2Literal(
                org.openrdf.model.Literal sesameLiteral) {
              URI sesame_datatype = sesameLiteral.getDatatype();
              String sesame_lang = sesameLiteral.getLanguage();
              

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

            public void createRepository(String config) {
              logger.debug("createRepository called");
              if(mRepositoryManager == null) {
                throw new SesameManagerException("No connect prior to createRepository");
              }

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

            public org.openrdf.model.Resource toSesameResource(ONodeID node) {
              Resource r = null;
              if (node != null) {
                if (node.isAnonymousResource()) {
                  String id = node.toString();

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

            public static String substituteConfigTemplate(String configtemplate, Map<String,String> variables) {
              // replace all variables in the template then do the actual createRepository
              StringBuffer result = new StringBuffer(configtemplate.length()*2);
              Matcher matcher = TOKEN_PATTERN.matcher(configtemplate);
                  while (matcher.find()) {

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

            public void deleteRepository(String name) {
              if(mRepositoryManager != null) {
                closeRepository();
                try {
                  boolean done = mRepositoryManager.removeRepositoryConfig(name);

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

            public org.openrdf.model.Literal toSesameLiteral(gate.creole.ontology.Literal literal) {
              org.openrdf.model.Literal l = null;
              if (literal != null) {
                if (literal.getLanguage() != null && !literal.getLanguage().getLanguage().equals("")) {
                  l = mRepositoryConnection.

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

            public void importIntoRepository(File from, String baseURI, String format) {
              if(mRepositoryConnection != null) {
                RDFFormat sesameFormat = RDFFormat.valueOf(format);
                if(sesameFormat==null) {
                  throw new SesameManagerException(

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

              private Repository createRepositoryStack(RepositoryImplConfig config) {
                  RepositoryFactory factory = RepositoryRegistry.getInstance().get(config.getType());
                  if (factory == null) {
                      throw new SesameManagerException("Unsupported repository type: " + config.getType());
                  }

          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

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

            public void importIntoRepository(Reader from, String baseURI, String format) {
              if(mRepositoryConnection != null) {
                RDFFormat sesameFormat = RDFFormat.valueOf(format);
                try {
                  mRepositoryConnection.add(from,baseURI,sesameFormat);
          lp-ontology-recommender/src/main/resources/gate/plugins/Ontology/src/gate/creole/ontology/impl/sesame/SesameManager.java on lines 650..661

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

          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

            public void importIntoRepository(InputStream from, String baseURI, String format) {
              if(mRepositoryConnection != null) {
                RDFFormat sesameFormat = RDFFormat.valueOf(format);
                try {
                  mRepositoryConnection.add(from,baseURI,sesameFormat);
          lp-ontology-recommender/src/main/resources/gate/plugins/Ontology/src/gate/creole/ontology/impl/sesame/SesameManager.java on lines 670..681

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

          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

              public void printStackTrace(java.io.PrintStream s) {
                s.flush();
                super.printStackTrace(s);
                Throwable cause = getCause();
                if (cause != null) {
          lp-ontology-recommender/src/main/resources/gate/plugins/Ontology/src/gate/creole/ontology/impl/sesame/SesameManager.java on lines 146..154

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

          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

              public void printStackTrace(java.io.PrintWriter s) {
                s.flush();
                super.printStackTrace(s);
                Throwable cause = getCause();
                if (cause != null) {
          lp-ontology-recommender/src/main/resources/gate/plugins/Ontology/src/gate/creole/ontology/impl/sesame/SesameManager.java on lines 133..141

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

          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

            public BooleanQuery createAskQuery(String query) {
              if(mRepositoryConnection != null) {
                try {
                  return mRepositoryConnection.prepareBooleanQuery(QueryLanguage.SPARQL, query);
                } catch (Exception ex) {
          lp-ontology-recommender/src/main/resources/gate/plugins/Ontology/src/gate/creole/ontology/impl/sesame/SesameManager.java on lines 712..722

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

          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

            public Update createUpdate(String query) {
              if(mRepositoryConnection != null) {
                try {
                  return mRepositoryConnection.prepareUpdate(QueryLanguage.SPARQL, query);
                } catch (Exception ex) {
          lp-ontology-recommender/src/main/resources/gate/plugins/Ontology/src/gate/creole/ontology/impl/sesame/SesameManager.java on lines 700..710

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

          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

          There are no issues that match your filters.

          Category
          Status