<commit_before>/*
Copyright libCellML Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "libcellml/issue.h"
#include "libcellml/types.h"
#include "utilities.h"

#include <map>
#include <string>

namespace libcellml {

/**
 * @brief The Issue::IssueImpl struct.
 *
 * The private implementation for the Issue class.
 */
struct Issue::IssueImpl
{
    std::string mDescription; /**< The string description for why this issue was raised. */
    Issue::Cause mCause = Issue::Cause::UNDEFINED; /**< The Issue::Cause enum value for this issue. */
    Issue::Level mLevel = Issue::Level::ERROR; /**< The Issue::Level enum value for this issue. */
    ReferenceRule mRule = ReferenceRule::UNDEFINED; /**< The ReferenceRule enum value for this issue. */
    std::string mReferenceUrl; /**< The web address at which the rule and its guidelines are available. By default
                               it should be the baseIssueUrl plus the reference rule's header number. */
    ComponentPtr mComponent; /**< Pointer to the component that the issue occurred in. */
    ImportSourcePtr mImportSource; /**< Pointer to the import source that the issue occurred in. */
    ModelPtr mModel; /**< Pointer to the model that the issue occurred in. */
    UnitsPtr mUnits; /**< Pointer to the units that the issue occurred in. */
    VariablePtr mVariable; /**< Pointer to the variable that the issue occurred in. */
    ResetPtr mReset; /**< Pointer to the reset that the issue ocurred in. */
};

Issue::Issue()
    : mPimpl(new IssueImpl())
{
}

Issue::~Issue()
{
    delete mPimpl;
}

Issue::Issue(const ModelPtr &model)
    : mPimpl(new IssueImpl())
{
    mPimpl->mModel = model;
    mPimpl->mCause = Issue::Cause::MODEL;
}

Issue::Issue(const ComponentPtr &component)
    : mPimpl(new IssueImpl())
{
    mPimpl->mComponent = component;
    mPimpl->mCause = Issue::Cause::COMPONENT;
}

Issue::Issue(const ImportSourcePtr &importSource)
    : mPimpl(new IssueImpl())
{
    mPimpl->mImportSource = importSource;
    mPimpl->mCause = Issue::Cause::IMPORT;
}

Issue::Issue(const UnitsPtr &units)
    : mPimpl(new IssueImpl())
{
    mPimpl->mUnits = units;
    mPimpl->mCause = Issue::Cause::UNITS;
}

Issue::Issue(const VariablePtr &variable)
    : mPimpl(new IssueImpl())
{
    mPimpl->mVariable = variable;
    mPimpl->mCause = Issue::Cause::VARIABLE;
}

Issue::Issue(const ResetPtr &reset)
    : mPimpl(new IssueImpl())
{
    mPimpl->mReset = reset;
    mPimpl->mCause = Issue::Cause::RESET;
}

IssuePtr Issue::create() noexcept
{
    return std::shared_ptr<Issue> {new Issue {}};
}

IssuePtr Issue::create(const ComponentPtr &component) noexcept
{
    return std::shared_ptr<Issue> {new Issue {component}};
}

IssuePtr Issue::create(const ImportSourcePtr &importSource) noexcept
{
    return std::shared_ptr<Issue> {new Issue {importSource}};
}

IssuePtr Issue::create(const ModelPtr &model) noexcept
{
    return std::shared_ptr<Issue> {new Issue {model}};
}

IssuePtr Issue::create(const ResetPtr &reset) noexcept
{
    return std::shared_ptr<Issue> {new Issue {reset}};
}

IssuePtr Issue::create(const UnitsPtr &units) noexcept
{
    return std::shared_ptr<Issue> {new Issue {units}};
}

IssuePtr Issue::create(const VariablePtr &variable) noexcept
{
    return std::shared_ptr<Issue> {new Issue {variable}};
}

void Issue::setDescription(const std::string &description)
{
    mPimpl->mDescription = description;
}

std::string Issue::description() const
{
    return mPimpl->mDescription;
}

void Issue::setCause(Issue::Cause cause)
{
    mPimpl->mCause = cause;
}

Issue::Cause Issue::cause() const
{
    return mPimpl->mCause;
}

bool Issue::isCause(Cause cause) const
{
    bool response = false;
    if (mPimpl->mCause == cause) {
        response = true;
    }
    return response;
}

void Issue::setLevel(Issue::Level level)
{
    mPimpl->mLevel = level;
}

Issue::Level Issue::level() const
{
    return mPimpl->mLevel;
}

bool Issue::isLevel(Level level) const
{
    bool response = false;
    if (mPimpl->mLevel == level) {
        response = true;
    }
    return response;
}

void Issue::setRule(ReferenceRule rule)
{
    mPimpl->mRule = rule;
}

ReferenceRule Issue::rule() const
{
    return mPimpl->mRule;
}

std::string Issue::url() const
{
    if (mPimpl->mReferenceUrl.empty()) {
        // Then construct from the default address formula: baseIssueUrl + rule number.
        return baseIssueUrl + referenceHeading();
    }
    return mPimpl->mReferenceUrl;
}

void Issue::setComponent(const ComponentPtr &component)
{
    mPimpl->mComponent = component;
    mPimpl->mCause = Issue::Cause::COMPONENT;
}

