PuzaTech/Fugue

View on GitHub

Showing 52 of 52 total issues

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

    public double likelihood(List<int[]> wordTopicCounts, List<int[]> docTopicBuffers, double[] alpha, double[] beta, double alphaSum, double betaSum) {
        double result_1 = 0.0;
        double result_2 = 0.0;

        // topics side likelihood
Severity: Minor
Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 45 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 logSumAll has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public double logSumAll(double[] x) {
        double maximum = 0;
        for (int i = 0; i < x.length; i++) {
            if (i == 0) {
                maximum = x[i];
Severity: Minor
Found in src/main/java/com/hongliangjie/fugue/utils/LogUtils.java - About 45 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 likelihood has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public double likelihood(List<int[]> wordTopicCounts, List<int[]> docTopicBuffers, double[] alpha, double[] beta, double alphaSum, double betaSum) {
Severity: Minor
Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - About 45 mins to fix

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

            return likelihood(modelPools.get(modelID).wordTopicCounts, modelPools.get(modelID).docTopicBuffers, modelPools.get(modelID).alpha, modelPools.get(modelID).beta, modelPools.get(modelID).alphaSum, modelPools.get(modelID).betaSum);
    Severity: Minor
    Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java and 1 other location - About 40 mins to fix
    src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java on lines 499..499

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

    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

                        double likelihood = likelihood(modelPools.get(modelID).wordTopicCounts, modelPools.get(modelID).docTopicBuffers, modelPools.get(modelID).alpha, modelPools.get(modelID).beta, modelPools.get(modelID).alphaSum, modelPools.get(modelID).betaSum);
    Severity: Minor
    Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java and 1 other location - About 40 mins to fix
    src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java on lines 332..332

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

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

        protected Sampler getSampler(String samplerStr){
            Sampler s = null;
            if (samplerStr != null) {
                if ("normal".equals(samplerStr)) {
                    s = new GibbsSampling();
    Severity: Minor
    Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - 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 rebuildIndex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public void rebuildIndex(){
            /* build index */
            LOGGER.info("Start to build index.");
            wordsForwardIndex = new HashMap<String, Integer>();
            wordsForwardIndex.clear();
    Severity: Minor
    Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - 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 initTrainModel has a Cognitive Complexity of 6 (exceeds 5 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 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

    Function load_raw has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_raw(args):
        input_f = open(args.input_file, 'r')
        docs = []
        for line in input_f:
            if line.strip()!='':
    Severity: Minor
    Found in src/main/python/tm.py - 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 setMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        @SuppressWarnings("unchecked")
        public void setMessage(Message m) {
            cmdArg = m;
            String randomGNRStr = cmdArg.getParam("random").toString();
    Severity: Minor
    Found in src/main/java/com/hongliangjie/fugue/topicmodeling/LDA/LDA.java - 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

    Function load_model has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_model(model_filename):
        json_file_content = ''
        input_f = open(model_filename, 'r')
        for line in input_f:
            json_file_content += line.strip()
    Severity: Minor
    Found in src/main/python/tm.py - 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 performTask has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public void performTask(){
    
            DataReader r = new DataReader();
            LOGGER.info("Start to read documents.");
            try {
    Severity: Minor
    Found in src/main/java/com/hongliangjie/fugue/topicmodeling/TopicModelDriver.java - 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