newsgac/platform

View on GitHub

Showing 22 of 74 total issues

Function initComponents has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function initComponents() {
        Vue.component("document-field", {
            props: ["param", "value"],
            template: `
                <div>
Severity: Major
Found in newsgac/templates/pipelines/scripts.js - About 3 hrs to fix

    Function get_sk_pipeline has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_sk_pipeline(pipeline):
        """
        Transform our `newsgac.pipelines.models.Pipeline` into a Scikit Learn `sklearn.pipeline.Pipeline`
        """
        if type(pipeline.nlp_tool) == TFIDF:
    Severity: Minor
    Found in newsgac/pipelines/get_sk_pipeline.py - 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

    Function get_pipeline_step has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_pipeline_step(step, label='', from_label=None, to_label=None):
        output = ''
        if isinstance(step[1], SKPipeline):
            for i, sub_step in enumerate(step[1].steps):
                output += get_pipeline_step(
    Severity: Minor
    Found in newsgac/pipelines/views.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 get_frog_features has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_frog_features(tokens, text):
        features = {}
    
        # Token count
        # token_count = len(tokens)
    Severity: Minor
    Found in newsgac/nlp_tools/models/frog_extract_features.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

    Function explain_article_lime_task_impl has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def explain_article_lime_task_impl(view_cache_id, ace_id, pipeline_id, article_number):
        ace = ACE.objects.get({'_id': ObjectId(ace_id)})
        pipeline = Pipeline.objects.get({'_id': ObjectId(pipeline_id)})
    
        article_number = int(article_number)
    Severity: Minor
    Found in newsgac/ace/tasks.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

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

    def svc_feature_weights(pipeline, top_features=10):
        sk_pipeline = pipeline.sk_pipeline.get()
        classifier = sk_pipeline.named_steps['Classifier']
        if classifier.kernel != 'linear':
            raise TypeError("SVC features: Can only plot feature weights for linear kernel.")
    Severity: Minor
    Found in newsgac/pipelines/plots.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

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

        def delete_objects(self):
            def delete_objects_in_field(instance):
                for field in instance._mongometa.get_fields():
                    obj = getattr(instance, field.attname)
                    if obj:
    Severity: Minor
    Found in newsgac/common/mixins.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

    Function parse_article has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_article(article_str):
            if isinstance(article_str, bytes):
                article_str = article_str.decode('utf-8')
            article = Article()
            # line = article_str.rstrip().decode('utf-8')
    Severity: Minor
    Found in newsgac/data_sources/parsers/newsgac.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

    Function parameter_dict has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def parameter_dict(cls):
            # create a json serializable dict of the parameters definition of this class
            def map_field(field):
                result_field_dict = {'type': field.__class__.__name__}
                field_dict = field.__dict__
    Severity: Minor
    Found in newsgac/common/mixins.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

    Function remove_cls_from_dict has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove_cls_from_dict(model_dict):
        """
        Remove _cls keys from dict representations of models (they are added by pymodm to_son())
        :param model_dict: the dict representation of a model still containing _cls keys
        """
    Severity: Minor
    Found in newsgac/common/utils.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

    Function get_frog_features has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def get_frog_features(tokens, text):
        features = {}
    
        # Token count
        # token_count = len(tokens)
    Severity: Minor
    Found in newsgac/nlp_tools/models/frog_extract_features.py - About 1 hr to fix

      Function register_user has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def register_user():
          if request.method == 'POST':
              form_dict = request.form.to_dict()
              try:
                  user = User(**form_dict)
      Severity: Minor
      Found in newsgac/users/views.py - About 55 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 feature_weights has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def feature_weights(pipeline, top_features = 10):
          if pipeline.learner._tag in ['svc']:
              return svc_feature_weights(pipeline, top_features)
      
          sk_pipeline = pipeline.sk_pipeline.get()
      Severity: Minor
      Found in newsgac/pipelines/plots.py - About 55 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 get_lime_feature_explanation has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def get_lime_feature_explanation(article, prediction, skp, predict_proba, training_articles, used_class_names):
      Severity: Minor
      Found in newsgac/ace/tasks.py - About 45 mins to fix

        Function explain_article_lime_task has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def explain_article_lime_task(self, view_cache_id, ace_id, pipeline_id, article_number):
        Severity: Minor
        Found in newsgac/ace/tasks.py - About 35 mins to fix

          Function cached_view has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def cached_view(template, view_name, task, args, kwargs):
          Severity: Minor
          Found in newsgac/common/cached_view.py - About 35 mins to fix

            Function confusion_matrix_plot has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def confusion_matrix_plot(pipeline, title="Evaluation", normalisation_flag=True, ds_param = 0.66):
                result = pipeline.result
                confusion_matrix = result.confusion_matrix.get()
                cm_normalised = normalise_confusion_matrix(confusion_matrix)
                genre_names = pipeline.data_source.labels
            Severity: Minor
            Found in newsgac/pipelines/plots.py - 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

            Function create_learner has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def create_learner(tag, with_defaults=True, **kwargs):
                for learner in learners:
                    if learner.tag == tag:
                        if with_defaults:
                            return learner.create(**kwargs)
            Severity: Minor
            Found in newsgac/learners/factory.py - 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

            Function create_nlp_tool has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def create_nlp_tool(tag, with_defaults=True, **kwargs):
                for tool in tools:
                    if tool.tag == tag:
                        if with_defaults:
                            return tool.create(**kwargs)
            Severity: Minor
            Found in newsgac/nlp_tools/factory.py - 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

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

            def new():
                if request.method == 'POST':
                    try:
                        form_dict = request.form.to_dict()
                        stop_words = StopWords(**form_dict)
            Severity: Minor
            Found in newsgac/stop_words/views.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

            Severity
            Category
            Status
            Source
            Language