ComponentPtr Issue::component() const
{
    return mPimpl->mComponent;<commit_msg>Removed mReferenceUrl from Issue class as now not needed<commit_after>/*
Copyright libCellML Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "libcellml/issue.h"
#include "libcellml/types.h"
#include "utilities.h"

#include <map>
#include <string>

namespace libcellml {

/**
 * @brief The Issue::IssueImpl struct.
 *
 * The private implementation for the Issue class.
 */
struct Issue::IssueImpl
{
    std::string mDescription; /**< The string description for why this issue was raised. */
    Issue::Cause mCause = Issue::Cause::UNDEFINED; /**< The Issue::Cause enum value for this issue. */
    Issue::Level mLevel = Issue::Level::ERROR; /**< The Issue::Level enum value for this issue. */
    ReferenceRule mRule = ReferenceRule::UNDEFINED; /**< The ReferenceRule enum value for this issue. */
    ComponentPtr mComponent; /**< Pointer to the component that the issue occurred in. */
    ImportSourcePtr mImportSource; /**< Pointer to the import source that the issue occurred in. */
    ModelPtr mModel; /**< Pointer to the model that the issue occurred in. */
    UnitsPtr mUnits; /**< Pointer to the units that the issue occurred in. */
    VariablePtr mVariable; /**< Pointer to the variable that the issue occurred in. */
    ResetPtr mReset; /**< Pointer to the reset that the issue ocurred in. */
};

Issue::Issue()
    : mPimpl(new IssueImpl())
{
}

Issue::~Issue()
{
    delete mPimpl;
}

Issue::Issue(const ModelPtr &model)
    : mPimpl(new IssueImpl())
{
    mPimpl->mModel = model;
    mPimpl->mCause = Issue::Cause::MODEL;
}

Issue::Issue(const ComponentPtr &component)
    : mPimpl(new IssueImpl())
{
    mPimpl->mComponent = component;
    mPimpl->mCause = Issue::Cause::COMPONENT;
}

Issue::Issue(const ImportSourcePtr &importSource)
    : mPimpl(new IssueImpl())
{
    mPimpl->mImportSource = importSource;
    mPimpl->mCause = Issue::Cause::IMPORT;
}

Issue::Issue(const UnitsPtr &units)
    : mPimpl(new IssueImpl())
{
    mPimpl->mUnits = units;
    mPimpl->mCause = Issue::Cause::UNITS;
}

Issue::Issue(const VariablePtr &variable)
    : mPimpl(new IssueImpl())
{
    mPimpl->mVariable = variable;
    mPimpl->mCause = Issue::Cause::VARIABLE;
}

Issue::Issue(const ResetPtr &reset)
    : mPimpl(new IssueImpl())
{
    mPimpl->mReset = reset;
    mPimpl->mCause = Issue::Cause::RESET;
}

IssuePtr Issue::create() noexcept
{
    return std::shared_ptr<Issue> {new Issue {}};
}

IssuePtr Issue::create(const ComponentPtr &component) noexcept
{
    return std::shared_ptr<Issue> {new Issue {component}};
}

IssuePtr Issue::create(const ImportSourcePtr &importSource) noexcept
{
    return std::shared_ptr<Issue> {new Issue {importSource}};
}

IssuePtr Issue::create(const ModelPtr &model) noexcept
{
    return std::shared_ptr<Issue> {new Issue {model}};
}

IssuePtr Issue::create(const ResetPtr &reset) noexcept
{
    return std::shared_ptr<Issue> {new Issue {reset}};
}

IssuePtr Issue::create(const UnitsPtr &units) noexcept
{
    return std::shared_ptr<Issue> {new Issue {units}};
}

IssuePtr Issue::create(const VariablePtr &variable) noexcept
{
    return std::shared_ptr<Issue> {new Issue {variable}};
}

void Issue::setDescription(const std::string &description)
{
    mPimpl->mDescription = description;
}

std::string Issue::description() const
{
    return mPimpl->mDescription;
}

void Issue::setCause(Issue::Cause cause)
{
    mPimpl->mCause = cause;
}

Issue::Cause Issue::cause() const
{
    return mPimpl->mCause;
}

bool Issue::isCause(Cause cause) const
{
    bool response = false;
    if (mPimpl->mCause == cause) {
        response = true;
    }
    return response;
}

void Issue::setLevel(Issue::Level level)
{
    mPimpl->mLevel = level;
}

Issue::Level Issue::level() const
{
    return mPimpl->mLevel;
}

bool Issue::isLevel(Level level) const
{
    bool response = false;
    if (mPimpl->mLevel == level) {
        response = true;
    }
    return response;
}

void Issue::setRule(ReferenceRule rule)
{
    mPimpl->mRule = rule;
}

ReferenceRule Issue::rule() const
{
    return mPimpl->mRule;
}

std::string Issue::url() const
{
    // Construct from the default address formula: baseIssueUrl + rule number.
    // TODO check that this is appropriate for however we need to handle them.
    return baseIssueUrl + referenceHeading();
}

void Issue::setComponent(const ComponentPtr &component)
{
    mPimpl->mComponent = component;
    mPimpl->mCause = Issue::Cause::COMPONENT;
}

ComponentPtr Issue::component() const
{
    return mPimpl->mComponent;
{'fraction_non_alphanumeric': 0.1238964096527369, 'fraction_numerical': 0.0007847753580537571, 'mean_word_length': 4.0975, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '861107', 'n_tokens_mistral': 3276, 'n_tokens_neox': 3103, 'n_words': 930}