PuzaTech/Fugue

View on GitHub

Showing 35 of 52 total issues

File LDA.java has 728 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package com.hongliangjie.fugue.topicmodeling.LDA;

import com.google.gson.Gson;
import com.hongliangjie.fugue.Message;
import com.hongliangjie.fugue.distributions.MultinomialDistribution;
Severity: Major
Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 1 day to fix

    Method optimize has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

            @Override
            public void optimize() {
                double[] alpha = new double[modelPools.get(0).alpha.length];
                double alphaSum = modelPools.get(0).alphaSum;
                double[] beta = new double[modelPools.get(0).beta.length];
    Severity: Minor
    Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 5 hrs 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 logGamma has 110 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static final double logGamma (double x)
        {
            double result;
            double y;
            double xnum;
    Severity: Major
    Found in src/main/java/com/hongliangjie/fugue/utils/LogGamma.java - About 4 hrs to fix

      Method initTestModels has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          public void initTestModels(){
              for (ModelCountainer m : modelPools){
                  m.beta = new double[m.outsideBeta.size()];
                  for (int v = 0; v < m.outsideBeta.size(); v++ ){
                      // this is the default value
      Severity: Minor
      Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 3 hrs 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 logGamma has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          public static final double logGamma (double x)
          {
              double result;
              double y;
              double xnum;
      Severity: Minor
      Found in src/main/java/com/hongliangjie/fugue/utils/LogGamma.java - About 3 hrs 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 optimize has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              @Override
              public void optimize() {
                  double[] alpha = new double[modelPools.get(0).alpha.length];
                  double alphaSum = modelPools.get(0).alphaSum;
                  double[] beta = new double[modelPools.get(0).beta.length];
      Severity: Major
      Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 2 hrs to fix

        Method sampleTestDoc has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

                protected void sampleTestDoc(List<Document> docs, int maxIter, int docIndex) {
                    // for each test document, half of the document is used to "fold-in" and the other half is used to compute "perplexity"
                    for (int m = 0; m < modelPools.size(); m++) {
                        docTopicAssignment = new ArrayList<Integer>();
                        docTopicBuffer = new int[TOPIC_NUM];
        Severity: Minor
        Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 2 hrs 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 read has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public Message read(Message m) throws IOException {
                String inputFile = m.getParam("inputFile").toString();
                Integer top = Integer.parseInt(m.getParam("topk").toString());
        
                if (top == null)
        Severity: Minor
        Found in src/main/java/com/hongliangjie/fugue/io/DataReader.java - About 2 hrs 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 load_models has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def load_models(args):
            files = args.model_file.split(',')
            topicsOrders = {}
            N = 0
            for file in files:
        Severity: Minor
        Found in src/main/python/tm.py - About 2 hrs 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 parse_docs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def parse_docs(dictionary, args):
            input_f = open(args.input_file, 'r')
            output_f = open(args.output_file,'w')
            doc_id = 0
            for line in input_f:
        Severity: Minor
        Found in src/main/python/tm.py - About 2 hrs 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 initTestModels has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public void initTestModels(){
                for (ModelCountainer m : modelPools){
                    m.beta = new double[m.outsideBeta.size()];
                    for (int v = 0; v < m.outsideBeta.size(); v++ ){
                        // this is the default value
        Severity: Minor
        Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 2 hrs to fix

          Method sampleOverDocs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                  public void sampleOverDocs(int modelID, List<Document> docs, int start, int end, int maxIter, int save){
                      int overall_pos = 0;
                      long overall_startTime = System.currentTimeMillis();
                      for (CURRENT_ITER = 0; CURRENT_ITER < maxIter; CURRENT_ITER++) {
                          LOGGER.info("Start to Iteration " + CURRENT_ITER);
          Severity: Minor
          Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - 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 initTrainModel has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected void initTrainModel() {
                  rebuildIndex();
                  LOGGER.info("Start to initialize model.");
                  LOGGER.info("Topic Num:" + TOPIC_NUM);
                  LOGGER.info("ForwardIndex Size:" + wordsForwardIndex.size());
          Severity: Minor
          Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 1 hr to fix

            Method sampleOverDocs has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public void sampleOverDocs(int modelID, List<Document> docs, int start, int end, int maxIter, int save){
                        int overall_pos = 0;
                        long overall_startTime = System.currentTimeMillis();
                        for (CURRENT_ITER = 0; CURRENT_ITER < maxIter; CURRENT_ITER++) {
                            LOGGER.info("Start to Iteration " + CURRENT_ITER);
            Severity: Minor
            Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 1 hr to fix

              Function compute_term_stats has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              def compute_term_stats(docs, args = None):
                  """
                  This function is to compute TF and DF stats
                  :param docs:
                  :return: a return obj with tf and df
              Severity: Minor
              Found in src/main/python/tm.py - 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 sampleTestDoc has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      protected void sampleTestDoc(List<Document> docs, int maxIter, int docIndex) {
                          // for each test document, half of the document is used to "fold-in" and the other half is used to compute "perplexity"
                          for (int m = 0; m < modelPools.size(); m++) {
                              docTopicAssignment = new ArrayList<Integer>();
                              docTopicBuffer = new int[TOPIC_NUM];
              Severity: Minor
              Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 1 hr to fix

                Method read has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public Message read(Message m) throws IOException {
                        String inputFile = m.getParam("inputFile").toString();
                        Integer top = Integer.parseInt(m.getParam("topk").toString());
                
                        if (top == null)
                Severity: Minor
                Found in src/main/java/com/hongliangjie/fugue/io/DataReader.java - About 1 hr to fix

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

                      protected static Message parseOptions(Options options, String[] args) {
                          // create the parser
                          Message cmd = defaultMessage();
                          CommandLineParser parser = new DefaultParser();
                          try {
                  Severity: Minor
                  Found in src/main/java/com/hongliangjie/fugue/MainEntrance.java - About 1 hr to fix

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

                        protected static Options createOptions(){
                    
                            Options options = new Options();
                    
                            Option inputFileOption = Option.builder().longOpt("inputFile").desc("the input file").hasArg().argName("inputFile").build();
                    Severity: Minor
                    Found in src/main/java/com/hongliangjie/fugue/MainEntrance.java - About 1 hr to fix

                      Method loadModel has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          @SuppressWarnings("unchecked")
                          public void loadModel() throws IOException {
                              int multipleModels = Integer.parseInt(cmdArg.getParam("multipleModels").toString());
                              String[] modelFileNames = null;
                              LOGGER.info("Load Multiple Test Models:" + multipleModels);
                      Severity: Minor
                      Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language